getkeops / keops

KErnel OPerationS, on CPUs and GPUs, with autodiff and without memory overflows
https://www.kernel-operations.io
MIT License
1.04k stars 64 forks source link

Kmin removes infinite values #199

Closed mglisse closed 1 year ago

mglisse commented 2 years ago

The Kmin reduction replaces infinite values with the largest finite float:

import torch
from pykeops.torch import LazyTensor
a=torch.tensor([1e20])
b=LazyTensor(a)
c=b*b
print(c.Kmin(1,dim=0))
print(c.sum_reduction(dim=0))

tensor([[3.4028e+38]]) tensor([[inf]])

We were trying to test for inf or nan to detect overflow, and this broke the detection.

I am using pykeops 1.5 with torch 1.10.0+cu113.