|
Open3D (C++ API)
0.11.0
|
#include <Tensor.h>
Public Member Functions | |
| Tensor () | |
| Tensor (const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0")) | |
| Constructor for creating a contiguous Tensor. More... | |
| template<typename T > | |
| Tensor (const std::vector< T > &init_vals, const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0")) | |
| Constructor for creating a contiguous Tensor with initial values. More... | |
| template<typename T > | |
| Tensor (const T *init_vals, const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0")) | |
| Constructor from raw host buffer. The memory will be copied. More... | |
| Tensor (const SizeVector &shape, const SizeVector &strides, void *data_ptr, Dtype dtype, const std::shared_ptr< Blob > &blob) | |
| Tensor (const Tensor &other)=default | |
| Tensor (Tensor &&other)=default | |
| Tensor & | operator= (const Tensor &other) & |
| Tensor & | operator= (Tensor &&other) & |
| Tensor & | operator= (const Tensor &other) && |
Tensor assignment rvalue = lvalue, e.g. tensor_a[0] = tensor_b More... | |
| Tensor & | operator= (Tensor &&other) && |
Tensor assignment rvalue = rvalue, e.g. tensor_a[0] = tensor_b[0] More... | |
| template<typename T > | |
| Tensor & | operator= (const T &v) && |
| template<typename Object > | |
| Tensor & | AssignObject (const Object &v) && |
| template<typename Scalar > | |
| void | Fill (Scalar v) |
| Fill the whole Tensor with a scalar value, the scalar will be casted to the Tensor's dtype. More... | |
| template<typename Object > | |
| void | FillObject (const Object &v) |
| Tensor | GetItem (const TensorKey &tk) const |
| Tensor | GetItem (const std::vector< TensorKey > &tks) const |
| Tensor | SetItem (const Tensor &value) |
Set all items. Equivalent to tensor[:] = value in Python. More... | |
| Tensor | SetItem (const TensorKey &tk, const Tensor &value) |
| Tensor | SetItem (const std::vector< TensorKey > &tks, const Tensor &value) |
| void | Assign (const Tensor &other) |
| Assign (copy) values from another Tensor, shape, dtype, device may change. More... | |
| Tensor | Broadcast (const SizeVector &dst_shape) const |
| Broadcast Tensor to a new broadcastable shape. More... | |
| Tensor | Expand (const SizeVector &dst_shape) const |
| Tensor | Reshape (const SizeVector &dst_shape) const |
| Tensor | View (const SizeVector &dst_shape) const |
| Tensor | Copy (const Device &device) const |
| Tensor | Copy () const |
| Copy Tensor to the same device. More... | |
| void | CopyFrom (const Tensor &other) |
| Copy Tensor values to current tensor for source tensor. More... | |
| void | ShallowCopyFrom (const Tensor &other) |
| Shallow copy a tensor, returning a tensor sharing the same memory. More... | |
| Tensor | To (Dtype dtype, bool copy=false) const |
| std::string | ToString (bool with_suffix=true, const std::string &indent="") const |
| Tensor | operator[] (int64_t i) const |
| Extract the i-th Tensor along the first axis, returning a new view. More... | |
| Tensor | IndexExtract (int64_t dim, int64_t idx) const |
| Tensor | Slice (int64_t dim, int64_t start, int64_t stop, int64_t step=1) const |
| Tensor | AsRvalue () const |
| Tensor | IndexGet (const std::vector< Tensor > &index_tensors) const |
| Advanced indexing getter. More... | |
| void | IndexSet (const std::vector< Tensor > &index_tensors, const Tensor &src_tensor) |
| Advanced indexing getter. More... | |
| Tensor | Permute (const SizeVector &dims) const |
| Permute (dimension shuffle) the Tensor, returns a view. More... | |
| Tensor | AsStrided (const SizeVector &new_shape, const SizeVector &new_strides) const |
| Create a Tensor view of specified shape and strides. The underlying buffer and data_ptr offsets remain the same. More... | |
| Tensor | Transpose (int64_t dim0, int64_t dim1) const |
Transpose a Tensor by swapping dimension dim0 and dim1. More... | |
| Tensor | T () const |
| Expects input to be <= 2-D Tensor by swapping dimension 0 and 1. More... | |
| template<typename T > | |
| T | Item () const |
| Tensor | Add (const Tensor &value) const |
| Adds a tensor and returns the resulting tensor. More... | |
| template<typename T > | |
| Tensor | Add (T scalar_value) const |
| Tensor | operator+ (const Tensor &value) const |
| template<typename T > | |
| Tensor | operator+ (T scalar_value) const |
| Tensor | Add_ (const Tensor &value) |
| template<typename T > | |
| Tensor | Add_ (T scalar_value) |
| Tensor | operator+= (const Tensor &value) |
| template<typename T > | |
| Tensor | operator+= (T scalar_value) |
| Tensor | Sub (const Tensor &value) const |
| Substracts a tensor and returns the resulting tensor. More... | |
| template<typename T > | |
| Tensor | Sub (T scalar_value) const |
| Tensor | operator- (const Tensor &value) const |
| template<typename T > | |
| Tensor | operator- (T scalar_value) const |
| Tensor | Sub_ (const Tensor &value) |
| template<typename T > | |
| Tensor | Sub_ (T scalar_value) |
| Tensor | operator-= (const Tensor &value) |
| template<typename T > | |
| Tensor | operator-= (T scalar_value) |
| Tensor | Mul (const Tensor &value) const |
| Multiplies a tensor and returns the resulting tensor. More... | |
| template<typename T > | |
| Tensor | Mul (T scalar_value) const |
| Tensor | operator* (const Tensor &value) const |
| template<typename T > | |
| Tensor | operator* (T scalar_value) const |
| Tensor | Mul_ (const Tensor &value) |
| template<typename T > | |
| Tensor | Mul_ (T scalar_value) |
| Tensor | operator*= (const Tensor &value) |
| template<typename T > | |
| Tensor | operator*= (T scalar_value) |
| Tensor | Div (const Tensor &value) const |
| Divides a tensor and returns the resulting tensor. More... | |
| template<typename T > | |
| Tensor | Div (T scalar_value) const |
| Tensor | operator/ (const Tensor &value) const |
| template<typename T > | |
| Tensor | operator/ (T scalar_value) const |
| Tensor | Div_ (const Tensor &value) |
| template<typename T > | |
| Tensor | Div_ (T scalar_value) |
| Tensor | operator/= (const Tensor &value) |
| template<typename T > | |
| Tensor | operator/= (T scalar_value) |
| Tensor | Sum (const SizeVector &dims, bool keepdim=false) const |
| Tensor | Mean (const SizeVector &dims, bool keepdim=false) const |
| Tensor | Prod (const SizeVector &dims, bool keepdim=false) const |
| Tensor | Min (const SizeVector &dims, bool keepdim=false) const |
| Tensor | Max (const SizeVector &dims, bool keepdim=false) const |
| Tensor | ArgMin (const SizeVector &dims) const |
| Tensor | ArgMax (const SizeVector &dims) const |
| Tensor | Sqrt () const |
| Element-wise square root of a tensor, returns a new tensor. More... | |
| Tensor | Sqrt_ () |
| Element-wise square root of a tensor, in-place. More... | |
| Tensor | Sin () const |
| Element-wise sine of a tensor, returning a new tensor. More... | |
| Tensor | Sin_ () |
| Element-wise sine of a tensor, in-place. More... | |
| Tensor | Cos () const |
| Element-wise cosine of a tensor, returning a new tensor. More... | |
| Tensor | Cos_ () |
| Element-wise cosine of a tensor, in-place. More... | |
| Tensor | Neg () const |
| Element-wise negation of a tensor, returning a new tensor. More... | |
| Tensor | Neg_ () |
| Element-wise negation of a tensor, in-place. More... | |
| Tensor | Exp () const |
| Element-wise exponential of a tensor, returning a new tensor. More... | |
| Tensor | Exp_ () |
| Element-wise base-e exponential of a tensor, in-place. More... | |
| Tensor | Abs () const |
| Element-wise absolute value of a tensor, returning a new tensor. More... | |
| Tensor | Abs_ () |
| Element-wise absolute value of a tensor, in-place. More... | |
| Tensor | LogicalNot () const |
| Tensor | LogicalNot_ () |
| Tensor | LogicalAnd (const Tensor &value) const |
| Tensor | operator && (const Tensor &value) const |
| template<typename T > | |
| Tensor | LogicalAnd (T scalar_value) const |
| Tensor | LogicalAnd_ (const Tensor &value) |
| template<typename T > | |
| Tensor | LogicalAnd_ (T scalar_value) |
| Tensor | LogicalOr (const Tensor &value) const |
| Tensor | operator|| (const Tensor &value) const |
| template<typename T > | |
| Tensor | LogicalOr (T scalar_value) const |
| Tensor | LogicalOr_ (const Tensor &value) |
| template<typename T > | |
| Tensor | LogicalOr_ (T scalar_value) |
| Tensor | LogicalXor (const Tensor &value) const |
| template<typename T > | |
| Tensor | LogicalXor (T scalar_value) const |
| Tensor | LogicalXor_ (const Tensor &value) |
| template<typename T > | |
| Tensor | LogicalXor_ (T scalar_value) |
| Tensor | Gt (const Tensor &value) const |
| Element-wise greater-than of tensors, returning a new boolean tensor. More... | |
| Tensor | operator> (const Tensor &value) const |
| template<typename T > | |
| Tensor | Gt (T scalar_value) const |
| Tensor | Gt_ (const Tensor &value) |
| template<typename T > | |
| Tensor | Gt_ (T scalar_value) |
| Tensor | Lt (const Tensor &value) const |
| Element-wise less-than of tensors, returning a new boolean tensor. More... | |
| Tensor | operator< (const Tensor &value) const |
| template<typename T > | |
| Tensor | Lt (T scalar_value) const |
| Tensor | Lt_ (const Tensor &value) |
| template<typename T > | |
| Tensor | Lt_ (T scalar_value) |
| Tensor | Ge (const Tensor &value) const |
| Tensor | operator>= (const Tensor &value) const |
| template<typename T > | |
| Tensor | Ge (T scalar_value) const |
| Tensor | Ge_ (const Tensor &value) |
| template<typename T > | |
| Tensor | Ge_ (T scalar_value) |
| Tensor | Le (const Tensor &value) const |
| Tensor | operator<= (const Tensor &value) const |
| template<typename T > | |
| Tensor | Le (T scalar_value) const |
| Tensor | Le_ (const Tensor &value) |
| template<typename T > | |
| Tensor | Le_ (T scalar_value) |
| Tensor | Eq (const Tensor &value) const |
| Element-wise equals-to of tensors, returning a new boolean tensor. More... | |
| Tensor | operator== (const Tensor &value) const |
| template<typename T > | |
| Tensor | Eq (T scalar_value) const |
| Tensor | Eq_ (const Tensor &value) |
| template<typename T > | |
| Tensor | Eq_ (T scalar_value) |
| Tensor | Ne (const Tensor &value) const |
| Element-wise not-equals-to of tensors, returning a new boolean tensor. More... | |
| Tensor | operator!= (const Tensor &value) const |
| template<typename T > | |
| Tensor | Ne (T scalar_value) const |
| Tensor | Ne_ (const Tensor &value) |
| template<typename T > | |
| Tensor | Ne_ (T scalar_value) |
| std::vector< Tensor > | NonZeroNumpy () const |
| Tensor | NonZero () const |
| bool | All () const |
| bool | Any () const |
| bool | AllClose (const Tensor &other, double rtol=1e-5, double atol=1e-8) const |
| Tensor | IsClose (const Tensor &other, double rtol=1e-5, double atol=1e-8) const |
| bool | IsSame (const Tensor &other) const |
| template<typename T > | |
| std::vector< T > | ToFlatVector () const |
| Retrive all values as an std::vector, for debugging and testing. More... | |
| bool | IsContiguous () const |
| Tensor | Contiguous () const |
| Tensor | Matmul (const Tensor &rhs) const |
| Tensor | Solve (const Tensor &rhs) const |
| Tensor | LeastSquares (const Tensor &rhs) const |
| Tensor | Inverse () const |
| std::tuple< Tensor, Tensor, Tensor > | SVD () const |
| SizeVector | GetShape () const |
| const SizeVector & | GetShapeRef () const |
| int64_t | GetShape (int64_t dim) const |
| SizeVector | GetStrides () const |
| const SizeVector & | GetStridesRef () const |
| int64_t | GetStride (int64_t dim) const |
| void * | GetDataPtr () |
| const void * | GetDataPtr () const |
| Dtype | GetDtype () const |
| Device | GetDevice () const |
| std::shared_ptr< Blob > | GetBlob () const |
| int64_t | NumElements () const |
| int64_t | NumDims () const |
| template<typename T > | |
| void | AssertTemplateDtype () const |
| DLManagedTensor * | ToDLPack () const |
| Convert the Tensor to DLManagedTensor. More... | |
| void | AssertShape (const SizeVector &expected_shape) const |
| Assert that the Tensor has the specified shape. More... | |
| template<> | |
| Tensor (const std::vector< bool > &init_vals, const SizeVector &shape, Dtype dtype, const Device &device) | |
| template<> | |
| std::vector< bool > | ToFlatVector () const |
| template<> | |
| bool | Item () const |
Static Public Member Functions | |
| static Tensor | Empty (const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0")) |
| Create a tensor with uninitilized values. More... | |
| static Tensor | EmptyLike (const Tensor &other) |
| template<typename T > | |
| static Tensor | Full (const SizeVector &shape, T fill_value, Dtype dtype, const Device &device=Device("CPU:0")) |
| Create a tensor fill with specified value. More... | |
| static Tensor | Zeros (const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0")) |
| Create a tensor fill with zeros. More... | |
| static Tensor | Ones (const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0")) |
| Create a tensor fill with ones. More... | |
| static Tensor | Eye (int64_t n, Dtype dtype, const Device &device) |
| Create a identity matrix of size n x n. More... | |
| static Tensor | Diag (const Tensor &input) |
| Create a square matrix with specified diagonal elements in input. More... | |
| static SizeVector | DefaultStrides (const SizeVector &shape) |
| static std::pair< bool, SizeVector > | ComputeNewStrides (const SizeVector &old_shape, const SizeVector &old_strides, const SizeVector &new_shape) |
| static Tensor | FromDLPack (const DLManagedTensor *dlmt) |
| Convert DLManagedTensor to Tensor. More... | |
Protected Member Functions | |
| std::string | ScalarPtrToString (const void *ptr) const |
Protected Attributes | |
| SizeVector | shape_ = {0} |
| SizeVector | strides_ = {1} |
| void * | data_ptr_ = nullptr |
| Dtype | dtype_ = Dtype::Undefined |
| Data type. More... | |
| std::shared_ptr< Blob > | blob_ = nullptr |
| Underlying memory buffer for Tensor. More... | |
A Tensor is a "view" of a data Blob with shape, stride, data_ptr. Tensor can also be used to perform numerical operations.
|
inline |
|
inline |
Constructor for creating a contiguous Tensor.
|
inline |
Constructor for creating a contiguous Tensor with initial values.
|
inline |
Constructor from raw host buffer. The memory will be copied.
|
inline |
|
default |
|
default |
|
inline |
| Tensor open3d::core::Tensor::Abs | ( | ) | const |
Element-wise absolute value of a tensor, returning a new tensor.
| Tensor open3d::core::Tensor::Abs_ | ( | ) |
Element-wise absolute value of a tensor, in-place.
Adds a tensor and returns the resulting tensor.
Inplace version of Tensor::Add. Adds a tensor to the current tensor and returns the current tensor.
| bool open3d::core::Tensor::All | ( | ) | const |
Returns true if all elements in the tensor are true. Only works for boolean tensors. This function does not take reduction dimensions, and the reduction is apply to all dimensions.
| bool open3d::core::Tensor::AllClose | ( | const Tensor & | other, |
| double | rtol = 1e-5, |
||
| double | atol = 1e-8 |
||
| ) | const |
Returns true if the two tensors are element-wise equal within a tolerance.
The equation is not symmetrial, i.e. a.AllClose(b) might not be the same as b.AllClose(a). Also see Numpy's documentation: https://numpy.org/doc/stable/reference/generated/numpy.allclose.html.
TODO: support nan
| other | The other tensor to compare with. |
| rtol | Relative tolerance. |
| atol | Absolute tolerance. |
| bool open3d::core::Tensor::Any | ( | ) | const |
Returns true if any elements in the tensor are true. Only works for boolean tensors. This function does not take reduction dimensions, and the reduction is apply to all dimensions.
| Tensor open3d::core::Tensor::ArgMax | ( | const SizeVector & | dims | ) | const |
Returns maximum index of the tensor along the given dim. The returned tensor has dtype int64_t, and has the same shape as original tensor except that the reduced dimension is removed.
| dims | dims can only contain a single dimension or all dimensions. If dims contains a single dimension, the index is along the specified dimension. If dims contains all dimensions, the index is into the flattend tensor. |
| Tensor open3d::core::Tensor::ArgMin | ( | const SizeVector & | dims | ) | const |
Returns minimum index of the tensor along the given dim. The returned tensor has dtype int64_t, and has the same shape as original tensor except that the reduced dimension is removed.
| dims | dims can only contain a single dimension or all dimensions. If dims contains a single dimension, the index is along the specified dimension. If dims contains all dimensions, the index is into the flattend tensor. |
|
inline |
Convert to rvalue such that the Tensor can be assigned. E.g. in numpy
| void open3d::core::Tensor::AssertShape | ( | const SizeVector & | expected_shape | ) | const |
Assert that the Tensor has the specified shape.
|
inline |
| void open3d::core::Tensor::Assign | ( | const Tensor & | other | ) |
|
inline |
Assign an object to a tensor. The tensor being assigned to must be a scalr tensor of shape {}. The element byte size of the tensor must be the same as the size of the object. The object must be a POD.
| Tensor open3d::core::Tensor::AsStrided | ( | const SizeVector & | new_shape, |
| const SizeVector & | new_strides | ||
| ) | const |
Create a Tensor view of specified shape and strides. The underlying buffer and data_ptr offsets remain the same.
| Tensor open3d::core::Tensor::Broadcast | ( | const SizeVector & | dst_shape | ) | const |
Broadcast Tensor to a new broadcastable shape.
|
static |
oldshape into chunks of dimensions, where the dimensions are ``contiguous'' in each chunk, i.e., oldstride[i] = oldshape[i+1] * oldstride[i+1]newshape must be able to be separated into same number of chunks as oldshape was separated into, where each chunk of newshape has matching ``numel'', i.e., number of subspaces, as the corresponding chunk of oldshape. Ref: aten/src/ATen/TensorUtils.cpp | Tensor open3d::core::Tensor::Contiguous | ( | ) | const |
Returns a contiguous Tensor containing the same data in the same device. If self tensor is already contiguous, the same underlying memory will be used.
| void open3d::core::Tensor::CopyFrom | ( | const Tensor & | other | ) |
Copy Tensor values to current tensor for source tensor.
| Tensor open3d::core::Tensor::Cos | ( | ) | const |
Element-wise cosine of a tensor, returning a new tensor.
| Tensor open3d::core::Tensor::Cos_ | ( | ) |
Element-wise cosine of a tensor, in-place.
|
static |
Create a square matrix with specified diagonal elements in input.
Divides a tensor and returns the resulting tensor.
Inplace version of Tensor::Div. Divides a tensor to the current tensor and returns the current tensor.
|
static |
Create a tensor with uninitilized values.
Create a tensor with uninitilized values with the same dtype and device as the other tensor.
Element-wise equals-to of tensors, returning a new boolean tensor.
Element-wise equals-to of tensors, in-place. This operation won't change the tensor's dtype.
| Tensor open3d::core::Tensor::Exp | ( | ) | const |
Element-wise exponential of a tensor, returning a new tensor.
| Tensor open3d::core::Tensor::Exp_ | ( | ) |
Element-wise base-e exponential of a tensor, in-place.
| Tensor open3d::core::Tensor::Expand | ( | const SizeVector & | dst_shape | ) | const |
Expand Tensor to a new broadcastable shape, returning a new view.
Tensors can be expanded to broadcastable shape by setting dimension of size 1 to have stride 0, without allocating new memory.
Create a identity matrix of size n x n.
|
inline |
|
inline |
|
static |
Convert DLManagedTensor to Tensor.
|
inlinestatic |
Create a tensor fill with specified value.
Element-wise greater-than-or-equals-to of tensors, returning a new boolean tensor.
Element-wise greater-than-or-equals-to of tensors, in-place. This operation won't change the tensor's dtype.
|
inline |
|
inline |
|
inline |
| Device open3d::core::Tensor::GetDevice | ( | ) | const |
|
inline |
Pythonic getitem for tensor.
Returns a view of the original tensor, if TensorKey is TensorKeyMode::Index or TensorKeyMode::Slice. Returns a copy if the TensorKey contains TensorKeyMode::IndexTensor (advanced indexing).
For example, in numpy:
The equivalent Open3D C++ calls:
Pythonic getitem for tensor.
Returns a view of the original tensor, if TensorKey only contains TensorKeyMode::Index or TensorKeyMode::Slice. Returns a copy if the TensorKey contains IndexTensor (advanced indexing).
For example, in numpy:
The equivalent Open3D C++ calls:
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Element-wise greater-than of tensors, returning a new boolean tensor.
Element-wise greater-than of tensors, in-place. This operation won't change the tensor's dtype.
| Tensor open3d::core::Tensor::IndexExtract | ( | int64_t | dim, |
| int64_t | idx | ||
| ) | const |
Extract the idx -th sub-tensor in dimension dim. After IndexExtract, the dimension dim will be removed.
Advanced indexing getter.
We use the Numpy advanced indexing symnatics, see: https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html
| void open3d::core::Tensor::IndexSet | ( | const std::vector< Tensor > & | index_tensors, |
| const Tensor & | src_tensor | ||
| ) |
Advanced indexing getter.
We use the Numpy advanced indexing symnatics, see: https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html
Note: Only support 1D index tensors. Note: Only support advanced indices are all next to each other.
| Tensor open3d::core::Tensor::Inverse | ( | ) | const |
Computes the matrix inversion of the square matrix *this with LU factorization and returns the result.
| Tensor open3d::core::Tensor::IsClose | ( | const Tensor & | other, |
| double | rtol = 1e-5, |
||
| double | atol = 1e-8 |
||
| ) | const |
Element-wise version of Tensor::AllClose.
The equation is not symmetrial, i.e. a.AllClose(b) might not be the same as b.AllClose(a). Also see Numpy's documentation: https://numpy.org/doc/stable/reference/generated/numpy.allclose.html.
TODO: support nan
| other | The other tensor to compare with. |
| rtol | Relative tolerance. |
| atol | Absolute tolerance. |
|
inline |
Returns True if the underlying memory buffer is contiguous. A contiguous Tensor's data_ptr_ does not need to point to the beginning of blob_.
| bool open3d::core::Tensor::IsSame | ( | const Tensor & | other | ) | const |
Returns true iff the tensor is the other tensor. This means that, the two tensors have the same underlying memory, device, dtype, shape, strides and etc.
|
inline |
|
inline |
Element-wise less-than-or-equals-to of tensors, returning a new boolean tensor.
Element-wise less-than-or-equals-to of tensors, in-place. This operation won't change the tensor's dtype.
Solves the linear system AX = B with QR decomposition and returns X. A is a (m, n) matrix with m >= n.
Element-wise logical and of a tensor, returning a new boolean tensor.
If the tensor is not boolean, zero will be treated as False, while non-zero values will be treated as True.
Element-wise logical and of tensors, in-place. This operation won't change the tensor's dtype.
If the tensor is not boolean, 0 will be treated as False, while non-zero will be treated as True. The tensor will be filled with 0 or 1 casted to the tensor's dtype.
| Tensor open3d::core::Tensor::LogicalNot | ( | ) | const |
Element-wise logical not of a tensor, returning a new boolean tensor.
If the tensor is not boolean, 0 will be treated as False, while non-zero will be treated as True.
| Tensor open3d::core::Tensor::LogicalNot_ | ( | ) |
Element-wise logical not of a tensor, in-place. This operation won't change the tensor's dtype.
If the tensor is not boolean, 0 will be treated as False, while non-zero will be treated as True. The tensor will be filled with 0 or 1 casted to the tensor's dtype.
Element-wise logical or of tensors, returning a new boolean tensor.
If the tensor is not boolean, zero will be treated as False, while non-zero values will be treated as True.
Element-wise logical or of tensors, in-place. This operation won't change the tensor's dtype.
If the tensor is not boolean, 0 will be treated as False, while non-zero will be treated as True. The tensor will be filled with 0 or 1 casted to the tensor's dtype.
Element-wise logical exclusive-or of tensors, returning a new boolean tensor.
If the tensor is not boolean, zero will be treated as False, while non-zero values will be treated as True.
Element-wise logical exclusive-or of tensors, in-place. This operation won't change the tensor's dtype.
If the tensor is not boolean, zero will be treated as False, while non-zero values will be treated as True. The tensor will be filled with 0 or 1 casted to the tensor's dtype.
Element-wise less-than of tensors, returning a new boolean tensor.
Element-wise less-than of tensors, in-place. This operation won't change the tensor's dtype.
Computes matrix multiplication with *this and rhs and returns the result.
| Tensor open3d::core::Tensor::Max | ( | const SizeVector & | dims, |
| bool | keepdim = false |
||
| ) | const |
Returns max of the tensor along the given dims.
| dims | A list of dimensions to be reduced. |
| keepdim | If true, the reduced dims will be retained as size 1. |
| Tensor open3d::core::Tensor::Mean | ( | const SizeVector & | dims, |
| bool | keepdim = false |
||
| ) | const |
Returns the mean of the tensor along the given dims.
| dims | A list of dimensions to be reduced. |
| keepdim | If true, the reduced dims will be retained as size 1. |
| Tensor open3d::core::Tensor::Min | ( | const SizeVector & | dims, |
| bool | keepdim = false |
||
| ) | const |
Returns min of the tensor along the given dims.
| dims | A list of dimensions to be reduced. |
| keepdim | If true, the reduced dims will be retained as size 1. |
Multiplies a tensor and returns the resulting tensor.
Inplace version of Tensor::Mul. Multiplies a tensor to the current tensor and returns the current tensor.
Element-wise not-equals-to of tensors, returning a new boolean tensor.
Element-wise equals-to of tensors, in-place. This operation won't change the tensor's dtype.
| Tensor open3d::core::Tensor::Neg | ( | ) | const |
Element-wise negation of a tensor, returning a new tensor.
| Tensor open3d::core::Tensor::Neg_ | ( | ) |
Element-wise negation of a tensor, in-place.
| Tensor open3d::core::Tensor::NonZero | ( | ) | const |
Find the indices of the elements that are non-zero. Returns an int64 tensor of shape {num_dims, num_non_zeros}, where the i-th row contains the indices of the non-zero elements in i-th dimension of the original tensor.
| std::vector< Tensor > open3d::core::Tensor::NonZeroNumpy | ( | ) | const |
Find the indices of the elements that are non-zero. Returns a vector of int64 Tensors, each containing the indices of the non-zero elements in each dimension.
|
inline |
|
inline |
|
static |
Create a tensor fill with ones.
Tensor assignment lvalue = lvalue, e.g. tensor_a = tensor_b. This results in a "shallow" copy.
Tensor assignment lvalue = rvalue, e.g. tensor_a = tensor_b[0]. This results in a "shallow" copy.
| Tensor open3d::core::Tensor::operator[] | ( | int64_t | i | ) | const |
Extract the i-th Tensor along the first axis, returning a new view.
| Tensor open3d::core::Tensor::Permute | ( | const SizeVector & | dims | ) | const |
| Tensor open3d::core::Tensor::Prod | ( | const SizeVector & | dims, |
| bool | keepdim = false |
||
| ) | const |
Returns the product of the tensor along the given dims.
| dims | A list of dimensions to be reduced. |
| keepdim | If true, the reduced dims will be retained as size 1. |
| Tensor open3d::core::Tensor::Reshape | ( | const SizeVector & | dst_shape | ) | const |
Returns a tensor with the same data and number of elements as input, but with the specified shape. When possible, the returned tensor will be a view of input. Otherwise, it will be a copy.
Contiguous inputs and inputs with compatible strides can be reshaped without copying, but you should not depend on the copying vs. viewing behavior.
Ref: https://pytorch.org/docs/stable/tensors.html aten/src/ATen/native/TensorShape.cpp aten/src/ATen/TensorUtils.cpp
|
protected |
Set all items. Equivalent to tensor[:] = value in Python.
Pythonic setitem for tensor.
For example, in numpy:
The equivalent Open3D C++ calls:
Pythonic setitem for tensor.
For example, in numpy:
The equivalent Open3D C++ calls:
| void open3d::core::Tensor::ShallowCopyFrom | ( | const Tensor & | other | ) |
Shallow copy a tensor, returning a tensor sharing the same memory.
| Tensor open3d::core::Tensor::Sin | ( | ) | const |
Element-wise sine of a tensor, returning a new tensor.
| Tensor open3d::core::Tensor::Sin_ | ( | ) |
Element-wise sine of a tensor, in-place.
| Tensor open3d::core::Tensor::Slice | ( | int64_t | dim, |
| int64_t | start, | ||
| int64_t | stop, | ||
| int64_t | step = 1 |
||
| ) | const |
Slice Tensor.
| dim | The dimension to slice. |
| start | The start index (inclusive). |
| stop | The end index (exclusive). |
| step | Pick one eleemnt for every step elements. |
Solves the linear system AX = B with QR decomposition and returns X. A must be a square matrix.
| Tensor open3d::core::Tensor::Sqrt | ( | ) | const |
Element-wise square root of a tensor, returns a new tensor.
| Tensor open3d::core::Tensor::Sqrt_ | ( | ) |
Element-wise square root of a tensor, in-place.
Substracts a tensor and returns the resulting tensor.
Inplace version of Tensor::Sub. Substracts a tensor to the current tensor and returns the current tensor.
| Tensor open3d::core::Tensor::Sum | ( | const SizeVector & | dims, |
| bool | keepdim = false |
||
| ) | const |
Returns the sum of the tensor along the given dims.
| dims | A list of dimensions to be reduced. |
| keepdim | If true, the reduced dims will be retained as size 1. |
Computes the matrix SVD decomposition A = U S VT and returns the result. Note VT (V transpose) is returned instead of V.
| Tensor open3d::core::Tensor::T | ( | ) | const |
Returns a tensor with the specified dtype.
| dtype | The targeted dtype to convert to. |
| copy | If true, a new tensor is always created; if false, the copy is avoided when the original tensor already have the targeted dtype. |
| DLManagedTensor * open3d::core::Tensor::ToDLPack | ( | ) | const |
Convert the Tensor to DLManagedTensor.
|
inline |
Retrive all values as an std::vector, for debugging and testing.
|
inline |
| std::string open3d::core::Tensor::ToString | ( | bool | with_suffix = true, |
| const std::string & | indent = "" |
||
| ) | const |
| Tensor open3d::core::Tensor::Transpose | ( | int64_t | dim0, |
| int64_t | dim1 | ||
| ) | const |
Transpose a Tensor by swapping dimension dim0 and dim1.
| dim0 | The first dimension to be transposed. |
| dim1 | The second dimension to be transposed. |
| Tensor open3d::core::Tensor::View | ( | const SizeVector & | dst_shape | ) | const |
Returns a new tensor view with the same data but of a different shape.
The returned tensor shares the same data and must have the same number of elements, but may have a different size. For a tensor to be viewed, the new view size must be compatible with its original size and stride, i.e., each new view dimension must either be a subspace of an original dimension, or only span across original dimensions d, d+1, ..., d+kd,d+1, ..., d+k that satisfy the following contiguity-like condition that for all i = 0, ..., k-1, strides[i] = stride[i + 1] * shape[i + 1].
Otherwise, contiguous() needs to be called before the tensor can be viewed. See also: reshape(), which returns a view if the shapes are compatible, and copies (equivalent to calling contiguous()) otherwise.
Ref: https://pytorch.org/docs/stable/tensors.html aten/src/ATen/native/TensorShape.cpp aten/src/ATen/TensorUtils.cpp
|
static |
Create a tensor fill with zeros.
|
protected |
Underlying memory buffer for Tensor.
|
protected |
Data pointer pointing to the beginning element of the Tensor.
Note that this is not necessarily the same as blob_.GetDataPtr(). When this happens, it means that the beginning element of the Tensor is not located a the beginning of the underlying blob. This could happen, for instance, at slicing:
|
protected |
Data type.
|
protected |
SizeVector of the Tensor. SizeVector[i] is the legnth of dimension i.
|
protected |
Stride of a Tensor. The stride of a n-dimensional tensor is also n-dimensional. Stride(i) is the number of elements (not bytes) to jump in a continuous memory space before eaching the next element in dimension i. For example, a 2x3x4 float32 dense tensor has shape(2, 3, 4) and stride(12, 4, 1). A slicing operation performed on the tensor can change the shape and stride.
1.8.13