Coordinate Management

CoordinateMapKey

class MinkowskiEngine.CoordinateMapKey
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: MinkowskiEngineBackend._C.CoordinateMapKey, arg0: int) -> None

  2. __init__(self: MinkowskiEngineBackend._C.CoordinateMapKey, arg0: List[int], arg1: str) -> None

get_coordinate_size(self: MinkowskiEngineBackend._C.CoordinateMapKey) → int
get_key(self: MinkowskiEngineBackend._C.CoordinateMapKey) → Tuple[List[int], str]
get_tensor_stride(self: MinkowskiEngineBackend._C.CoordinateMapKey) → List[int]
is_key_set(self: MinkowskiEngineBackend._C.CoordinateMapKey) → bool
set_key(*args, **kwargs)

Overloaded function.

  1. set_key(self: MinkowskiEngineBackend._C.CoordinateMapKey, arg0: List[int], arg1: str) -> None

  2. set_key(self: MinkowskiEngineBackend._C.CoordinateMapKey, arg0: Tuple[List[int], str]) -> None

CoordinateManager

class MinkowskiEngine.CoordinateManager(D: int = 0, num_threads: int = - 1, coordinate_map_type: Optional[MinkowskiEngineBackend._C.CoordinateMapType] = None, allocator_type: Optional[MinkowskiEngineBackend._C.GPUMemoryAllocatorType] = None, minkowski_algorithm: Optional[MinkowskiEngineBackend._C.MinkowskiAlgorithm] = None)
__init__(D: int = 0, num_threads: int = - 1, coordinate_map_type: Optional[MinkowskiEngineBackend._C.CoordinateMapType] = None, allocator_type: Optional[MinkowskiEngineBackend._C.GPUMemoryAllocatorType] = None, minkowski_algorithm: Optional[MinkowskiEngineBackend._C.MinkowskiAlgorithm] = None)

D: The order, or dimension of the coordinates.

exists_field_to_sparse(field_map_key: MinkowskiEngineBackend._C.CoordinateMapKey, sparse_map_key: MinkowskiEngineBackend._C.CoordinateMapKey)
field_to_sparse_insert_and_map(field_map_key: MinkowskiEngineBackend._C.CoordinateMapKey, sparse_tensor_stride: Union[int, collections.abc.Sequence, numpy.ndarray], sparse_tensor_string_id: str = '') → Tuple[MinkowskiEngineBackend._C.CoordinateMapKey, Tuple[torch.IntTensor, torch.IntTensor]]

Create a sparse tensor coordinate map with the tensor stride.

field_map_key (CoordinateMapKey): field map that a new sparse tensor will be created from.

tensor_stride (list): a list of D elements that defines the tensor stride for the new order-D + 1 sparse tensor.

string_id (str): string id of the new sparse tensor coordinate map key.

Example:

>>> manager = CoordinateManager(D=1)
>>> coordinates = torch.FloatTensor([[0, 0.1], [0, 2.3], [0, 1.2], [0, 2.4]])
>>> key, (unique_map, inverse_map) = manager.insert(coordinates, [1])
field_to_sparse_keys(field_map_key: MinkowskiEngineBackend._C.CoordinateMapKey)
field_to_sparse_map(field_map_key: MinkowskiEngineBackend._C.CoordinateMapKey, sparse_map_key: MinkowskiEngineBackend._C.CoordinateMapKey)
get_coordinate_field(coords_key_or_tensor_strides) → torch.Tensor
get_coordinates(coords_key_or_tensor_strides) → torch.Tensor
get_field_to_sparse_map(field_map_key: MinkowskiEngineBackend._C.CoordinateMapKey, sparse_map_key: MinkowskiEngineBackend._C.CoordinateMapKey)
get_kernel_map(in_key: MinkowskiEngineBackend._C.CoordinateMapKey, out_key: MinkowskiEngineBackend._C.CoordinateMapKey, stride=1, kernel_size=3, dilation=1, region_type=<RegionType.HYPER_CUBE: 0>, region_offset=None, is_transpose=False, is_pool=False) → dict

Alias of CoordinateManager.kernel_map. Will be deprecated in the next version.

get_unique_coordinate_map_key(tensor_stride: Union[int, list]) → MinkowskiEngineBackend._C.CoordinateMapKey

Returns a unique coordinate_map_key for a given tensor stride.

tensor_stride (list): a list of D elements that defines the tensor stride for the new order-D + 1 sparse tensor.

insert_and_map(coordinates: torch.Tensor, tensor_stride: Union[int, collections.abc.Sequence, numpy.ndarray] = 1, string_id: str = '') → Tuple[MinkowskiEngineBackend._C.CoordinateMapKey, Tuple[torch.IntTensor, torch.IntTensor]]

create a new coordinate map and returns (key, (map, inverse_map)).

coordinates: torch.Tensor (Int tensor. CUDA if coordinate_map_type == CoordinateMapType.GPU) that defines the coordinates.

tensor_stride (list): a list of D elements that defines the tensor stride for the new order-D + 1 sparse tensor.

Example:

>>> manager = CoordinateManager(D=1)
>>> coordinates = torch.IntTensor([[0, 0], [0, 0], [0, 1], [0, 2]])
>>> key, (unique_map, inverse_map) = manager.insert(coordinates, [1])
>>> print(key) # key is tensor_stride, string_id [1]:""
>>> torch.all(coordinates[unique_map] == manager.get_coordinates(key)) # True
>>> torch.all(coordinates == coordinates[unique_map][inverse_map]) # True
insert_field(coordinates: torch.Tensor, tensor_stride: collections.abc.Sequence, string_id: str = '') → Tuple[MinkowskiEngineBackend._C.CoordinateMapKey, Tuple[torch.IntTensor, torch.IntTensor]]

create a new coordinate map and returns

coordinates: torch.FloatTensor (CUDA if coordinate_map_type == CoordinateMapType.GPU) that defines the coordinates.

tensor_stride (list): a list of D elements that defines the tensor stride for the new order-D + 1 sparse tensor.

Example:

>>> manager = CoordinateManager(D=1)
>>> coordinates = torch.FloatTensor([[0, 0.1], [0, 2.3], [0, 1.2], [0, 2.4]])
>>> key, (unique_map, inverse_map) = manager.insert(coordinates, [1])
>>> print(key) # key is tensor_stride, string_id [1]:""
>>> torch.all(coordinates[unique_map] == manager.get_coordinates(key)) # True
>>> torch.all(coordinates == coordinates[unique_map][inverse_map]) # True
interpolation_map_weight(key: MinkowskiEngineBackend._C.CoordinateMapKey, samples: torch.Tensor)
kernel_map(in_key: MinkowskiEngineBackend._C.CoordinateMapKey, out_key: MinkowskiEngineBackend._C.CoordinateMapKey, stride=1, kernel_size=3, dilation=1, region_type=<RegionType.HYPER_CUBE: 0>, region_offset=None, is_transpose=False, is_pool=False) → dict

Get kernel in-out maps for the specified coords keys or tensor strides.

returns dict{kernel_index: in_out_tensor} where in_out_tensor[0] is the input row indices that correspond to in_out_tensor[1], which is the row indices for output.

number_of_unique_batch_indices() → int
origin() → MinkowskiEngineBackend._C.CoordinateMapKey
origin_field() → MinkowskiEngineBackend._C.CoordinateMapKey
origin_field_map(key: MinkowskiEngineBackend._C.CoordinateMapKey)
origin_map(key: MinkowskiEngineBackend._C.CoordinateMapKey)
size(coordinate_map_key: MinkowskiEngineBackend._C.CoordinateMapKey) → int
stride(coordinate_map_key: MinkowskiEngineBackend._C.CoordinateMapKey, stride: Union[int, collections.abc.Sequence, numpy.ndarray, torch.Tensor], string_id: str = '') → MinkowskiEngineBackend._C.CoordinateMapKey

Generate a new coordinate map and returns the key.

coordinate_map_key (MinkowskiEngine.CoordinateMapKey): input map to generate the strided map from.

stride: stride size.

stride_map(in_key: MinkowskiEngineBackend._C.CoordinateMapKey, stride_key: MinkowskiEngineBackend._C.CoordinateMapKey)
union_map(in_keys: list, out_key)

GPU Memory Allocator

class MinkowskiEngine.GPUMemoryAllocatorType

Members:

PYTORCH

CUDA

property name
MinkowskiEngine.set_gpu_allocator(backend: MinkowskiEngineBackend._C.GPUMemoryAllocatorType)

Set the GPU memory allocator

By default, the Minkowski Engine will use the pytorch memory pool to allocate temporary GPU memory slots. This allows the pytorch backend to effectively reuse the memory pool shared between the pytorch backend and the Minkowski Engine. It tends to allow training with larger batch sizes given a fixed GPU memory. However, pytorch memory manager tend to be slower than allocating GPU directly using raw CUDA calls.

By default, the Minkowski Engine uses ME.GPUMemoryAllocatorType.PYTORCH for memory management.

Example:

>>> import MinkowskiEngine as ME
>>> # Set the GPU memory manager backend to raw CUDA calls
>>> ME.set_gpu_allocator(ME.GPUMemoryAllocatorType.CUDA)
>>> # Set the GPU memory manager backend to the pytorch c10 allocator
>>> ME.set_gpu_allocator(ME.GPUMemoryAllocatorType.PYTORCH)