LazyTensor¶
Summary
This section contains the full API documentation of the LazyTensor wrapper, which works identically on NumPy arrays and PyTorch tensors.

Simple wrapper that return an instantiation of 

Simple wrapper that return an instantiation of 

Simple wrapper that return an instantiation of 

Symbolic wrapper for PyTorch tensors. 

Extension of the LazyTensor class for complex operations. 
Syntax

pykeops.torch.
Vi
(x_or_ind, dim=None)[source]¶ Simple wrapper that return an instantiation of
LazyTensor
of type 0.

pykeops.torch.
Vj
(x_or_ind, dim=None)[source]¶ Simple wrapper that return an instantiation of
LazyTensor
of type 1.

pykeops.torch.
Pm
(x_or_ind, dim=None)[source]¶ Simple wrapper that return an instantiation of
LazyTensor
of type 2.

class
pykeops.torch.
LazyTensor
(x=None, axis=None, is_complex=False)[source]¶ Symbolic wrapper for PyTorch tensors.
LazyTensor
encode numerical arrays through the combination of a symbolic, mathematical formula and a list of small data arrays. They can be used to implement efficient algorithms on objects that are easy to define, but impossible to store in memory (e.g. the matrix of pairwise distances between two large point clouds).LazyTensor
may be created from standard NumPy arrays or PyTorch tensors, combined using simple mathematical operations and converted back to NumPy arrays or PyTorch tensors with efficient reduction routines, which outperform standard tensorized implementations by two orders of magnitude.
static
__new__
(self, x=None, axis=None, is_complex=False)[source]¶ Create and return a new object. See help(type) for accurate signature.

__init__
(x=None, axis=None, is_complex=False)[source]¶ Creates a KeOps symbolic variable.
 Parameters
x –
May be either:
A float, a list of floats, a NumPy float, a 0D or 1D NumPy array, a 0D or 1D PyTorch tensor, in which case the
LazyTensor
represents a constant vector of parameters, to be broadcasted on otherLazyTensor
.A 2D NumPy array or PyTorch tensor, in which case the
LazyTensor
represents a variable indexed by \(i\) if axis=0 or \(j\) if axis=1.A 3D+ NumPy array or PyTorch tensor with a dummy dimension (=1) at position 3 or 2, in which case the
LazyTensor
represents a variable indexed by \(i\) or \(j\), respectively. Dimensions before the last three will be handled as batch dimensions, that may support operator broadcasting.A tuple of 3 integers (ind,dim,cat), in which case the
LazyTensor
represents a symbolic variable that should be instantiated at calltime.An integer, in which case the
LazyTensor
represents an integer constant handled efficiently at compilation time.None, for internal use.
axis (int) – should be equal to 0 or 1 if x is a 2D tensor, and None otherwise.
Warning
A
LazyTensor
constructed from a NumPy array or a PyTorch tensor retains its dtype (float16, float32 or float64) and device properties (is it stored on the GPU?). Since KeOps does not support automatic type conversions and data transfers, please make sure not to mixLazyTensor
that come from different frameworks/devices or which are stored with different precisions.

get_tools
()[source]¶ This method is specialized in
pykeops.numpy.LazyTensor
andpykeops.torch.LazyTensor
. It populate the tools class.

lt_constructor
(x=None, axis=None, is_complex=False)[source]¶ This method is specialized in
pykeops.numpy.LazyTensor
andpykeops.torch.LazyTensor
. It returns a new instance of a LazyTensor (numpy or pytorch).

static

class
pykeops.torch.
ComplexLazyTensor
(x=None, axis=None)[source]¶ Extension of the LazyTensor class for complex operations.

get_tools
()[source]¶ This method is specialized in
pykeops.numpy.LazyTensor
andpykeops.torch.LazyTensor
. It populate the tools class.

lt_constructor
(x=None, axis=None, is_complex=True)[source]¶ This method is specialized in
pykeops.numpy.LazyTensor
andpykeops.torch.LazyTensor
. It returns a new instance of a LazyTensor (numpy or pytorch).
