open3d.ml.torch.classes.RaggedTensor¶
-
class
open3d.ml.torch.classes.
RaggedTensor
(r_tensor, internal=False)¶ RaggedTensor.
A RaggedTensor is a tensor with ragged dimension, whose slice may have different lengths. We define a container for ragged tensor to support operations involving batches whose elements may have different shape.
-
__init__
(r_tensor, internal=False)¶ Creates a RaggedTensor with specified torch script object.
This constructor is private – please use one of the following ops to build RaggedTensor’s:
ml3d.classes.RaggedTensor.from_row_splits
- Raises
ValueError – If internal = False. This method is intented for internal use.
-
clone
()¶ Returns a clone of object.
-
classmethod
from_row_splits
(values, row_splits, validate=True, copy=True)¶ Creates a RaggedTensor with rows partitioned by row_splits.
The returned RaggedTensor corresponds with the python list defined by:
result = [values[row_splits[i]:row_splits[i + 1]] for i in range(len(row_splits) - 1)]
- Parameters
values – A Tensor with shape [N, None].
row_splits – A 1-D integer tensor with shape [N+1]. Must not be empty, and must be stored in ascending order. row_splits[0] must be zero and row_splits[-1] must be N.
validate – Verify that row_splits are compatible with values. Set it to False to avoid expensive checks.
copy – Whether to do a deep copy for values and row_splits. Set it to False to save memory for short term usage.
- Returns
A RaggedTensor container.
Example:
>>> print(ml3d.classes.RaggedTensor.from_row_splits( ... values=[3, 1, 4, 1, 5, 9, 2, 6], ... row_splits=[0, 4, 4, 7, 8, 8])) <RaggedTensor [[3, 1, 4, 1], [], [5, 9, 2], [6], []]>
-
to_list
()¶ Returns a list of tensors
-
property
device
¶ The device of values in this ragged tensor.
-
property
dtype
¶ The DType of values in this ragged tensor.
-
property
requires_grad
¶ Read/writeble requires_grad for values.
-
property
row_splits
¶ The row-split indices for this ragged tensor’s values.
-
property
shape
¶ The statically known shape of this ragged tensor.
-
property
values
¶ The concatenated rows for this ragged tensor.
-