MinkowskiPooling

MinkowskiMaxPooling

class MinkowskiEngine.MinkowskiMaxPooling(kernel_size, stride=1, dilation=1, kernel_generator=None, dimension=None)

A max pooling layer for a sparse tensor.

\[y^c_\mathbf{u} = \max_{\mathbf{i} \in \mathcal{N}^D(\mathbf{u}, \mathcal{C}^\text{in})} x^c_{\mathbf{u} + \mathbf{i}} \; \text{for} \; \mathbf{u} \in \mathcal{C}^\text{out}\]

where \(y^c_\mathbf{u}\) is a feature at channel \(c\) and a coordinate \(\mathbf{u}\).

Note

The engine will generate the in-out mapping corresponding to a pooling function faster if the kernel sizes is equal to the stride sizes, e.g. kernel_size = [2, 1], stride = [2, 1].

If you use a U-network architecture, use the transposed version of the same function for up-sampling. e.g. pool = MinkowskiSumPooling(kernel_size=2, stride=2, D=D), then use the unpool = MinkowskiPoolingTranspose(kernel_size=2, stride=2, D=D).

__init__(kernel_size, stride=1, dilation=1, kernel_generator=None, dimension=None)

a high-dimensional max pooling layer for sparse tensors.

Args:

kernel_size (int, optional): the size of the kernel in the output tensor. If not provided, region_offset should be RegionType.CUSTOM and region_offset should be a 2D matrix with size \(N\times D\) such that it lists all \(N\) offsets in D-dimension.

stride (int, or list, optional): stride size of the convolution layer. If non-identity is used, the output coordinates will be at least stride \(\times\) tensor_stride away. When a list is given, the length must be D; each element will be used for stride size for the specific axis.

dilation (int, or list, optional): dilation size for the convolution kernel. When a list is given, the length must be D and each element is an axis specific dilation. All elements must be > 0.

kernel_generator (MinkowskiEngine.KernelGenerator, optional): define custom kernel shape.

dimension (int): the spatial dimension of the space where all the inputs and the network are defined. For example, images are in a 2D space, meshes and 3D shapes are in a 3D space.

Warning

Custom kernel shapes are not supported when kernel_size == stride.

cpu() → T

Moves all model parameters and buffers to the CPU.

Returns:

Module: self

cuda(device: Optional[Union[int, torch.device]] = None) → T

Moves all model parameters and buffers to the GPU.

This also makes associated parameters and buffers different objects. So it should be called before constructing optimizer if the module will live on GPU while being optimized.

Arguments:
device (int, optional): if specified, all parameters will be

copied to that device

Returns:

Module: self

double() → T

Casts all floating point parameters and buffers to double datatype.

Returns:

Module: self

float() → T

Casts all floating point parameters and buffers to float datatype.

Returns:

Module: self

forward(input: MinkowskiSparseTensor.SparseTensor, coordinates: Optional[Union[torch.IntTensor, MinkowskiEngineBackend._C.CoordinateMapKey, MinkowskiSparseTensor.SparseTensor]] = None)

input (MinkowskiEngine.SparseTensor): Input sparse tensor to apply a convolution on.

coordinates ((torch.IntTensor, MinkowskiEngine.CoordsKey, MinkowskiEngine.SparseTensor), optional): If provided, generate results on the provided coordinates. None by default.

to(*args, **kwargs)

Moves and/or casts the parameters and buffers.

This can be called as

to(device=None, dtype=None, non_blocking=False)
to(dtype, non_blocking=False)
to(tensor, non_blocking=False)
to(memory_format=torch.channels_last)

Its signature is similar to torch.Tensor.to(), but only accepts floating point desired dtype s. In addition, this method will only cast the floating point parameters and buffers to dtype (if given). The integral parameters and buffers will be moved device, if that is given, but with dtypes unchanged. When non_blocking is set, it tries to convert/move asynchronously with respect to the host if possible, e.g., moving CPU Tensors with pinned memory to CUDA devices.

See below for examples.

Note

This method modifies the module in-place.

Args:
device (torch.device): the desired device of the parameters

and buffers in this module

dtype (torch.dtype): the desired floating point type of

the floating point parameters and buffers in this module

tensor (torch.Tensor): Tensor whose dtype and device are the desired

dtype and device for all parameters and buffers in this module

memory_format (torch.memory_format): the desired memory

format for 4D parameters and buffers in this module (keyword only argument)

Returns:

Module: self

Example:

>>> linear = nn.Linear(2, 2)
>>> linear.weight
Parameter containing:
tensor([[ 0.1913, -0.3420],
        [-0.5113, -0.2325]])
>>> linear.to(torch.double)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1913, -0.3420],
        [-0.5113, -0.2325]], dtype=torch.float64)
>>> gpu1 = torch.device("cuda:1")
>>> linear.to(gpu1, dtype=torch.half, non_blocking=True)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1914, -0.3420],
        [-0.5112, -0.2324]], dtype=torch.float16, device='cuda:1')
>>> cpu = torch.device("cpu")
>>> linear.to(cpu)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1914, -0.3420],
        [-0.5112, -0.2324]], dtype=torch.float16)
type(dst_type: Union[torch.dtype, str]) → T

Casts all parameters and buffers to dst_type.

Arguments:

dst_type (type or string): the desired type

Returns:

Module: self

MinkowskiAvgPooling

class MinkowskiEngine.MinkowskiAvgPooling(kernel_size=- 1, stride=1, dilation=1, kernel_generator=None, dimension=None)

Average input features within a kernel.

\[\mathbf{y}_\mathbf{u} = \frac{1}{|\mathcal{N}^D(\mathbf{u}, \mathcal{C}^\text{in})|} \sum_{\mathbf{i} \in \mathcal{N}^D(\mathbf{u}, \mathcal{C}^\text{in})} \mathbf{x}_{\mathbf{u} + \mathbf{i}} \; \text{for} \; \mathbf{u} \in \mathcal{C}^\text{out}\]

For each output \(\mathbf{u}\) in \(\mathcal{C}^\text{out}\), average input features.

Note

An average layer first computes the cardinality of the input features, the number of input features for each output, and divide the sum of the input features by the cardinality. For a dense tensor, the cardinality is a constant, the volume of a kernel. However, for a sparse tensor, the cardinality varies depending on the number of input features per output. Thus, the average pooling for a sparse tensor is not equivalent to the conventional average pooling layer for a dense tensor. Please refer to the MinkowskiSumPooling for the equivalent layer.

Note

The engine will generate the in-out mapping corresponding to a pooling function faster if the kernel sizes is equal to the stride sizes, e.g. kernel_size = [2, 1], stride = [2, 1].

If you use a U-network architecture, use the transposed version of the same function for up-sampling. e.g. pool = MinkowskiSumPooling(kernel_size=2, stride=2, D=D), then use the unpool = MinkowskiPoolingTranspose(kernel_size=2, stride=2, D=D).

__init__(kernel_size=- 1, stride=1, dilation=1, kernel_generator=None, dimension=None)

a high-dimensional sparse average pooling layer.

Args:

kernel_size (int, optional): the size of the kernel in the output tensor. If not provided, region_offset should be RegionType.CUSTOM and region_offset should be a 2D matrix with size \(N\times D\) such that it lists all \(N\) offsets in D-dimension.

stride (int, or list, optional): stride size of the convolution layer. If non-identity is used, the output coordinates will be at least stride \(\times\) tensor_stride away. When a list is given, the length must be D; each element will be used for stride size for the specific axis.

dilation (int, or list, optional): dilation size for the convolution kernel. When a list is given, the length must be D and each element is an axis specific dilation. All elements must be > 0.

kernel_generator (MinkowskiEngine.KernelGenerator, optional): define custom kernel shape.

dimension (int): the spatial dimension of the space where all the inputs and the network are defined. For example, images are in a 2D space, meshes and 3D shapes are in a 3D space.

Warning

Custom kernel shapes are not supported when kernel_size == stride.

cpu() → T

Moves all model parameters and buffers to the CPU.

Returns:

Module: self

cuda(device: Optional[Union[int, torch.device]] = None) → T

Moves all model parameters and buffers to the GPU.

This also makes associated parameters and buffers different objects. So it should be called before constructing optimizer if the module will live on GPU while being optimized.

Arguments:
device (int, optional): if specified, all parameters will be

copied to that device

Returns:

Module: self

double() → T

Casts all floating point parameters and buffers to double datatype.

Returns:

Module: self

float() → T

Casts all floating point parameters and buffers to float datatype.

Returns:

Module: self

forward(input: MinkowskiSparseTensor.SparseTensor, coordinates: Optional[Union[torch.IntTensor, MinkowskiEngineBackend._C.CoordinateMapKey, MinkowskiSparseTensor.SparseTensor]] = None)

input (MinkowskiEngine.SparseTensor): Input sparse tensor to apply a convolution on.

coordinates ((torch.IntTensor, MinkowskiEngine.CoordsKey, MinkowskiEngine.SparseTensor), optional): If provided, generate results on the provided coordinates. None by default.

to(*args, **kwargs)

Moves and/or casts the parameters and buffers.

This can be called as

to(device=None, dtype=None, non_blocking=False)
to(dtype, non_blocking=False)
to(tensor, non_blocking=False)
to(memory_format=torch.channels_last)

Its signature is similar to torch.Tensor.to(), but only accepts floating point desired dtype s. In addition, this method will only cast the floating point parameters and buffers to dtype (if given). The integral parameters and buffers will be moved device, if that is given, but with dtypes unchanged. When non_blocking is set, it tries to convert/move asynchronously with respect to the host if possible, e.g., moving CPU Tensors with pinned memory to CUDA devices.

See below for examples.

Note

This method modifies the module in-place.

Args:
device (torch.device): the desired device of the parameters

and buffers in this module

dtype (torch.dtype): the desired floating point type of

the floating point parameters and buffers in this module

tensor (torch.Tensor): Tensor whose dtype and device are the desired

dtype and device for all parameters and buffers in this module

memory_format (torch.memory_format): the desired memory

format for 4D parameters and buffers in this module (keyword only argument)

Returns:

Module: self

Example:

>>> linear = nn.Linear(2, 2)
>>> linear.weight
Parameter containing:
tensor([[ 0.1913, -0.3420],
        [-0.5113, -0.2325]])
>>> linear.to(torch.double)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1913, -0.3420],
        [-0.5113, -0.2325]], dtype=torch.float64)
>>> gpu1 = torch.device("cuda:1")
>>> linear.to(gpu1, dtype=torch.half, non_blocking=True)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1914, -0.3420],
        [-0.5112, -0.2324]], dtype=torch.float16, device='cuda:1')
>>> cpu = torch.device("cpu")
>>> linear.to(cpu)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1914, -0.3420],
        [-0.5112, -0.2324]], dtype=torch.float16)
type(dst_type: Union[torch.dtype, str]) → T

Casts all parameters and buffers to dst_type.

Arguments:

dst_type (type or string): the desired type

Returns:

Module: self

MinkowskiSumPooling

class MinkowskiEngine.MinkowskiSumPooling(kernel_size, stride=1, dilation=1, kernel_generator=None, dimension=None)

Sum all input features within a kernel.

\[\mathbf{y}_\mathbf{u} = \sum_{\mathbf{i} \in \mathcal{N}^D(\mathbf{u}, \mathcal{C}^\text{in})} \mathbf{x}_{\mathbf{u} + \mathbf{i}} \; \text{for} \; \mathbf{u} \in \mathcal{C}^\text{out}\]

For each output \(\mathbf{u}\) in \(\mathcal{C}^\text{out}\), average input features.

Note

An average layer first computes the cardinality of the input features, the number of input features for each output, and divide the sum of the input features by the cardinality. For a dense tensor, the cardinality is a constant, the volume of a kernel. However, for a sparse tensor, the cardinality varies depending on the number of input features per output. Thus, averaging the input features with the cardinality may not be equivalent to the conventional average pooling for a dense tensor. This layer provides an alternative that does not divide the sum by the cardinality.

Note

The engine will generate the in-out mapping corresponding to a pooling function faster if the kernel sizes is equal to the stride sizes, e.g. kernel_size = [2, 1], stride = [2, 1].

If you use a U-network architecture, use the transposed version of the same function for up-sampling. e.g. pool = MinkowskiSumPooling(kernel_size=2, stride=2, D=D), then use the unpool = MinkowskiPoolingTranspose(kernel_size=2, stride=2, D=D).

__init__(kernel_size, stride=1, dilation=1, kernel_generator=None, dimension=None)

a high-dimensional sum pooling layer

Args:

kernel_size (int, optional): the size of the kernel in the output tensor. If not provided, region_offset should be RegionType.CUSTOM and region_offset should be a 2D matrix with size \(N\times D\) such that it lists all \(N\) offsets in D-dimension.

stride (int, or list, optional): stride size of the convolution layer. If non-identity is used, the output coordinates will be at least stride \(\times\) tensor_stride away. When a list is given, the length must be D; each element will be used for stride size for the specific axis.

dilation (int, or list, optional): dilation size for the convolution kernel. When a list is given, the length must be D and each element is an axis specific dilation. All elements must be > 0.

kernel_generator (MinkowskiEngine.KernelGenerator, optional): define custom kernel shape.

dimension (int): the spatial dimension of the space where all the inputs and the network are defined. For example, images are in a 2D space, meshes and 3D shapes are in a 3D space.

Warning

Custom kernel shapes are not supported when kernel_size == stride.

cpu() → T

Moves all model parameters and buffers to the CPU.

Returns:

Module: self

cuda(device: Optional[Union[int, torch.device]] = None) → T

Moves all model parameters and buffers to the GPU.

This also makes associated parameters and buffers different objects. So it should be called before constructing optimizer if the module will live on GPU while being optimized.

Arguments:
device (int, optional): if specified, all parameters will be

copied to that device

Returns:

Module: self

double() → T

Casts all floating point parameters and buffers to double datatype.

Returns:

Module: self

float() → T

Casts all floating point parameters and buffers to float datatype.

Returns:

Module: self

forward(input: MinkowskiSparseTensor.SparseTensor, coordinates: Optional[Union[torch.IntTensor, MinkowskiEngineBackend._C.CoordinateMapKey, MinkowskiSparseTensor.SparseTensor]] = None)

input (MinkowskiEngine.SparseTensor): Input sparse tensor to apply a convolution on.

coordinates ((torch.IntTensor, MinkowskiEngine.CoordsKey, MinkowskiEngine.SparseTensor), optional): If provided, generate results on the provided coordinates. None by default.

to(*args, **kwargs)

Moves and/or casts the parameters and buffers.

This can be called as

to(device=None, dtype=None, non_blocking=False)
to(dtype, non_blocking=False)
to(tensor, non_blocking=False)
to(memory_format=torch.channels_last)

Its signature is similar to torch.Tensor.to(), but only accepts floating point desired dtype s. In addition, this method will only cast the floating point parameters and buffers to dtype (if given). The integral parameters and buffers will be moved device, if that is given, but with dtypes unchanged. When non_blocking is set, it tries to convert/move asynchronously with respect to the host if possible, e.g., moving CPU Tensors with pinned memory to CUDA devices.

See below for examples.

Note

This method modifies the module in-place.

Args:
device (torch.device): the desired device of the parameters

and buffers in this module

dtype (torch.dtype): the desired floating point type of

the floating point parameters and buffers in this module

tensor (torch.Tensor): Tensor whose dtype and device are the desired

dtype and device for all parameters and buffers in this module

memory_format (torch.memory_format): the desired memory

format for 4D parameters and buffers in this module (keyword only argument)

Returns:

Module: self

Example:

>>> linear = nn.Linear(2, 2)
>>> linear.weight
Parameter containing:
tensor([[ 0.1913, -0.3420],
        [-0.5113, -0.2325]])
>>> linear.to(torch.double)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1913, -0.3420],
        [-0.5113, -0.2325]], dtype=torch.float64)
>>> gpu1 = torch.device("cuda:1")
>>> linear.to(gpu1, dtype=torch.half, non_blocking=True)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1914, -0.3420],
        [-0.5112, -0.2324]], dtype=torch.float16, device='cuda:1')
>>> cpu = torch.device("cpu")
>>> linear.to(cpu)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1914, -0.3420],
        [-0.5112, -0.2324]], dtype=torch.float16)
type(dst_type: Union[torch.dtype, str]) → T

Casts all parameters and buffers to dst_type.

Arguments:

dst_type (type or string): the desired type

Returns:

Module: self

MinkowskiPoolingTranspose

class MinkowskiEngine.MinkowskiPoolingTranspose(kernel_size, stride, dilation=1, kernel_generator=None, expand_coordinates=False, dimension=None)

A pooling transpose layer for a sparse tensor.

Unpool the features and divide it by the number of non zero elements that contributed.

__init__(kernel_size, stride, dilation=1, kernel_generator=None, expand_coordinates=False, dimension=None)

a high-dimensional unpooling layer for sparse tensors.

Args:

kernel_size (int, optional): the size of the kernel in the output tensor. If not provided, region_offset should be RegionType.CUSTOM and region_offset should be a 2D matrix with size \(N\times D\) such that it lists all \(N\) offsets in D-dimension.

stride (int, or list, optional): stride size of the convolution layer. If non-identity is used, the output coordinates will be at least stride \(\times\) tensor_stride away. When a list is given, the length must be D; each element will be used for stride size for the specific axis.

dilation (int, or list, optional): dilation size for the convolution kernel. When a list is given, the length must be D and each element is an axis specific dilation. All elements must be > 0.

kernel_generator (MinkowskiEngine.KernelGenerator, optional): define custom kernel shape.

expand_coordinates (bool, optional): Force generation of new coordinates. When True, the output coordinates will be the outer product of the kernel shape and the input coordinates. False by default.

dimension (int): the spatial dimension of the space where all the inputs and the network are defined. For example, images are in a 2D space, meshes and 3D shapes are in a 3D space.

cpu() → T

Moves all model parameters and buffers to the CPU.

Returns:

Module: self

cuda(device: Optional[Union[int, torch.device]] = None) → T

Moves all model parameters and buffers to the GPU.

This also makes associated parameters and buffers different objects. So it should be called before constructing optimizer if the module will live on GPU while being optimized.

Arguments:
device (int, optional): if specified, all parameters will be

copied to that device

Returns:

Module: self

double() → T

Casts all floating point parameters and buffers to double datatype.

Returns:

Module: self

float() → T

Casts all floating point parameters and buffers to float datatype.

Returns:

Module: self

forward(input: MinkowskiSparseTensor.SparseTensor, coordinates: Optional[Union[torch.IntTensor, MinkowskiEngineBackend._C.CoordinateMapKey, MinkowskiSparseTensor.SparseTensor]] = None)

input (MinkowskiEngine.SparseTensor): Input sparse tensor to apply a convolution on.

coordinates ((torch.IntTensor, MinkowskiEngine.CoordsKey, MinkowskiEngine.SparseTensor), optional): If provided, generate results on the provided coordinates. None by default.

to(*args, **kwargs)

Moves and/or casts the parameters and buffers.

This can be called as

to(device=None, dtype=None, non_blocking=False)
to(dtype, non_blocking=False)
to(tensor, non_blocking=False)
to(memory_format=torch.channels_last)

Its signature is similar to torch.Tensor.to(), but only accepts floating point desired dtype s. In addition, this method will only cast the floating point parameters and buffers to dtype (if given). The integral parameters and buffers will be moved device, if that is given, but with dtypes unchanged. When non_blocking is set, it tries to convert/move asynchronously with respect to the host if possible, e.g., moving CPU Tensors with pinned memory to CUDA devices.

See below for examples.

Note

This method modifies the module in-place.

Args:
device (torch.device): the desired device of the parameters

and buffers in this module

dtype (torch.dtype): the desired floating point type of

the floating point parameters and buffers in this module

tensor (torch.Tensor): Tensor whose dtype and device are the desired

dtype and device for all parameters and buffers in this module

memory_format (torch.memory_format): the desired memory

format for 4D parameters and buffers in this module (keyword only argument)

Returns:

Module: self

Example:

>>> linear = nn.Linear(2, 2)
>>> linear.weight
Parameter containing:
tensor([[ 0.1913, -0.3420],
        [-0.5113, -0.2325]])
>>> linear.to(torch.double)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1913, -0.3420],
        [-0.5113, -0.2325]], dtype=torch.float64)
>>> gpu1 = torch.device("cuda:1")
>>> linear.to(gpu1, dtype=torch.half, non_blocking=True)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1914, -0.3420],
        [-0.5112, -0.2324]], dtype=torch.float16, device='cuda:1')
>>> cpu = torch.device("cpu")
>>> linear.to(cpu)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1914, -0.3420],
        [-0.5112, -0.2324]], dtype=torch.float16)
type(dst_type: Union[torch.dtype, str]) → T

Casts all parameters and buffers to dst_type.

Arguments:

dst_type (type or string): the desired type

Returns:

Module: self

MinkowskiGlobalMaxPooling

class MinkowskiEngine.MinkowskiGlobalMaxPooling(mode=<PoolingMode.GLOBAL_MAX_POOLING_PYTORCH_INDEX: 11>)

Max pool all input features to one output feature at the origin.

\[\mathbf{y} = \max_{\mathbf{i} \in \mathcal{C}^\text{in}} \mathbf{x}_{\mathbf{i}}\]
__init__(mode=<PoolingMode.GLOBAL_MAX_POOLING_PYTORCH_INDEX: 11>)

Reduces sparse coords into points at origin, i.e. reduce each point cloud into a point at the origin, returning batch_size number of points [[0, 0, …, 0], [0, 0, …, 1],, [0, 0, …, 2]] where the last elem of the coords is the batch index.

cpu() → T

Moves all model parameters and buffers to the CPU.

Returns:

Module: self

cuda(device: Optional[Union[int, torch.device]] = None) → T

Moves all model parameters and buffers to the GPU.

This also makes associated parameters and buffers different objects. So it should be called before constructing optimizer if the module will live on GPU while being optimized.

Arguments:
device (int, optional): if specified, all parameters will be

copied to that device

Returns:

Module: self

double() → T

Casts all floating point parameters and buffers to double datatype.

Returns:

Module: self

float() → T

Casts all floating point parameters and buffers to float datatype.

Returns:

Module: self

forward(input, coordinates: Optional[Union[torch.IntTensor, MinkowskiEngineBackend._C.CoordinateMapKey, MinkowskiSparseTensor.SparseTensor]] = None)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

to(*args, **kwargs)

Moves and/or casts the parameters and buffers.

This can be called as

to(device=None, dtype=None, non_blocking=False)
to(dtype, non_blocking=False)
to(tensor, non_blocking=False)
to(memory_format=torch.channels_last)

Its signature is similar to torch.Tensor.to(), but only accepts floating point desired dtype s. In addition, this method will only cast the floating point parameters and buffers to dtype (if given). The integral parameters and buffers will be moved device, if that is given, but with dtypes unchanged. When non_blocking is set, it tries to convert/move asynchronously with respect to the host if possible, e.g., moving CPU Tensors with pinned memory to CUDA devices.

See below for examples.

Note

This method modifies the module in-place.

Args:
device (torch.device): the desired device of the parameters

and buffers in this module

dtype (torch.dtype): the desired floating point type of

the floating point parameters and buffers in this module

tensor (torch.Tensor): Tensor whose dtype and device are the desired

dtype and device for all parameters and buffers in this module

memory_format (torch.memory_format): the desired memory

format for 4D parameters and buffers in this module (keyword only argument)

Returns:

Module: self

Example:

>>> linear = nn.Linear(2, 2)
>>> linear.weight
Parameter containing:
tensor([[ 0.1913, -0.3420],
        [-0.5113, -0.2325]])
>>> linear.to(torch.double)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1913, -0.3420],
        [-0.5113, -0.2325]], dtype=torch.float64)
>>> gpu1 = torch.device("cuda:1")
>>> linear.to(gpu1, dtype=torch.half, non_blocking=True)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1914, -0.3420],
        [-0.5112, -0.2324]], dtype=torch.float16, device='cuda:1')
>>> cpu = torch.device("cpu")
>>> linear.to(cpu)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1914, -0.3420],
        [-0.5112, -0.2324]], dtype=torch.float16)
type(dst_type: Union[torch.dtype, str]) → T

Casts all parameters and buffers to dst_type.

Arguments:

dst_type (type or string): the desired type

Returns:

Module: self

MinkowskiGlobalAvgPooling

class MinkowskiEngine.MinkowskiGlobalAvgPooling(mode=<PoolingMode.GLOBAL_AVG_POOLING_PYTORCH_INDEX: 10>)
__init__(mode=<PoolingMode.GLOBAL_AVG_POOLING_PYTORCH_INDEX: 10>)

Reduces sparse coords into points at origin, i.e. reduce each point cloud into a point at the origin, returning batch_size number of points [[0, 0, …, 0], [0, 0, …, 1],, [0, 0, …, 2]] where the last elem of the coords is the batch index.

cpu() → T

Moves all model parameters and buffers to the CPU.

Returns:

Module: self

cuda(device: Optional[Union[int, torch.device]] = None) → T

Moves all model parameters and buffers to the GPU.

This also makes associated parameters and buffers different objects. So it should be called before constructing optimizer if the module will live on GPU while being optimized.

Arguments:
device (int, optional): if specified, all parameters will be

copied to that device

Returns:

Module: self

double() → T

Casts all floating point parameters and buffers to double datatype.

Returns:

Module: self

float() → T

Casts all floating point parameters and buffers to float datatype.

Returns:

Module: self

forward(input: MinkowskiSparseTensor.SparseTensor, coordinates: Optional[Union[torch.IntTensor, MinkowskiEngineBackend._C.CoordinateMapKey, MinkowskiSparseTensor.SparseTensor]] = None)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

to(*args, **kwargs)

Moves and/or casts the parameters and buffers.

This can be called as

to(device=None, dtype=None, non_blocking=False)
to(dtype, non_blocking=False)
to(tensor, non_blocking=False)
to(memory_format=torch.channels_last)

Its signature is similar to torch.Tensor.to(), but only accepts floating point desired dtype s. In addition, this method will only cast the floating point parameters and buffers to dtype (if given). The integral parameters and buffers will be moved device, if that is given, but with dtypes unchanged. When non_blocking is set, it tries to convert/move asynchronously with respect to the host if possible, e.g., moving CPU Tensors with pinned memory to CUDA devices.

See below for examples.

Note

This method modifies the module in-place.

Args:
device (torch.device): the desired device of the parameters

and buffers in this module

dtype (torch.dtype): the desired floating point type of

the floating point parameters and buffers in this module

tensor (torch.Tensor): Tensor whose dtype and device are the desired

dtype and device for all parameters and buffers in this module

memory_format (torch.memory_format): the desired memory

format for 4D parameters and buffers in this module (keyword only argument)

Returns:

Module: self

Example:

>>> linear = nn.Linear(2, 2)
>>> linear.weight
Parameter containing:
tensor([[ 0.1913, -0.3420],
        [-0.5113, -0.2325]])
>>> linear.to(torch.double)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1913, -0.3420],
        [-0.5113, -0.2325]], dtype=torch.float64)
>>> gpu1 = torch.device("cuda:1")
>>> linear.to(gpu1, dtype=torch.half, non_blocking=True)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1914, -0.3420],
        [-0.5112, -0.2324]], dtype=torch.float16, device='cuda:1')
>>> cpu = torch.device("cpu")
>>> linear.to(cpu)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1914, -0.3420],
        [-0.5112, -0.2324]], dtype=torch.float16)
type(dst_type: Union[torch.dtype, str]) → T

Casts all parameters and buffers to dst_type.

Arguments:

dst_type (type or string): the desired type

Returns:

Module: self

MinkowskiGlobalSumPooling

class MinkowskiEngine.MinkowskiGlobalSumPooling(mode=<PoolingMode.GLOBAL_SUM_POOLING_PYTORCH_INDEX: 9>)
__init__(mode=<PoolingMode.GLOBAL_SUM_POOLING_PYTORCH_INDEX: 9>)

Reduces sparse coords into points at origin, i.e. reduce each point cloud into a point at the origin, returning batch_size number of points [[0, 0, …, 0], [0, 0, …, 1],, [0, 0, …, 2]] where the last elem of the coords is the batch index.

cpu() → T

Moves all model parameters and buffers to the CPU.

Returns:

Module: self

cuda(device: Optional[Union[int, torch.device]] = None) → T

Moves all model parameters and buffers to the GPU.

This also makes associated parameters and buffers different objects. So it should be called before constructing optimizer if the module will live on GPU while being optimized.

Arguments:
device (int, optional): if specified, all parameters will be

copied to that device

Returns:

Module: self

double() → T

Casts all floating point parameters and buffers to double datatype.

Returns:

Module: self

float() → T

Casts all floating point parameters and buffers to float datatype.

Returns:

Module: self

forward(input: MinkowskiSparseTensor.SparseTensor, coordinates: Optional[Union[torch.IntTensor, MinkowskiEngineBackend._C.CoordinateMapKey, MinkowskiSparseTensor.SparseTensor]] = None)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

to(*args, **kwargs)

Moves and/or casts the parameters and buffers.

This can be called as

to(device=None, dtype=None, non_blocking=False)
to(dtype, non_blocking=False)
to(tensor, non_blocking=False)
to(memory_format=torch.channels_last)

Its signature is similar to torch.Tensor.to(), but only accepts floating point desired dtype s. In addition, this method will only cast the floating point parameters and buffers to dtype (if given). The integral parameters and buffers will be moved device, if that is given, but with dtypes unchanged. When non_blocking is set, it tries to convert/move asynchronously with respect to the host if possible, e.g., moving CPU Tensors with pinned memory to CUDA devices.

See below for examples.

Note

This method modifies the module in-place.

Args:
device (torch.device): the desired device of the parameters

and buffers in this module

dtype (torch.dtype): the desired floating point type of

the floating point parameters and buffers in this module

tensor (torch.Tensor): Tensor whose dtype and device are the desired

dtype and device for all parameters and buffers in this module

memory_format (torch.memory_format): the desired memory

format for 4D parameters and buffers in this module (keyword only argument)

Returns:

Module: self

Example:

>>> linear = nn.Linear(2, 2)
>>> linear.weight
Parameter containing:
tensor([[ 0.1913, -0.3420],
        [-0.5113, -0.2325]])
>>> linear.to(torch.double)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1913, -0.3420],
        [-0.5113, -0.2325]], dtype=torch.float64)
>>> gpu1 = torch.device("cuda:1")
>>> linear.to(gpu1, dtype=torch.half, non_blocking=True)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1914, -0.3420],
        [-0.5112, -0.2324]], dtype=torch.float16, device='cuda:1')
>>> cpu = torch.device("cpu")
>>> linear.to(cpu)
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight
Parameter containing:
tensor([[ 0.1914, -0.3420],
        [-0.5112, -0.2324]], dtype=torch.float16)
type(dst_type: Union[torch.dtype, str]) → T

Casts all parameters and buffers to dst_type.

Arguments:

dst_type (type or string): the desired type

Returns:

Module: self