MCPcopy Create free account
hub / github.com/NVIDIA/MinkowskiEngine / SparseTensor

Class SparseTensor

MinkowskiEngine/MinkowskiSparseTensor.py:48–737  ·  view source on GitHub ↗

r"""A sparse tensor class. Can be accessed via :attr:`MinkowskiEngine.SparseTensor`. The :attr:`SparseTensor` class is the basic tensor in MinkowskiEngine. For the definition of a sparse tensor, please visit `the terminology page <https://nvidia.github.io/MinkowskiEngine/terminology

Source from the content-addressed store, hash-verified

46
47
48class SparseTensor(Tensor):
49 r"""A sparse tensor class. Can be accessed via
50 :attr:`MinkowskiEngine.SparseTensor`.
51
52 The :attr:`SparseTensor` class is the basic tensor in MinkowskiEngine. For
53 the definition of a sparse tensor, please visit `the terminology page
54 <https://nvidia.github.io/MinkowskiEngine/terminology.html#sparse-tensor>`_.
55 We use the COOrdinate (COO) format to save a sparse tensor `[1]
56 <http://groups.csail.mit.edu/commit/papers/2016/parker-thesis.pdf>`_. This
57 representation is simply a concatenation of coordinates in a matrix
58 :math:`C` and associated features :math:`F`.
59
60 .. math::
61
62 \mathbf{C} = \begin{bmatrix}
63 b_1 & x_1^1 & x_1^2 & \cdots & x_1^D \\
64 \vdots & \vdots & \vdots & \ddots & \vdots \\
65 b_N & x_N^1 & x_N^2 & \cdots & x_N^D
66 \end{bmatrix}, \; \mathbf{F} = \begin{bmatrix}
67 \mathbf{f}_1^T\\
68 \vdots\\
69 \mathbf{f}_N^T
70 \end{bmatrix}
71
72 where :math:`\mathbf{x}_i \in \mathcal{Z}^D` is a :math:`D`-dimensional
73 coordinate and :math:`b_i \in \mathcal{Z}_+` denotes the corresponding
74 batch index. :math:`N` is the number of non-zero elements in the sparse
75 tensor, each with the coordinate :math:`(b_i, x_i^1, x_i^1, \cdots,
76 x_i^D)`, and the associated feature :math:`\mathbf{f}_i`. Internally, we
77 handle the batch index as an additional spatial dimension.
78
79 Example::
80
81 >>> coords, feats = ME.utils.sparse_collate([coords_batch0, coords_batch1], [feats_batch0, feats_batch1])
82 >>> A = ME.SparseTensor(features=feats, coordinates=coords)
83 >>> B = ME.SparseTensor(features=feats, coordinate_map_key=A.coordiante_map_key, coordinate_manager=A.coordinate_manager)
84 >>> C = ME.SparseTensor(features=feats, coordinates=coords, quantization_mode=ME.SparseTensorQuantizationMode.UNWEIGHTED_AVERAGE)
85 >>> D = ME.SparseTensor(features=feats, coordinates=coords, quantization_mode=ME.SparseTensorQuantizationMode.RANDOM_SUBSAMPLE)
86 >>> E = ME.SparseTensor(features=feats, coordinates=coords, tensor_stride=2)
87
88 .. warning::
89
90 To use the GPU-backend for coordinate management, the
91 :attr:`coordinates` must be a torch tensor on GPU. Applying `to(device)`
92 after :attr:`MinkowskiEngine.SparseTensor` initialization with a CPU
93 `coordinates` will waste time and computation on creating an unnecessary
94 CPU CoordinateMap since the GPU CoordinateMap will be created from
95 scratch as well.
96
97 .. warning::
98
99 Before MinkowskiEngine version 0.4, we put the batch indices on the last
100 column. Thus, direct manipulation of coordinates will be incompatible
101 with the latest versions. Instead, please use
102 :attr:`MinkowskiEngine.utils.batched_coordinates` or
103 :attr:`MinkowskiEngine.utils.sparse_collate` to create batched
104 coordinates.
105

Callers 15

forwardMethod · 0.90
sparseMethod · 0.90
splatMethod · 0.90
forwardMethod · 0.90
_tuple_operatorFunction · 0.90
to_sparseFunction · 0.90
to_sparse_allFunction · 0.90
forwardMethod · 0.90
forwardMethod · 0.90
forwardMethod · 0.90
forwardMethod · 0.90
forwardMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_gpuMethod · 0.72
test_emptyMethod · 0.72
test_tensor_strideMethod · 0.72
test_force_creationMethod · 0.72
test_deviceMethod · 0.72
test_device_uniqueMethod · 0.72
test_device2Method · 0.72
test_quantizationMethod · 0.72
test_quantization_gpuMethod · 0.72
test_extractionMethod · 0.72
test_decompositionMethod · 0.72