ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::core::Tensor Class Reference

#include <Tensor.h>

Inheritance diagram for cloudViewer::core::Tensor:
Collaboration diagram for cloudViewer::core::Tensor:

Classes

struct  ConstIterator
 Const iterator for Tensor. More...
 
struct  Iterator
 Iterator for Tensor. More...
 

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)
 
template<typename T >
 Tensor (std::vector< T > &&vec, const SizeVector &shape={})
 Take ownership of data in std::vector<T> More...
 
 Tensor (void *data_ptr, Dtype dtype, const SizeVector &shape, const SizeVector &strides={}, const Device &device=Device("CPU:0"))
 Tensor wrapper constructor from raw host buffer. More...
 
 Tensor (const Tensor &other)=default
 
 Tensor (Tensor &&other)=default
 
Tensoroperator= (const Tensor &other) &
 
Tensoroperator= (Tensor &&other) &
 
Tensoroperator= (const Tensor &other) &&
 Tensor assignment rvalue = lvalue, e.g. tensor_a[0] = tensor_b. More...
 
Tensoroperator= (Tensor &&other) &&
 Tensor assignment rvalue = rvalue, e.g. tensor_a[0] = tensor_b[0]. More...
 
template<typename T >
Tensoroperator= (const T v) &&
 
Tensor ReinterpretCast (const core::Dtype &dtype) const
 
template<typename Object >
TensorAssignObject (const Object &v) &&
 
template<typename S >
void Fill (S 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 Reverse () const
 Reverse a Tensor's elements by viewing the tensor as a 1D array. More...
 
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)
 
Tensor Append (const Tensor &other, const utility::optional< int64_t > &axis=utility::nullopt) const
 Appends the other tensor, along the given axis and returns a copy of the tensor. The other tensors must have same data-type, device, and number of dimensions. All dimensions must be the same, except the dimension along the axis the tensors are to be appended. 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 Flatten (int64_t start_dim=0, int64_t end_dim=-1) const
 
Tensor View (const SizeVector &dst_shape) const
 
Tensor Clone () const
 Copy Tensor to the same device. More...
 
void CopyFrom (const Tensor &other)
 Copy Tensor values to current tensor from the source tensor. More...
 
Tensor To (Dtype dtype, bool copy=false) const
 
Tensor To (const Device &device, bool copy=false) const
 
Tensor To (const Device &device, 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 AsRvalue () const
 Convert to constant rvalue. More...
 
Tensor IndexGet (const std::vector< Tensor > &index_tensors) const
 Advanced indexing getter. This will always allocate a new Tensor. More...
 
void IndexSet (const std::vector< Tensor > &index_tensors, const Tensor &src_tensor)
 Advanced indexing getter. More...
 
void IndexAdd_ (int64_t dim, const Tensor &index, const Tensor &src)
 Advanced in-place reduction by index. 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...
 
double Det () const
 Compute the determinant of a 2D square tensor. More...
 
template<typename T >
T Item () const
 
Tensor Add (const Tensor &value) const
 Adds a tensor and returns the resulting tensor. More...
 
Tensor Add (Scalar value) const
 
Tensor operator+ (const Tensor &value) const
 
Tensor operator+ (Scalar value) const
 
Tensor Add_ (const Tensor &value)
 
Tensor Add_ (Scalar value)
 
Tensor operator+= (const Tensor &value)
 
Tensor operator+= (Scalar value)
 
Tensor Sub (const Tensor &value) const
 Substracts a tensor and returns the resulting tensor. More...
 
Tensor Sub (Scalar value) const
 
Tensor operator- (const Tensor &value) const
 
Tensor operator- (Scalar value) const
 
Tensor Sub_ (const Tensor &value)
 
Tensor Sub_ (Scalar value)
 
Tensor operator-= (const Tensor &value)
 
Tensor operator-= (Scalar value)
 
Tensor Mul (const Tensor &value) const
 Multiplies a tensor and returns the resulting tensor. More...
 
Tensor Mul (Scalar value) const
 
Tensor operator* (const Tensor &value) const
 
Tensor operator* (Scalar value) const
 
Tensor Mul_ (const Tensor &value)
 
Tensor Mul_ (Scalar value)
 
Tensor operator*= (const Tensor &value)
 
Tensor operator*= (Scalar value)
 
Tensor Div (const Tensor &value) const
 Divides a tensor and returns the resulting tensor. More...
 
Tensor Div (Scalar value) const
 
Tensor operator/ (const Tensor &value) const
 
Tensor operator/ (Scalar value) const
 
Tensor Div_ (const Tensor &value)
 
Tensor Div_ (Scalar value)
 
Tensor operator/= (const Tensor &value)
 
Tensor operator/= (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 operator- () const
 Unary minus of a tensor, returning a new tensor. 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 IsNan () const
 
Tensor IsInf () const
 
Tensor IsFinite () const
 
Tensor Clip (Scalar min_val, Scalar max_val) const
 
Tensor Clip_ (Scalar min_val, Scalar max_val)
 
Tensor Floor () const
 Element-wise floor value of a tensor, returning a new tensor. More...
 
Tensor Ceil () const
 Element-wise ceil value of a tensor, returning a new tensor. More...
 
Tensor Round () const
 Element-wise round value of a tensor, returning a new tensor. More...
 
Tensor Trunc () const
 Element-wise trunc value of a tensor, returning a new tensor. More...
 
Tensor LogicalNot () const
 
Tensor LogicalNot_ ()
 
Tensor LogicalAnd (const Tensor &value) const
 
Tensor operator&& (const Tensor &value) const
 
Tensor LogicalAnd (Scalar value) const
 
Tensor LogicalAnd_ (const Tensor &value)
 
Tensor LogicalAnd_ (Scalar value)
 
Tensor LogicalOr (const Tensor &value) const
 
Tensor operator|| (const Tensor &value) const
 
Tensor LogicalOr (Scalar value) const
 
Tensor LogicalOr_ (const Tensor &value)
 
Tensor LogicalOr_ (Scalar value)
 
Tensor LogicalXor (const Tensor &value) const
 
Tensor LogicalXor (Scalar value) const
 
Tensor LogicalXor_ (const Tensor &value)
 
Tensor LogicalXor_ (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
 
Tensor Gt (Scalar value) const
 
Tensor Gt_ (const Tensor &value)
 
Tensor Gt_ (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
 
Tensor Lt (Scalar value) const
 
Tensor Lt_ (const Tensor &value)
 
Tensor Lt_ (Scalar value)
 
Tensor Ge (const Tensor &value) const
 
Tensor operator>= (const Tensor &value) const
 
Tensor Ge (Scalar value) const
 
Tensor Ge_ (const Tensor &value)
 
Tensor Ge_ (Scalar value)
 
Tensor Le (const Tensor &value) const
 
Tensor operator<= (const Tensor &value) const
 
Tensor Le (Scalar value) const
 
Tensor Le_ (const Tensor &value)
 
Tensor Le_ (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
 
Tensor Eq (Scalar value) const
 
Tensor Eq_ (const Tensor &value)
 
Tensor Eq_ (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
 
Tensor Ne (Scalar value) const
 
Tensor Ne_ (const Tensor &value)
 
Tensor Ne_ (Scalar value)
 
std::vector< TensorNonZeroNumpy () const
 
Tensor NonZero () const
 
bool IsNonZero () const
 
Tensor All (const utility::optional< SizeVector > &dims=utility::nullopt, bool keepdim=false) const
 
Tensor Any (const utility::optional< SizeVector > &dims=utility::nullopt, bool keepdim=false) const
 
bool AllEqual (const Tensor &other) 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< TToFlatVector () const
 Retrieve 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
 
std::tuple< Tensor, Tensor, TensorLU (const bool permute_l=false) const
 Computes LU factorisation of the 2D square tensor, using A = P * L * U; where P is the permutation matrix, L is the lower-triangular matrix with diagonal elements as 1.0 and U is the upper-triangular matrix, and returns tuple (P, L, U). More...
 
std::tuple< Tensor, TensorLUIpiv () const
 Computes LU factorisation of the 2D square tensor, using A = P * L * U; where P is the permutation matrix, L is the lower-triangular matrix with diagonal elements as 1.0 and U is the upper-triangular matrix, and returns tuple output tensor of shape {n,n} and ipiv tensor of shape {n}, where {n,n} is the shape of input tensor. [ipiv, output = cloudViewer.core.lu_ipiv(a)]. More...
 
Tensor Triu (const int diagonal=0) const
 Returns the upper triangular matrix of the 2D tensor, above the given diagonal index. [The value of diagonal = col - row, therefore 0 is the main diagonal (row = col), and it shifts towards right for positive values (for diagonal = 1, col - row = 1), and towards left for negative values. The value of the diagonal parameter must be between [-m, n] for a {m,n} shaped tensor. More...
 
Tensor Tril (const int diagonal=0) const
 Returns the lower triangular matrix of the 2D tensor, above the given diagonal index. [The value of diagonal = col - row, therefore 0 is the main diagonal (row = col), and it shifts towards right for positive values (for diagonal = 1, col - row = 1), and towards left for negative values. The value of the diagonal parameter must be between [-m, n] where {m, n} is the shape of input tensor. More...
 
std::tuple< Tensor, TensorTriul (const int diagonal=0) const
 Returns the tuple of upper and lower triangular matrix of the 2D tensor, above and below the given diagonal index. The diagonal elements of lower triangular matrix are taken to be unity. [The value of diagonal = col - row, therefore 0 is the main diagonal (row = col), and it shifts towards right for positive values (for diagonal = 1, col - row = 1), and towards left for negative values. The value of the diagonal parameter must be between [-m, n] where {m, n} is the shape of input tensor. More...
 
Tensor Inverse () const
 
std::tuple< Tensor, Tensor, TensorSVD () const
 
int64_t GetLength () const
 
SizeVector GetShape () const
 
const SizeVectorGetShapeRef () const
 
int64_t GetShape (int64_t dim) const
 
SizeVector GetStrides () const
 
const SizeVectorGetStridesRef () const
 
int64_t GetStride (int64_t dim) const
 
template<typename T >
TGetDataPtr ()
 
template<typename T >
const TGetDataPtr () const
 
void * GetDataPtr ()
 
const void * GetDataPtr () const
 
Dtype GetDtype () const
 
Device GetDevice () const override
 
std::shared_ptr< BlobGetBlob () const
 
int64_t NumElements () const
 
int64_t NumDims () const
 
template<typename T >
void AssertTemplateDtype () const
 
DLManagedTensorToDLPack () const
 Convert the Tensor to DLManagedTensor (DLPack v0.x). More...
 
DLManagedTensorVersionedToDLPackVersioned () const
 Convert the Tensor to DLManagedTensorVersioned (DLPack v1.x). More...
 
void Save (const std::string &file_name) const
 Save tensor to numpy's npy format. More...
 
Iterator begin ()
 
Iterator end ()
 
ConstIterator cbegin () const
 
ConstIterator cend () const
 
ConstIterator begin () const
 
ConstIterator end () const
 
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
 
- Public Member Functions inherited from cloudViewer::core::IsDevice
 IsDevice ()=default
 
virtual ~IsDevice ()=default
 
bool IsCPU () const
 
bool IsCUDA () const
 
bool IsSYCL () const
 

Static Public Member Functions

static Tensor Empty (const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0"))
 Create a tensor with uninitialized 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...
 
template<typename T >
static Tensor Init (const T val, const Device &device=Device("CPU:0"))
 
template<typename T >
static Tensor Init (const std::initializer_list< T > &in_list, const Device &device=Device("CPU:0"))
 
template<typename T >
static Tensor Init (const std::initializer_list< std::initializer_list< T >> &in_list, const Device &device=Device("CPU:0"))
 
template<typename T >
static Tensor Init (const std::initializer_list< std::initializer_list< std::initializer_list< T >>> &in_list, const Device &device=Device("CPU:0"))
 
static Tensor Eye (int64_t n, Dtype dtype, const Device &device)
 Create an 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 Tensor Arange (const Scalar start, const Scalar stop, const Scalar step=1, const Dtype dtype=core::Int64, const Device &device=core::Device("CPU:0"))
 Create a 1D tensor with evenly spaced values in the given interval. More...
 
static Tensor FromDLPack (const DLManagedTensor *dlmt, std::function< void(void *)> deleter=nullptr)
 Convert DLManagedTensor to Tensor (DLPack v0.x). More...
 
static Tensor FromDLPackVersioned (const DLManagedTensorVersioned *dlmt, std::function< void(void *)> deleter=nullptr)
 Convert DLManagedTensorVersioned to Tensor (DLPack v1.x). More...
 
static Tensor Load (const std::string &file_name)
 Load tensor from numpy's npy format. More...
 

Protected Member Functions

std::string ScalarPtrToString (const void *ptr) const
 

Protected Attributes

SizeVector shape_ = {0}
 SizeVector of the Tensor. shape_[i] is the length of dimension i. More...
 
SizeVector strides_ = {1}
 
void * data_ptr_ = nullptr
 
Dtype dtype_ = core::Undefined
 Data type. More...
 
std::shared_ptr< Blobblob_ = nullptr
 Underlying memory buffer for Tensor. More...
 

Detailed Description

A Tensor is a "view" of a data Blob with shape, stride, data_ptr. Tensor can also be used to perform numerical operations.

Definition at line 32 of file Tensor.h.

Constructor & Destructor Documentation

◆ Tensor() [1/10]

cloudViewer::core::Tensor::Tensor ( )
inline

◆ Tensor() [2/10]

cloudViewer::core::Tensor::Tensor ( const SizeVector shape,
Dtype  dtype,
const Device device = Device("CPU:0") 
)
inline

Constructor for creating a contiguous Tensor.

Definition at line 37 of file Tensor.h.

References blob_, and data_ptr_.

◆ Tensor() [3/10]

template<typename T >
cloudViewer::core::Tensor::Tensor ( const std::vector< T > &  init_vals,
const SizeVector shape,
Dtype  dtype,
const Device device = Device("CPU:0") 
)
inline

Constructor for creating a contiguous Tensor with initial values.

Definition at line 50 of file Tensor.h.

References blob_, cloudViewer::core::Dtype::ByteSize(), GetDevice(), LogError, cloudViewer::core::MemoryManager::MemcpyFromHost(), cloudViewer::core::SizeVector::NumElements(), and shape_.

◆ Tensor() [4/10]

template<typename T >
cloudViewer::core::Tensor::Tensor ( const T init_vals,
const SizeVector shape,
Dtype  dtype,
const Device device = Device("CPU:0") 
)
inline

Constructor from raw host buffer. The memory will be copied.

Definition at line 78 of file Tensor.h.

References blob_, cloudViewer::core::Dtype::ByteSize(), GetDevice(), cloudViewer::core::MemoryManager::MemcpyFromHost(), cloudViewer::core::SizeVector::NumElements(), and shape_.

◆ Tensor() [5/10]

cloudViewer::core::Tensor::Tensor ( const SizeVector shape,
const SizeVector strides,
void *  data_ptr,
Dtype  dtype,
const std::shared_ptr< Blob > &  blob 
)
inline

The fully specified constructor. Since you're responsible for creating the Blob, take care of Blob's deleter if the memory is allocated elsewhere. See Blob.h for more details.

Definition at line 95 of file Tensor.h.

◆ Tensor() [6/10]

template<typename T >
cloudViewer::core::Tensor::Tensor ( std::vector< T > &&  vec,
const SizeVector shape = {} 
)
inline

Take ownership of data in std::vector<T>

Create a Tensor from data "moved" from an std::vector<T>. This always produces a Tensor on the CPU device.

Parameters
vecsource for the data as an r-value reference. After the Tensor is created this will not have access to or manage the data any more.
shapeList of dimensions of data in buffer. e.g. {640, 480, 3} for a 640x480 RGB image. A 1D {vec.size()} shape is assumed if not specified.

Definition at line 117 of file Tensor.h.

◆ Tensor() [7/10]

cloudViewer::core::Tensor::Tensor ( void *  data_ptr,
Dtype  dtype,
const SizeVector shape,
const SizeVector strides = {},
const Device device = Device("CPU:0") 
)
inline

Tensor wrapper constructor from raw host buffer.

This creates a Tensor wrapper for externally managed memory. It is the user's responsibility to keep the buffer valid during the lifetime of this Tensor and deallocate it afterwards.

Parameters
data_ptrPointer to externally managed buffer.
dtypeTensor element data type. e.g. Float32 for single precision float.
shapeList of dimensions of data in buffer. e.g. {640, 480, 3} for a 640x480 RGB image.
stridesNumber of elements to advance to reach the next element, for every dimension. This will be calculated from the shape assuming a contiguous buffer if not specified. For the above Float32 image, the value of an element will be read as:
image[row, col, ch] = *(float *) (data_ptr + sizeof(float) *
(row * stride[0] + col * stride[1] + ch * stride[2]));
deviceDevice containing the data buffer.

Definition at line 162 of file Tensor.h.

◆ Tensor() [8/10]

cloudViewer::core::Tensor::Tensor ( const Tensor other)
default

Copy constructor performs a "shallow" copy of the Tensor. This takes a lvalue input, e.g. Tensor dst(src).

◆ Tensor() [9/10]

cloudViewer::core::Tensor::Tensor ( Tensor &&  other)
default

Move constructor performs a "shallow" copy of the Tensor. This takes a rvalue input, e.g. Tensor dst(src[0]).

◆ Tensor() [10/10]

template<>
cloudViewer::core::Tensor::Tensor ( const std::vector< bool > &  init_vals,
const SizeVector shape,
Dtype  dtype,
const Device device 
)
inline

Member Function Documentation

◆ Abs()

Tensor cloudViewer::core::Tensor::Abs ( ) const

Element-wise absolute value of a tensor, returning a new tensor.

Definition at line 1351 of file Tensor.cpp.

References cloudViewer::core::kernel::Abs, dtype_, GetDevice(), shape_, and cloudViewer::core::kernel::UnaryEW().

Referenced by IsClose(), cloudViewer::core::MakeOperation(), and cloudViewer::core::pybind_core_tensor().

◆ Abs_()

Tensor cloudViewer::core::Tensor::Abs_ ( )

Element-wise absolute value of a tensor, in-place.

Definition at line 1357 of file Tensor.cpp.

References cloudViewer::core::kernel::Abs, and cloudViewer::core::kernel::UnaryEW().

Referenced by cloudViewer::core::pybind_core_tensor().

◆ Add() [1/2]

◆ Add() [2/2]

Tensor cloudViewer::core::Tensor::Add ( Scalar  value) const

◆ Add_() [1/2]

◆ Add_() [2/2]

Tensor cloudViewer::core::Tensor::Add_ ( Scalar  value)

◆ All()

◆ AllClose()

bool cloudViewer::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.

  • If the device is not the same: throws exception.
  • If the dtype is not the same: throws exception.
  • If the shape is not the same: returns false.
  • Returns true if: abs(self - other) <= (atol + rtol * abs(other)).

The equation is not symmetrical, 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

Parameters
otherThe other tensor to compare with.
rtolRelative tolerance.
atolAbsolute tolerance.

Definition at line 1895 of file Tensor.cpp.

References All(), IsClose(), and Item().

Referenced by cloudViewer::t::geometry::CreatePointCloudWithNormals(), cloudViewer::t::geometry::OrientedBoundingBox::Rotate(), and cloudViewer::t::geometry::OrientedBoundingBox::SetRotation().

◆ AllEqual()

bool cloudViewer::core::Tensor::AllEqual ( const Tensor other) const

Returns true if the two tensors are element-wise equal.

  • If the device is not the same: throws exception.
  • If the dtype is not the same: throws exception.
  • If the shape is not the same: returns false.
  • Returns true if: the device, dtype and shape are the same and all corresponding elements are equal.

TODO: support nan

Parameters
otherThe other tensor to compare with.

Definition at line 1885 of file Tensor.cpp.

References AssertTensorDevice, AssertTensorDtype, GetDevice(), GetDtype(), and shape_.

◆ Any()

◆ Append()

Tensor cloudViewer::core::Tensor::Append ( const Tensor other,
const utility::optional< int64_t > &  axis = utility::nullopt 
) const

Appends the other tensor, along the given axis and returns a copy of the tensor. The other tensors must have same data-type, device, and number of dimensions. All dimensions must be the same, except the dimension along the axis the tensors are to be appended.

This is the same as NumPy's semantics:

Example:

Tensor a = Tensor::Init<int64_t>({0, 1}, {2, 3});
Tensor b = Tensor::Init<int64_t>({4, 5});
Tensor t1 = a.Append(b, 0);
// t1:
// [[0 1],
// [2 3],
// [4 5]]
// Tensor[shape={3, 2}, stride={2, 1}, Int64, CPU:0, 0x55555abc6b00]
Tensor t2 = a.Append(b);
// t2:
// [0 1 2 3 4 5]
// Tensor[shape={6}, stride={1}, Int64, CPU:0, 0x55555abc6b70]
Parameters
otherValues of this tensor is appended to the tensor.
axis[optional] The axis along which values are appended. If axis is not given, both tensors are flattened before use.
Returns
A copy of the tensor with values appended to axis. Note that append does not occur in-place: a new array is allocated and filled. If axis is None, out is a flattened tensor.

Definition at line 622 of file Tensor.cpp.

References cloudViewer::core::Append().

◆ Arange()

◆ ArgMax()

Tensor cloudViewer::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.

Parameters
dimsdims 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 flattened tensor.

Definition at line 1289 of file Tensor.cpp.

References cloudViewer::core::kernel::ArgMax, GetDevice(), cloudViewer::core::Int64, cloudViewer::core::kernel::Reduction(), cloudViewer::core::shape_util::ReductionShape(), and shape_.

◆ ArgMin()

Tensor cloudViewer::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.

Parameters
dimsdims 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 flattened tensor.

Definition at line 1282 of file Tensor.cpp.

References cloudViewer::core::kernel::ArgMin, GetDevice(), cloudViewer::core::Int64, cloudViewer::core::kernel::Reduction(), cloudViewer::core::shape_util::ReductionShape(), and shape_.

◆ AsRvalue() [1/2]

Tensor cloudViewer::core::Tensor::AsRvalue ( )
inline

Convert to rvalue such that the Tensor can be assigned.

E.g. in numpy

tensor_a = tensor_b # tensor_a is lvalue, tensor_a variable will
# now reference tensor_b, that is, tensor_a
# and tensor_b share exactly the same memory.
tensor_a[:] = tensor_b # tensor_a[:] is rvalue, tensor_b's values are
# assigned to tensor_a's memory.

Definition at line 558 of file Tensor.h.

Referenced by Broadcast(), CopyFrom(), Fill(), FillObject(), cloudViewer::t::geometry::LineSet::PaintUniformColor(), cloudViewer::t::geometry::PointCloud::PaintUniformColor(), cloudViewer::ml::contrib::RadiusSearch(), cloudViewer::core::kernel::Reduction(), and SetItem().

◆ AsRvalue() [2/2]

const Tensor cloudViewer::core::Tensor::AsRvalue ( ) const
inline

Convert to constant rvalue.

Definition at line 561 of file Tensor.h.

◆ AssertTemplateDtype()

template<typename T >
void cloudViewer::core::Tensor::AssertTemplateDtype ( ) const
inline

◆ AssignObject()

template<typename Object >
Tensor& cloudViewer::core::Tensor::AssignObject ( const Object &  v) &&
inline

Assign an object to a tensor. The tensor being assigned to must be a scalar 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.

Definition at line 220 of file Tensor.h.

References GetDataPtr(), GetDevice(), LogError, cloudViewer::core::MemoryManager::MemcpyFromHost(), shape_, and cloudViewer::core::SmallVectorBase< Size_T >::size().

◆ AsStrided()

Tensor cloudViewer::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.

Definition at line 1061 of file Tensor.cpp.

References blob_, data_ptr_, dtype_, and result.

Referenced by Diag(), Expand(), Eye(), Permute(), Reshape(), cloudViewer::core::AdvancedIndexPreprocessor::RestrideTensor(), and View().

◆ begin() [1/2]

Tensor::Iterator cloudViewer::core::Tensor::begin ( )

Returns the beginning of the tensor iterator. The iterator iterates over the first dimension of the tensor. The generated tensor slices share the same memory with the original tensor.

Definition at line 269 of file Tensor.cpp.

References LogError, and NumDims().

◆ begin() [2/2]

ConstIterator cloudViewer::core::Tensor::begin ( ) const
inline

Returns the beginning of the const tensor iterator. The iterator iterates over the first dimension of the tensor. The generated tensor slices share the same memory with the original tensor. This is equivalent to Tensor::cbegin().

Definition at line 1284 of file Tensor.h.

References cbegin().

◆ Broadcast()

Tensor cloudViewer::core::Tensor::Broadcast ( const SizeVector dst_shape) const

◆ cbegin()

Tensor::ConstIterator cloudViewer::core::Tensor::cbegin ( ) const

Returns the beginning of the const tensor iterator. The iterator iterates over the first dimension of the tensor. The generated tensor slices share the same memory with the original tensor.

Definition at line 338 of file Tensor.cpp.

References LogError, and NumDims().

Referenced by begin().

◆ Ceil()

Tensor cloudViewer::core::Tensor::Ceil ( ) const

Element-wise ceil value of a tensor, returning a new tensor.

Definition at line 1417 of file Tensor.cpp.

References cloudViewer::core::kernel::Ceil, dtype_, GetDevice(), shape_, and cloudViewer::core::kernel::UnaryEW().

Referenced by cloudViewer::core::MakeOperation(), and cloudViewer::core::pybind_core_tensor().

◆ cend()

Tensor::ConstIterator cloudViewer::core::Tensor::cend ( ) const

Returns the end of the const tensor iterator. The iterator iterates over the first dimension of the tensor. The generated tensor slices share the same memory with the original tensor.

Definition at line 345 of file Tensor.cpp.

References LogError, NumDims(), and shape_.

Referenced by end().

◆ Clip()

Tensor cloudViewer::core::Tensor::Clip ( Scalar  min_val,
Scalar  max_val 
) const

Element-wise clipping of tensor values so that resulting values lie in the range [min_val, max_val], returning a new tensor.

Parameters
min_valLower bound for output values.
max_valUpper bound for output values.

Definition at line 1392 of file Tensor.cpp.

References Clip_(), and Clone().

Referenced by cloudViewer::t::io::ConvertColorTensorToUint8().

◆ Clip_()

Tensor cloudViewer::core::Tensor::Clip_ ( Scalar  min_val,
Scalar  max_val 
)

Element-wise clipping of tensor values so that resulting values lie in the range [min_val, max_val]. In-place version.

Parameters
min_valLower bound for output values.
max_valUpper bound for output values.

Definition at line 1398 of file Tensor.cpp.

References DISPATCH_DTYPE_TO_TEMPLATE, dtype_, Full(), GetDevice(), Gt(), cloudViewer::core::TensorKey::IndexTensor(), Lt(), SetItem(), and cloudViewer::core::Scalar::To().

Referenced by Clip().

◆ Clone()

◆ Contiguous()

Tensor cloudViewer::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.

Definition at line 772 of file Tensor.cpp.

References GetDevice(), IsContiguous(), and To().

Referenced by cloudViewer::core::AddMM(), cloudViewer::t::geometry::RaycastingScene::AddTriangles(), cloudViewer::t::geometry::RaycastingScene::CastRays(), cloudViewer::t::geometry::PointCloud::ComputeBoundaryPoints(), cloudViewer::t::geometry::RaycastingScene::ComputeClosestPoints(), cloudViewer::t::geometry::RaycastingScene::ComputeDistance(), cloudViewer::t::pipelines::kernel::ComputeInformationMatrix(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryInformationMatrix(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryResultHybrid(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryResultIntensity(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryResultPointToPlane(), cloudViewer::t::pipelines::kernel::ComputePoseColoredICP(), cloudViewer::t::pipelines::kernel::ComputePoseDopplerICP(), cloudViewer::t::pipelines::kernel::ComputePosePointToPlane(), cloudViewer::t::pipelines::kernel::ComputeRtPointToPoint(), cloudViewer::t::geometry::RaycastingScene::ComputeSignedDistance(), cloudViewer::t::geometry::ComputeTriangleAreasHelper(), cloudViewer::t::geometry::kernel::uvunwrapping::ComputeUVAtlas(), cloudViewer::core::kernel::CopySYCL(), cloudViewer::t::geometry::RaycastingScene::CountIntersections(), cloudViewer::t::geometry::RaycastingScene::CreateRaysPinhole(), cloudViewer::t::geometry::kernel::image::CreateVertexMap(), cloudViewer::t::geometry::kernel::pointcloud::EstimateColorGradientsUsingKNNSearchCPU(), cloudViewer::t::geometry::kernel::pointcloud::EstimateColorGradientsUsingRadiusSearchCPU(), cloudViewer::t::geometry::kernel::pointcloud::EstimateCovariancesUsingKNNSearchCPU(), cloudViewer::t::geometry::kernel::voxel_grid::EstimateRange(), cloudViewer::t::geometry::vtkutils::ExtrudeLinearPolyData(), cloudViewer::t::geometry::vtkutils::ExtrudeRotationPolyData(), cloudViewer::t::pipelines::slac::FillInSLACAlignmentTerm(), cloudViewer::io::rpc::messages::Array::FromTensor(), cloudViewer::t::pipelines::slac::ControlGrid::GetNeighborGridMap(), cloudViewer::t::geometry::TriangleMesh::GetNonManifoldEdges(), cloudViewer::t::geometry::kernel::pointcloud::GetPointMaskWithinAABB(), cloudViewer::t::geometry::kernel::pointcloud::GetPointMaskWithinOBB(), cloudViewer::t::geometry::kernel::pointcloud::GetPointMaskWithinOBBCPU(), cloudViewer::core::Inverse(), cloudViewer::ml::contrib::Iou3dCPU(), cloudViewer::ml::contrib::IouBevCPU(), cloudViewer::t::geometry::RaycastingScene::ListIntersections(), cloudViewer::core::LUIpiv(), cloudViewer::core::Matmul(), cloudViewer::t::io::NumpyArray::NumpyArray(), cloudViewer::core::OutputToPLU(), cloudViewer::t::pipelines::slac::ControlGrid::Parameterize(), cloudViewer::t::pipelines::kernel::PoseToTransformation(), cloudViewer::t::geometry::kernel::pointcloud::Project(), cloudViewer::t::geometry::TriangleMesh::ProjectImagesToAlbedo(), cloudViewer::core::pybind_core_tensor(), cloudViewer::t::geometry::TriangleMesh::RemoveNonManifoldEdges(), cloudViewer::t::geometry::TriangleMesh::RemoveUnreferencedVertices(), Reshape(), cloudViewer::t::geometry::kernel::transform::RotateNormals(), cloudViewer::t::geometry::kernel::transform::RotatePoints(), cloudViewer::t::geometry::TriangleMesh::SamplePointsUniformly(), cloudViewer::core::nns::FixedRadiusIndex::SearchHybrid(), cloudViewer::core::nns::NanoFlannIndex::SearchHybrid(), cloudViewer::core::nns::KnnIndex::SearchKnn(), cloudViewer::core::nns::NanoFlannIndex::SearchKnn(), cloudViewer::core::nns::FixedRadiusIndex::SearchRadius(), cloudViewer::core::nns::NanoFlannIndex::SearchRadius(), cloudViewer::t::geometry::TriangleMesh::SelectByIndex(), cloudViewer::t::geometry::TriangleMesh::SelectFacesByMask(), cloudViewer::core::nns::NanoFlannIndex::SetTensorData(), cloudViewer::core::nns::KnnIndex::SetTensorData(), cloudViewer::core::nns::FixedRadiusIndex::SetTensorData(), cloudViewer::t::io::DepthNoiseSimulator::Simulate(), cloudViewer::ml::contrib::Subsample(), cloudViewer::ml::contrib::SubsampleBatch(), cloudViewer::core::SVD(), cloudViewer::core::eigen_converter::TensorToEigenMatrix(), cloudViewer::core::eigen_converter::TensorToEigenVectorNxVector(), cloudViewer::t::geometry::RaycastingScene::TestOcclusions(), ToFlatVector(), ToString(), cloudViewer::t::pipelines::kernel::TransformationToPose(), cloudViewer::t::geometry::kernel::transform::TransformNormals(), cloudViewer::t::geometry::kernel::transform::TransformPoints(), cloudViewer::core::Tril(), cloudViewer::core::Triu(), cloudViewer::core::Triul(), cloudViewer::t::geometry::kernel::pointcloud::Unproject(), cloudViewer::t::pipelines::slam::Model::UpdateFramePose(), and cloudViewer::t::io::WriteNpz().

◆ CopyFrom()

void cloudViewer::core::Tensor::CopyFrom ( const Tensor other)

Copy Tensor values to current tensor from the source tensor.

Definition at line 770 of file Tensor.cpp.

References AsRvalue().

Referenced by cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBApprox(), cloudViewer::core::kernel::CopySYCL(), and cloudViewer::core::kernel::IndexGet().

◆ Cos()

Tensor cloudViewer::core::Tensor::Cos ( ) const

Element-wise cosine of a tensor, returning a new tensor.

Definition at line 1318 of file Tensor.cpp.

References cloudViewer::core::kernel::Cos, dtype_, GetDevice(), shape_, and cloudViewer::core::kernel::UnaryEW().

Referenced by cloudViewer::core::MakeOperation(), and cloudViewer::core::pybind_core_tensor().

◆ Cos_()

Tensor cloudViewer::core::Tensor::Cos_ ( )

Element-wise cosine of a tensor, in-place.

Definition at line 1324 of file Tensor.cpp.

References cloudViewer::core::kernel::Cos, and cloudViewer::core::kernel::UnaryEW().

Referenced by cloudViewer::core::pybind_core_tensor().

◆ Det()

double cloudViewer::core::Tensor::Det ( ) const

Compute the determinant of a 2D square tensor.

Returns
returns the determinant of the matrix (double).

Definition at line 1092 of file Tensor.cpp.

References AssertTensorDtypes, cloudViewer::core::Det(), cloudViewer::core::Float32, and cloudViewer::core::Float64.

Referenced by cloudViewer::t::pipelines::kernel::ComputeRtPointToPoint(), and cloudViewer::core::pybind_core_tensor().

◆ Diag()

Tensor cloudViewer::core::Tensor::Diag ( const Tensor input)
static

Create a square matrix with specified diagonal elements in input.

Definition at line 424 of file Tensor.cpp.

References AsStrided(), GetDevice(), GetDtype(), GetShape(), LogError, shape_, cloudViewer::core::SmallVectorBase< Size_T >::size(), strides_, cloudViewer::core::SizeVector::ToString(), and Zeros().

Referenced by cloudViewer::core::pybind_core_tensor().

◆ Div() [1/2]

◆ Div() [2/2]

Tensor cloudViewer::core::Tensor::Div ( Scalar  value) const

◆ Div_() [1/2]

Tensor cloudViewer::core::Tensor::Div_ ( const Tensor value)

Inplace version of Tensor::Div. Divides a tensor to the current tensor and returns the current tensor.

Definition at line 1225 of file Tensor.cpp.

References AssertTensorDevice, AssertTensorDtype, cloudViewer::core::kernel::BinaryEW(), cloudViewer::core::kernel::Div, GetDevice(), and GetDtype().

Referenced by cloudViewer::t::pipelines::kernel::ComputeRtPointToPoint(), Div_(), and operator/=().

◆ Div_() [2/2]

Tensor cloudViewer::core::Tensor::Div_ ( Scalar  value)

◆ Empty()

Tensor cloudViewer::core::Tensor::Empty ( const SizeVector shape,
Dtype  dtype,
const Device device = Device("CPU:0") 
)
static

Create a tensor with uninitialized values.

Definition at line 400 of file Tensor.cpp.

References Tensor().

Referenced by cloudViewer::core::nns::NeighborSearchAllocator< T, TIndex >::AllocCounts(), cloudViewer::core::nns::NeighborSearchAllocator< T, TIndex >::AllocDistances(), cloudViewer::core::nns::NeighborSearchAllocator< T, TIndex >::AllocIndices(), cloudViewer::t::geometry::PointCloud::Append(), cloudViewer::t::geometry::TriangleMesh::BakeVertexAttrTextures(), cloudViewer::t::pipelines::registration::ComputeDirectionVectors(), cloudViewer::t::pipelines::kernel::ComputeFPFHFeatureCPU(), cloudViewer::t::pipelines::kernel::ComputeInformationMatrix(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryInformationMatrixCPU(), cloudViewer::t::pipelines::kernel::ComputePoseColoredICP(), cloudViewer::t::pipelines::kernel::ComputePoseDopplerICP(), cloudViewer::t::pipelines::kernel::ComputePosePointToPlane(), cloudViewer::t::geometry::TriangleMesh::ComputeTriangleAreas(), cloudViewer::visualization::rendering::TMeshBuffersBuilder::ConstructBuffers(), cloudViewer::t::pipelines::kernel::DecodeAndSolve6x6(), cloudViewer::core::eigen_converter::EigenVectorNxVectorToTensor(), EmptyLike(), cloudViewer::t::geometry::PointCloud::EstimateColorGradients(), cloudViewer::t::geometry::PointCloud::EstimateNormals(), cloudViewer::t::geometry::Image::FilterSobel(), cloudViewer::core::TensorList::FromTensor(), Full(), cloudViewer::core::Inverse(), cloudViewer::core::LUIpiv(), cloudViewer::core::Matmul(), cloudViewer::t::io::PackColorsToFloat(), cloudViewer::t::geometry::LineSet::PaintUniformColor(), cloudViewer::t::geometry::PointCloud::PaintUniformColor(), cloudViewer::t::geometry::kernel::pcapartition::PCAPartition(), cloudViewer::t::geometry::TriangleMesh::ProjectImagesToAlbedo(), cloudViewer::core::pybind_core_tensor(), cloudViewer::t::geometry::Image::PyrDownDepth(), cloudViewer::benchmarks::Rand(), cloudViewer::t::io::ReadPCDData(), cloudViewer::t::io::ReadPointCloudFromPLY(), cloudViewer::t::io::ReadPointCloudFromSPLAT(), cloudViewer::t::io::ReadTriangleMeshUsingASSIMP(), cloudViewer::t::geometry::Image::Resize(), cloudViewer::t::geometry::Image::RGBToGray(), cloudViewer::t::geometry::kernel::trianglemesh::SamplePointsUniformlyCPU(), cloudViewer::core::nns::KnnIndex::SearchKnn(), cloudViewer::core::nns::FixedRadiusIndex::SetTensorData(), cloudViewer::core::Solve(), cloudViewer::core::SVD(), and cloudViewer::t::geometry::Image::To().

◆ EmptyLike()

static Tensor cloudViewer::core::Tensor::EmptyLike ( const Tensor other)
inlinestatic

◆ end() [1/2]

Tensor::Iterator cloudViewer::core::Tensor::end ( )

Returns the end of the tensor iterator. The iterator iterates over the first dimension of the tensor. The generated tensor slices share the same memory with the original tensor.

Definition at line 276 of file Tensor.cpp.

References LogError, NumDims(), and shape_.

◆ end() [2/2]

ConstIterator cloudViewer::core::Tensor::end ( ) const
inline

Returns the end of the const tensor iterator. The iterator iterates over the first dimension of the tensor. The generated tensor slices share the same memory with the original tensor. This is equivalent to Tensor::cend().

Definition at line 1290 of file Tensor.h.

References cend().

◆ Eq() [1/2]

Tensor cloudViewer::core::Tensor::Eq ( const Tensor value) const

◆ Eq() [2/2]

Tensor cloudViewer::core::Tensor::Eq ( Scalar  value) const

◆ Eq_() [1/2]

Tensor cloudViewer::core::Tensor::Eq_ ( const Tensor value)

Element-wise equals-to of tensors, in-place. This operation won't change the tensor's dtype.

Definition at line 1700 of file Tensor.cpp.

References AssertTensorDevice, cloudViewer::core::kernel::BinaryEW(), cloudViewer::core::kernel::Eq, and GetDevice().

Referenced by Eq_().

◆ Eq_() [2/2]

Tensor cloudViewer::core::Tensor::Eq_ ( Scalar  value)

◆ Exp()

Tensor cloudViewer::core::Tensor::Exp ( ) const

◆ Exp_()

Tensor cloudViewer::core::Tensor::Exp_ ( )

Element-wise base-e exponential of a tensor, in-place.

Definition at line 1346 of file Tensor.cpp.

References cloudViewer::core::kernel::Exp, and cloudViewer::core::kernel::UnaryEW().

Referenced by cloudViewer::core::pybind_core_tensor().

◆ Expand()

Tensor cloudViewer::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.

Definition at line 638 of file Tensor.cpp.

References AsStrided(), cloudViewer::core::shape_util::CanBeBrocastedToShape(), LogError, NumDims(), shape_, cloudViewer::core::SmallVectorBase< Size_T >::size(), strides_, and cloudViewer::core::SizeVector::ToString().

Referenced by cloudViewer::core::pybind_core_linalg().

◆ Eye()

◆ Fill()

◆ FillObject()

template<typename Object >
void cloudViewer::core::Tensor::FillObject ( const Object &  v)
inline

Definition at line 1410 of file Tensor.h.

References AsRvalue(), GetDevice(), and GetDtype().

◆ Flatten()

Tensor cloudViewer::core::Tensor::Flatten ( int64_t  start_dim = 0,
int64_t  end_dim = -1 
) const

Flattens input by reshaping it into a one-dimensional tensor. If start_dim or end_dim are passed, only dimensions starting with start_dim and ending with end_dim are flattened. The order of elements in input is unchanged.

Unlike NumPy’s flatten, which always copies input’s data, this function may return the original object, a view, or copy. If no dimensions are flattened, then the original object input is returned. Otherwise, if input can be viewed as the flattened shape, then that view is returned. Finally, only if the input cannot be viewed as the flattened shape is input’s data copied.

Ref:

Parameters
start_dimThe first dimension to flatten (inclusive).
end_dimThe last dimension to flatten, starting from start_dim (inclusive).

Definition at line 685 of file Tensor.cpp.

References GetShape(), LogError, NumDims(), cloudViewer::core::SmallVectorTemplateBase< T, bool >::push_back(), Reshape(), and cloudViewer::core::shape_util::WrapDim().

Referenced by cloudViewer::t::geometry::AxisAlignedBoundingBox::FromLegacy(), cloudViewer::t::geometry::OrientedBoundingBox::FromLegacy(), cloudViewer::core::pybind_core_tensor(), and cloudViewer::t::geometry::OrientedBoundingBox::Rotate().

◆ Floor()

◆ FromDLPack()

Tensor cloudViewer::core::Tensor::FromDLPack ( const DLManagedTensor dlmt,
std::function< void(void *)>  deleter = nullptr 
)
static

Convert DLManagedTensor to Tensor (DLPack v0.x).

Definition at line 1868 of file Tensor.cpp.

Referenced by cloudViewer::core::pybind_core_tensor().

◆ FromDLPackVersioned()

Tensor cloudViewer::core::Tensor::FromDLPackVersioned ( const DLManagedTensorVersioned dlmt,
std::function< void(void *)>  deleter = nullptr 
)
static

Convert DLManagedTensorVersioned to Tensor (DLPack v1.x).

Definition at line 1872 of file Tensor.cpp.

Referenced by cloudViewer::core::pybind_core_tensor().

◆ Full()

◆ Ge() [1/2]

Tensor cloudViewer::core::Tensor::Ge ( const Tensor value) const

◆ Ge() [2/2]

Tensor cloudViewer::core::Tensor::Ge ( Scalar  value) const

◆ Ge_() [1/2]

Tensor cloudViewer::core::Tensor::Ge_ ( const Tensor value)

Element-wise greater-than-or-equals-to of tensors, in-place. This operation won't change the tensor's dtype.

Definition at line 1636 of file Tensor.cpp.

References AssertTensorDevice, cloudViewer::core::kernel::BinaryEW(), cloudViewer::core::kernel::Ge, and GetDevice().

Referenced by Ge_().

◆ Ge_() [2/2]

Tensor cloudViewer::core::Tensor::Ge_ ( Scalar  value)

◆ GetBlob()

std::shared_ptr<Blob> cloudViewer::core::Tensor::GetBlob ( ) const
inline

◆ GetDataPtr() [1/4]

template<typename T >
T* cloudViewer::core::Tensor::GetDataPtr ( )
inline

Definition at line 1144 of file Tensor.h.

References T().

Referenced by cloudViewer::core::AddMM(), cloudViewer::core::nns::NeighborSearchAllocator< T, TIndex >::AllocCounts(), cloudViewer::core::nns::NeighborSearchAllocator< T, TIndex >::AllocDistances(), cloudViewer::core::nns::NeighborSearchAllocator< T, TIndex >::AllocIndices(), cloudViewer::core::kernel::ArangeCPU(), cloudViewer::core::kernel::ArangeSYCL(), AssignObject(), cloudViewer::t::geometry::TriangleMesh::BakeVertexAttrTextures(), cloudViewer::core::nns::BuildSpatialHashTableCPU(), cloudViewer::visualization::rendering::TMeshBuffersBuilder::ComputeAABB(), cloudViewer::visualization::rendering::TPointCloudBuffersBuilder::ComputeAABB(), cloudViewer::visualization::rendering::TLineSetBuffersBuilder::ComputeAABB(), cloudViewer::t::geometry::PointCloud::ComputeConvexHull(), cloudViewer::t::geometry::RaycastingScene::ComputeDistance(), cloudViewer::t::pipelines::kernel::ComputeFPFHFeatureCPU(), cloudViewer::t::pipelines::kernel::ComputeInformationMatrixCPU(), cloudViewer::t::geometry::ComputeMetricsCommon(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryInformationMatrixCPU(), cloudViewer::t::pipelines::kernel::ComputePoseDopplerICPCPU(), cloudViewer::t::pipelines::kernel::ComputePosePointToPlaneCPU(), cloudViewer::t::pipelines::kernel::ComputeRtPointToPointCPU(), cloudViewer::t::geometry::kernel::trianglemesh::ComputeTriangleAreasCPU(), cloudViewer::t::geometry::kernel::trianglemesh::ComputeTriangleNormalsCPU(), cloudViewer::t::geometry::kernel::uvunwrapping::ComputeUVAtlas(), cloudViewer::t::geometry::kernel::trianglemesh::ComputeVertexNormalsCPU(), cloudViewer::visualization::rendering::TMeshBuffersBuilder::ConstructBuffers(), cloudViewer::visualization::rendering::TPointCloudBuffersBuilder::ConstructBuffers(), cloudViewer::core::kernel::CopyCPU(), cloudViewer::core::kernel::CopySYCL(), cloudViewer::t::geometry::RaycastingScene::CountIntersections(), cloudViewer::core::nns::NeighborSearchAllocator< T, TIndex >::CountsPtr(), cloudViewer::core::CPUResetHeap(), cloudViewer::t::geometry::RaycastingScene::CreateRaysPinhole(), cloudViewer::t::geometry::vtkutils::CreateVtkCellArrayFromTensor(), cloudViewer::t::geometry::vtkutils::CreateVtkDataArrayFromTensor(), cloudViewer::t::geometry::vtkutils::CreateVtkImageDataFromTensor(), cloudViewer::t::pipelines::kernel::DecodeAndSolve6x6(), cloudViewer::core::Det(), cloudViewer::t::geometry::ipp::Dilate(), cloudViewer::core::nns::NeighborSearchAllocator< T, TIndex >::DistancesPtr(), cloudViewer::core::HashMap::Erase(), cloudViewer::core::StdGPUHashBackend< Key, Hash, Eq >::Erase(), cloudViewer::t::geometry::kernel::pointcloud::EstimateColorGradientsUsingHybridSearchCPU(), cloudViewer::t::geometry::kernel::pointcloud::EstimateColorGradientsUsingKNNSearchCPU(), cloudViewer::t::geometry::kernel::pointcloud::EstimateColorGradientsUsingRadiusSearchCPU(), cloudViewer::t::geometry::kernel::pointcloud::EstimateCovariancesUsingHybridSearchCPU(), cloudViewer::t::geometry::kernel::pointcloud::EstimateCovariancesUsingKNNSearchCPU(), cloudViewer::t::geometry::kernel::pointcloud::EstimateCovariancesUsingRadiusSearchCPU(), cloudViewer::t::pipelines::kernel::FillInRigidAlignmentTermCPU(), cloudViewer::t::geometry::npp::Filter(), cloudViewer::t::geometry::ipp::Filter(), cloudViewer::t::geometry::ipp::FilterBilateral(), cloudViewer::t::geometry::ipp::FilterGaussian(), cloudViewer::t::geometry::ipp::FilterSobel(), cloudViewer::core::HashMap::Find(), cloudViewer::core::nns::FixedRadiusSearchCPU(), cloudViewer::core::HashMap::GetActiveIndices(), cloudViewer::core::GetColPermutation(), cloudViewer::t::geometry::Image::GetDataPtr(), cloudViewer::t::geometry::GetEdgeToTrianglesMap(), cloudViewer::core::HashMap::GetValueTensor(), cloudViewer::core::kernel::IndexAddSYCL_(), cloudViewer::core::nns::NeighborSearchAllocator< T, TIndex >::IndicesPtr(), cloudViewer::core::HashMap::InsertImpl(), cloudViewer::core::Inverse(), cloudViewer::t::geometry::InverseTransformation(), cloudViewer::ml::contrib::Iou3dCPU(), cloudViewer::ml::contrib::IouBevCPU(), cloudViewer::core::kernel::LaunchIndexReductionKernel(), cloudViewer::core::LeastSquares(), cloudViewer::t::geometry::RaycastingScene::ListIntersections(), cloudViewer::core::LUIpiv(), cloudViewer::core::Matmul(), cloudViewer::core::kernel::NonZeroSYCL(), cloudViewer::t::io::PackColorsToFloat(), cloudViewer::t::geometry::kernel::pcapartition::PCAPartition(), cloudViewer::t::geometry::kernel::voxel_grid::PointCloudTouchCPU(), cloudViewer::t::pipelines::kernel::PoseToTransformationDevice(), cloudViewer::t::geometry::TriangleMesh::ProjectImagesToAlbedo(), cloudViewer::ml::contrib::RadiusSearch(), cloudViewer::t::io::ReadPCDData(), cloudViewer::t::io::ReadPointCloudFromPTS(), cloudViewer::t::io::ReadPointCloudFromSPLAT(), cloudViewer::t::io::ReadPointCloudFromTXT(), cloudViewer::t::io::ReadTriangleMeshUsingASSIMP(), cloudViewer::t::geometry::ipp::Remap(), cloudViewer::t::geometry::TriangleMesh::RemoveUnreferencedVertices(), cloudViewer::t::geometry::ipp::Resize(), cloudViewer::t::geometry::ipp::RGBToGray(), cloudViewer::core::nns::NanoFlannIndex::SearchHybrid(), cloudViewer::core::nns::NanoFlannIndex::SearchKnn(), cloudViewer::core::nns::NanoFlannIndex::SearchRadius(), cloudViewer::t::geometry::TriangleMesh::SelectByIndex(), cloudViewer::t::geometry::TriangleMesh::SelectFacesByMask(), cloudViewer::core::nns::NanoFlannIndex::SetTensorData(), cloudViewer::core::CUDAHashBackendBufferAccessor::Setup(), cloudViewer::core::Solve(), cloudViewer::ml::contrib::Subsample(), cloudViewer::ml::contrib::SubsampleBatch(), cloudViewer::core::SVD(), cloudViewer::t::geometry::kernel::TArrayIndexer< index_t >::TArrayIndexer(), cloudViewer::core::TensorRef::TensorRef(), cloudViewer::core::eigen_converter::TensorToEigenMatrix(), cloudViewer::core::eigen_converter::TensorToEigenVectorNxVector(), cloudViewer::core::TensorToPyArray(), cloudViewer::t::geometry::ipp::To(), ToFlatVector(), cloudViewer::t::geometry::Image::ToLegacy(), cloudViewer::t::pipelines::kernel::TransformationToPoseDevice(), cloudViewer::t::geometry::kernel::TransformIndexer::TransformIndexer(), cloudViewer::visualization::rendering::FilamentScene::UpdateGeometry(), cloudViewer::t::geometry::UpdateTriangleIndicesByVertexMask(), cloudViewer::t::io::WriteNpzOneTensor(), and cloudViewer::t::io::WritePointCloudToPTS().

◆ GetDataPtr() [2/4]

void* cloudViewer::core::Tensor::GetDataPtr ( )
inline

Definition at line 1160 of file Tensor.h.

References data_ptr_.

◆ GetDataPtr() [3/4]

template<typename T >
const T* cloudViewer::core::Tensor::GetDataPtr ( ) const
inline

◆ GetDataPtr() [4/4]

const void* cloudViewer::core::Tensor::GetDataPtr ( ) const
inline

Definition at line 1162 of file Tensor.h.

References data_ptr_.

◆ GetDevice()

Device cloudViewer::core::Tensor::GetDevice ( ) const
overridevirtual

Implements cloudViewer::core::IsDevice.

Definition at line 1435 of file Tensor.cpp.

References blob_, and LogError.

Referenced by Abs(), Add(), Add_(), cloudViewer::core::AddMM(), All(), AllEqual(), Any(), cloudViewer::core::kernel::Arange(), cloudViewer::core::kernel::ArangeCPU(), cloudViewer::core::kernel::ArangeSYCL(), ArgMax(), ArgMin(), cloudViewer::core::AssertNotSYCL(), cloudViewer::core::tensor_check::AssertTensorDevice_(), cloudViewer::t::pipelines::registration::AssertValidCorrespondences(), AssignObject(), cloudViewer::t::geometry::AxisAlignedBoundingBox::AxisAlignedBoundingBox(), cloudViewer::core::kernel::BinaryEW(), cloudViewer::core::kernel::BinaryEWSYCL(), Broadcast(), cloudViewer::t::geometry::RaycastingScene::CastRays(), Ceil(), Clip_(), cloudViewer::t::geometry::kernel::image::ClipTransform(), cloudViewer::t::geometry::Image::ClipTransform(), Clone(), cloudViewer::t::geometry::kernel::image::ColorizeDepth(), cloudViewer::t::pipelines::registration::ComputeDirectionVectors(), cloudViewer::t::pipelines::registration::ComputeFPFHFeature(), cloudViewer::t::pipelines::kernel::ComputeInformationMatrix(), cloudViewer::t::geometry::ComputeMetricsCommon(), cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBJylanki(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryInformationMatrix(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryInformationMatrixCPU(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryResultHybrid(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryResultHybridCPU(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryResultIntensity(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryResultIntensityCPU(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryResultPointToPlane(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryResultPointToPlaneCPU(), cloudViewer::t::pipelines::kernel::ComputePoseColoredICP(), cloudViewer::t::pipelines::kernel::ComputePoseDopplerICP(), cloudViewer::t::pipelines::kernel::ComputePosePointToPlane(), cloudViewer::t::pipelines::registration::TransformationEstimationForColoredICP::ComputeRMSE(), cloudViewer::t::pipelines::kernel::ComputeRtPointToPoint(), Contiguous(), cloudViewer::t::pipelines::slac::ConvertCorrespondencesTargetIndexedToCx2Form(), cloudViewer::core::kernel::Copy(), cloudViewer::core::kernel::CopyCPU(), cloudViewer::core::kernel::CopySYCL(), Cos(), cloudViewer::t::geometry::kernel::image::CreateNormalMap(), cloudViewer::t::geometry::CreatePointCloudWithNormals(), cloudViewer::t::geometry::kernel::image::CreateVertexMap(), cloudViewer::t::geometry::vtkutils::CreateVtkDataArrayFromTensor(), cloudViewer::t::geometry::kernel::voxel_grid::DepthTouchCPU(), Diag(), cloudViewer::t::geometry::ipp::Dilate(), cloudViewer::t::geometry::npp::Dilate(), Div(), Div_(), EmptyLike(), Eq(), Eq_(), Exp(), Fill(), cloudViewer::t::pipelines::kernel::FillInRigidAlignmentTerm(), cloudViewer::t::pipelines::kernel::FillInSLACAlignmentTerm(), cloudViewer::t::pipelines::kernel::FillInSLACRegularizerTerm(), FillObject(), cloudViewer::t::geometry::npp::Filter(), cloudViewer::t::geometry::npp::FilterBilateral(), cloudViewer::t::geometry::npp::FilterGaussian(), cloudViewer::t::geometry::npp::FilterSobel(), cloudViewer::t::geometry::Image::FilterSobel(), cloudViewer::core::nns::NearestNeighborSearch::FixedRadiusSearch(), Floor(), cloudViewer::core::TensorList::FromTensor(), Ge(), Ge_(), cloudViewer::core::GetColPermutation(), cloudViewer::core::HashBackendBuffer::GetDevice(), cloudViewer::core::nns::NNSIndex::GetDevice(), cloudViewer::core::TensorList::GetDevice(), cloudViewer::t::geometry::Image::GetDevice(), cloudViewer::core::Open3DDLManagedTensor< DLMT >::getDLPackDevice(), GetItem(), cloudViewer::t::geometry::TriangleMesh::GetNonManifoldEdges(), Gt(), Gt_(), cloudViewer::core::nns::NearestNeighborSearch::HybridSearch(), cloudViewer::core::kernel::IndexAddSYCL_(), IndexGet(), cloudViewer::core::kernel::IndexGet(), cloudViewer::core::kernel::IndexGetSYCL(), cloudViewer::core::kernel::IndexSet(), cloudViewer::core::kernel::IndexSetSYCL(), cloudViewer::core::Inverse(), IsClose(), IsFinite(), IsInf(), IsNan(), IsSame(), Item(), cloudViewer::core::nns::NearestNeighborSearch::KnnSearch(), Le(), Le_(), cloudViewer::core::LeastSquares(), LeastSquares(), cloudViewer::t::geometry::LineSet::LineSet(), LogicalAnd(), LogicalAnd_(), LogicalNot(), LogicalOr(), LogicalOr_(), LogicalXor(), LogicalXor_(), Lt(), Lt_(), cloudViewer::core::LUIpiv(), cloudViewer::core::Matmul(), Matmul(), Max(), cloudViewer::core::Maximum(), Min(), cloudViewer::core::Minimum(), Mul(), Mul_(), Ne(), Ne_(), Neg(), cloudViewer::core::kernel::NonZeroSYCL(), cloudViewer::core::operator-(), cloudViewer::core::operator/(), cloudViewer::t::geometry::OrientedBoundingBox::OrientedBoundingBox(), cloudViewer::core::OutputToPLU(), cloudViewer::t::pipelines::kernel::PoseToTransformation(), cloudViewer::t::pipelines::kernel::PoseToTransformationDevice(), cloudViewer::core::HashMap::PrepareIndicesOutput(), cloudViewer::core::HashMap::PrepareMasksOutput(), Prod(), cloudViewer::t::geometry::kernel::pointcloud::Project(), cloudViewer::core::pybind_core_tensor(), cloudViewer::t::geometry::kernel::image::PyrDownDepth(), cloudViewer::core::kernel::Reduction(), cloudViewer::core::kernel::ReductionSYCL(), cloudViewer::t::geometry::PointCloud::RemoveNonFinitePoints(), cloudViewer::t::geometry::npp::Resize(), cloudViewer::t::geometry::npp::RGBToGray(), Round(), cloudViewer::t::pipelines::kernel::RtToTransformation(), cloudViewer::core::AdvancedIndexPreprocessor::RunPreprocess(), SetItem(), cloudViewer::t::geometry::PointCloud::SetPointAttr(), cloudViewer::t::io::DepthNoiseSimulator::Simulate(), Sin(), cloudViewer::core::Solve(), Solve(), Sqrt(), Sub(), Sub_(), Sum(), cloudViewer::core::SVD(), Tensor(), cloudViewer::core::TensorList::TensorList(), cloudViewer::core::eigen_converter::TensorToEigenVectorNxVector(), cloudViewer::t::geometry::RaycastingScene::TestOcclusions(), cloudViewer::t::geometry::kernel::image::To(), To(), ToFlatVector(), cloudViewer::t::geometry::Image::ToLegacy(), cloudViewer::t::geometry::TensorMap::ToString(), ToString(), cloudViewer::t::pipelines::kernel::TransformationToPose(), cloudViewer::t::geometry::TriangleMesh::TriangleMesh(), cloudViewer::core::Tril(), cloudViewer::core::TrilSYCL(), cloudViewer::core::Triu(), cloudViewer::core::Triul(), cloudViewer::core::TriulSYCL(), cloudViewer::core::TriuSYCL(), Trunc(), cloudViewer::core::kernel::UnaryEW(), cloudViewer::core::kernel::UnaryEWSYCL(), and cloudViewer::t::geometry::kernel::pointcloud::Unproject().

◆ GetDtype()

Dtype cloudViewer::core::Tensor::GetDtype ( ) const
inline

Definition at line 1164 of file Tensor.h.

References dtype_.

Referenced by Add(), Add_(), cloudViewer::core::AddMM(), cloudViewer::core::AdvancedIndexer::AdvancedIndexer(), AllEqual(), cloudViewer::core::kernel::Arange(), cloudViewer::core::kernel::ArangeCPU(), cloudViewer::core::kernel::ArangeSYCL(), cloudViewer::core::tensor_check::AssertTensorDtype_(), cloudViewer::core::tensor_check::AssertTensorDtypes_(), cloudViewer::t::geometry::AxisAlignedBoundingBox::AxisAlignedBoundingBox(), cloudViewer::t::geometry::TriangleMesh::BakeTriangleAttrTextures(), cloudViewer::t::geometry::TriangleMesh::BakeVertexAttrTextures(), cloudViewer::core::kernel::BinaryEWCPU(), cloudViewer::core::kernel::BinaryEWSYCL(), cloudViewer::t::geometry::CheckBlockCoordinates(), cloudViewer::t::geometry::CheckDepthTensor(), cloudViewer::t::geometry::CheckExtrinsicTensor(), cloudViewer::t::geometry::CheckIntrinsicTensor(), cloudViewer::core::HashMap::CheckKeyCompatibility(), cloudViewer::core::HashMap::CheckValueCompatibility(), cloudViewer::t::pipelines::registration::ComputeDirectionVectors(), cloudViewer::t::pipelines::registration::ComputeFPFHFeature(), cloudViewer::t::pipelines::kernel::ComputeInformationMatrix(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryInformationMatrix(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryResultHybrid(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryResultIntensity(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryResultPointToPlane(), cloudViewer::t::pipelines::kernel::ComputePoseColoredICP(), cloudViewer::t::pipelines::kernel::ComputePoseDopplerICP(), cloudViewer::t::pipelines::kernel::ComputePosePointToPlane(), cloudViewer::t::pipelines::registration::TransformationEstimationPointToPoint::ComputeRMSE(), cloudViewer::t::pipelines::registration::TransformationEstimationPointToPlane::ComputeRMSE(), cloudViewer::t::pipelines::registration::TransformationEstimationForColoredICP::ComputeRMSE(), cloudViewer::t::pipelines::registration::TransformationEstimationForDopplerICP::ComputeRMSE(), cloudViewer::t::pipelines::kernel::ComputeRtPointToPoint(), cloudViewer::t::pipelines::registration::TransformationEstimationPointToPoint::ComputeTransformation(), cloudViewer::t::pipelines::registration::TransformationEstimationPointToPlane::ComputeTransformation(), cloudViewer::t::pipelines::registration::TransformationEstimationForColoredICP::ComputeTransformation(), cloudViewer::t::pipelines::registration::TransformationEstimationForDopplerICP::ComputeTransformation(), cloudViewer::t::geometry::TriangleMesh::ComputeTriangleAreas(), cloudViewer::t::geometry::ComputeTriangleAreasHelper(), cloudViewer::t::geometry::TriangleMesh::ComputeTriangleNormals(), cloudViewer::t::geometry::TriangleMesh::ComputeVertexNormals(), cloudViewer::t::geometry::kernel::trianglemesh::ComputeVertexNormalsCPU(), cloudViewer::t::io::ConvertColorTensorToUint8(), cloudViewer::core::kernel::CopyCPU(), cloudViewer::core::kernel::CopySYCL(), cloudViewer::t::geometry::CreatePointCloudWithNormals(), cloudViewer::t::geometry::vtkutils::CreateVtkDataArrayFromTensor(), cloudViewer::t::geometry::kernel::voxel_grid::DepthTouchCPU(), cloudViewer::core::Det(), Diag(), cloudViewer::t::geometry::ipp::Dilate(), cloudViewer::t::geometry::npp::Dilate(), Div(), Div_(), cloudViewer::t::geometry::PointCloud::EstimateColorGradients(), cloudViewer::t::geometry::PointCloud::EstimateNormals(), cloudViewer::t::pipelines::registration::EvaluateRegistration(), cloudViewer::t::geometry::PointCloud::FarthestPointDownSample(), Fill(), FillObject(), cloudViewer::t::geometry::npp::Filter(), cloudViewer::t::geometry::ipp::Filter(), cloudViewer::t::geometry::ipp::FilterBilateral(), cloudViewer::t::geometry::npp::FilterBilateral(), cloudViewer::t::geometry::ipp::FilterGaussian(), cloudViewer::t::geometry::ipp::FilterSobel(), cloudViewer::t::geometry::npp::FilterSobel(), cloudViewer::core::TensorList::FromTensor(), cloudViewer::t::io::GenerateHeader(), cloudViewer::t::pipelines::slac::GetCorrespondenceSetForPointCloudPair(), cloudViewer::core::nns::NNSIndex::GetDtype(), cloudViewer::core::TensorList::GetDtype(), cloudViewer::t::geometry::Image::GetDtype(), cloudViewer::t::pipelines::registration::GetInformationMatrix(), cloudViewer::core::HashBackendBuffer::GetKeyDsize(), cloudViewer::t::geometry::TriangleMesh::GetNonManifoldEdges(), IndexAdd_(), cloudViewer::core::kernel::IndexAddCPU_(), cloudViewer::core::kernel::IndexAddSYCL_(), IndexGet(), cloudViewer::core::kernel::IndexGet(), cloudViewer::core::kernel::IndexGetCPU(), cloudViewer::core::kernel::IndexGetSYCL(), IndexSet(), cloudViewer::core::kernel::IndexSetCPU(), cloudViewer::core::kernel::IndexSetSYCL(), cloudViewer::t::geometry::kernel::voxel_grid::Integrate(), cloudViewer::core::Inverse(), IsClose(), cloudViewer::ml::contrib::KnnSearch(), cloudViewer::core::LeastSquares(), LeastSquares(), cloudViewer::t::geometry::VoxelBlockGrid::Load(), cloudViewer::core::LUIpiv(), cloudViewer::core::Matmul(), Matmul(), cloudViewer::core::Maximum(), cloudViewer::core::Minimum(), Mul(), Mul_(), cloudViewer::core::nns::NearestNeighborSearch::MultiRadiusSearch(), cloudViewer::t::pipelines::registration::MultiScaleICP(), cloudViewer::core::kernel::NonZeroCPU(), cloudViewer::core::kernel::NonZeroSYCL(), cloudViewer::core::operator-(), cloudViewer::core::operator/(), cloudViewer::t::geometry::OrientedBoundingBox::OrientedBoundingBox(), cloudViewer::core::OutputToPLU(), cloudViewer::t::io::PackColorsToFloat(), cloudViewer::t::pipelines::kernel::PoseToTransformation(), cloudViewer::core::HashMap::PrepareIndicesOutput(), cloudViewer::core::HashMap::PrepareMasksOutput(), cloudViewer::core::pybind_core_tensor(), cloudViewer::ml::contrib::RadiusSearch(), cloudViewer::t::io::ReadHashMap(), cloudViewer::core::kernel::ReductionCPU(), cloudViewer::core::kernel::ReductionSYCL(), cloudViewer::t::geometry::ipp::Remap(), cloudViewer::t::geometry::PointCloud::RemoveDuplicatedPoints(), cloudViewer::t::geometry::TriangleMesh::RemoveNonManifoldEdges(), cloudViewer::t::geometry::TriangleMesh::RemoveUnreferencedVertices(), cloudViewer::t::geometry::npp::Resize(), cloudViewer::t::geometry::ipp::Resize(), cloudViewer::t::geometry::ipp::RGBToGray(), cloudViewer::t::geometry::npp::RGBToGray(), cloudViewer::t::pipelines::kernel::RtToTransformation(), cloudViewer::t::geometry::TriangleMesh::SamplePointsUniformly(), cloudViewer::t::geometry::kernel::trianglemesh::SamplePointsUniformlyCPU(), cloudViewer::t::geometry::TriangleMesh::SelectByIndex(), cloudViewer::t::geometry::TriangleMesh::SelectFacesByMask(), cloudViewer::io::rpc::SetMeshData(), cloudViewer::t::io::DepthNoiseSimulator::Simulate(), cloudViewer::core::Solve(), Solve(), Sub(), Sub_(), cloudViewer::ml::contrib::Subsample(), cloudViewer::ml::contrib::SubsampleBatch(), cloudViewer::core::SVD(), cloudViewer::t::geometry::kernel::TArrayIndexer< index_t >::TArrayIndexer(), cloudViewer::core::TensorList::TensorList(), cloudViewer::core::TensorRef::TensorRef(), cloudViewer::core::eigen_converter::TensorToEigenVectorNxVector(), cloudViewer::core::TensorToPyArray(), cloudViewer::visualization::rendering::TLineSetBuffersBuilder::TLineSetBuffersBuilder(), cloudViewer::visualization::rendering::TMeshBuffersBuilder::TMeshBuffersBuilder(), cloudViewer::t::geometry::ipp::To(), ToFlatVector(), cloudViewer::t::geometry::PointCloud::ToLegacy(), cloudViewer::t::geometry::TensorMap::ToString(), cloudViewer::core::ToTensorKey(), cloudViewer::visualization::rendering::TPointCloudBuffersBuilder::TPointCloudBuffersBuilder(), cloudViewer::t::geometry::Transform(), cloudViewer::t::pipelines::kernel::TransformationToPose(), cloudViewer::core::Tril(), cloudViewer::core::TrilCPU(), cloudViewer::core::TrilSYCL(), cloudViewer::core::Triu(), cloudViewer::core::TriuCPU(), cloudViewer::core::Triul(), cloudViewer::core::TriulCPU(), cloudViewer::core::TriulSYCL(), cloudViewer::core::TriuSYCL(), cloudViewer::core::kernel::UnaryEW(), cloudViewer::core::kernel::UnaryEWCPU(), cloudViewer::core::kernel::UnaryEWSYCL(), and cloudViewer::t::io::WriteNpzOneTensor().

◆ GetItem() [1/2]

Tensor cloudViewer::core::Tensor::GetItem ( const std::vector< TensorKey > &  tks) const

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:

t = np.empty((4, 5), dtype=np.float32)
t1 = t[1, 0:4:2]

The equivalent CloudViewer C++ calls:

Tensor t({4, 5}, core::Float32);
Tensor t1 = t.GetItem({TensorIndex(2), TensorSlice(0, 4, 2)});
const Dtype Float32
Definition: Dtype.cpp:42

Definition at line 489 of file Tensor.cpp.

References GetDevice(), cloudViewer::core::TensorKey::GetIndex(), cloudViewer::core::TensorKey::GetIndexTensor(), GetItem(), cloudViewer::core::TensorKey::GetMode(), cloudViewer::core::TensorKey::GetStart(), cloudViewer::core::TensorKey::GetStep(), cloudViewer::core::TensorKey::GetStop(), cloudViewer::core::TensorKey::Index, IndexExtract(), IndexGet(), cloudViewer::core::TensorKey::IndexTensor, cloudViewer::core::TensorKey::InstantiateDimSize(), cloudViewer::core::Int64, LogError, cloudViewer::core::None, shape_, Slice(), cloudViewer::core::TensorKey::Slice(), and Tensor().

◆ GetItem() [2/2]

Tensor cloudViewer::core::Tensor::GetItem ( const TensorKey tk) const

◆ GetLength()

int64_t cloudViewer::core::Tensor::GetLength ( ) const
inline

Returns the size of the first dimension. If NumDims() == 0, an exception will be thrown.

Definition at line 1125 of file Tensor.h.

References cloudViewer::core::SizeVector::GetLength(), and GetShape().

Referenced by cloudViewer::core::HashMap::Activate(), cloudViewer::t::geometry::RaycastingScene::AddTriangles(), cloudViewer::t::geometry::PointCloud::Append(), cloudViewer::core::kernel::ArangeCPU(), cloudViewer::core::kernel::ArangeSYCL(), cloudViewer::t::pipelines::registration::AssertValidCorrespondences(), cloudViewer::t::geometry::TriangleMesh::BakeVertexAttrTextures(), cloudViewer::core::HashMap::CheckKeyLength(), cloudViewer::core::HashMap::CheckKeyValueLengthCompatibility(), cloudViewer::t::geometry::PointCloud::ComputeBoundaryPoints(), cloudViewer::t::geometry::PointCloud::ComputeConvexHull(), cloudViewer::t::pipelines::registration::ComputeDirectionVectors(), cloudViewer::t::pipelines::kernel::ComputeFPFHFeature(), cloudViewer::t::pipelines::registration::ComputeFPFHFeature(), cloudViewer::t::pipelines::kernel::ComputeFPFHFeatureCPU(), cloudViewer::t::pipelines::kernel::ComputeInformationMatrixCPU(), cloudViewer::t::pipelines::kernel::ComputePoseColoredICPCPU(), cloudViewer::t::pipelines::kernel::ComputePoseDopplerICPCPU(), cloudViewer::t::pipelines::kernel::ComputePosePointToPlaneCPU(), cloudViewer::t::pipelines::registration::ComputeRegistrationResult(), cloudViewer::t::pipelines::registration::TransformationEstimationPointToPoint::ComputeRMSE(), cloudViewer::t::pipelines::registration::TransformationEstimationPointToPlane::ComputeRMSE(), cloudViewer::t::pipelines::registration::TransformationEstimationForDopplerICP::ComputeRMSE(), cloudViewer::t::pipelines::kernel::ComputeRtPointToPoint(), cloudViewer::t::pipelines::kernel::ComputeRtPointToPointCPU(), cloudViewer::t::geometry::ComputeTriangleAreasHelper(), cloudViewer::t::geometry::TriangleMesh::ComputeTriangleNormals(), cloudViewer::t::geometry::kernel::uvunwrapping::ComputeUVAtlas(), cloudViewer::t::geometry::TriangleMesh::ComputeVertexNormals(), cloudViewer::t::geometry::kernel::trianglemesh::ComputeVertexNormalsCPU(), cloudViewer::visualization::rendering::TMeshBuffersBuilder::ConstructBuffers(), cloudViewer::t::pipelines::slac::ControlGrid::ControlGrid(), cloudViewer::t::pipelines::slac::ConvertCorrespondencesTargetIndexedToCx2Form(), cloudViewer::t::pipelines::registration::CorrespondencesFromFeatures(), cloudViewer::core::CPUResetHeap(), cloudViewer::core::HashMap::Erase(), cloudViewer::t::geometry::PointCloud::EstimateColorGradients(), cloudViewer::t::geometry::PointCloud::EstimateNormals(), cloudViewer::t::geometry::VoxelBlockGrid::ExtractTriangleMesh(), cloudViewer::t::geometry::PointCloud::FarthestPointDownSample(), cloudViewer::core::HashMap::Find(), cloudViewer::t::geometry::PointCloud::GaussianSplatGetSHOrder(), cloudViewer::t::io::GenerateHeader(), cloudViewer::core::HashBackendBuffer::GetCapacity(), cloudViewer::t::pipelines::slac::GetCorrespondenceSetForPointCloudPair(), cloudViewer::t::geometry::GetEdgeToTrianglesMap(), cloudViewer::t::pipelines::slac::ControlGrid::GetNeighborGridMap(), cloudViewer::t::geometry::VoxelBlockGrid::GetUniqueBlockCoordinates(), cloudViewer::t::geometry::VoxelBlockGrid::GetVoxelCoordinatesAndFlattenedIndices(), cloudViewer::t::geometry::VoxelBlockGrid::GetVoxelIndices(), cloudViewer::t::geometry::LineSet::HasLineAttr(), cloudViewer::t::geometry::LineSet::HasPointAttr(), cloudViewer::t::geometry::PointCloud::HasPointAttr(), cloudViewer::t::geometry::TriangleMesh::HasTriangleAttr(), cloudViewer::t::geometry::TriangleMesh::HasVertexAttr(), cloudViewer::t::geometry::PointCloud::HiddenPointRemoval(), cloudViewer::core::HashMap::Insert(), cloudViewer::core::HashMap::InsertImpl(), cloudViewer::ml::contrib::Iou3dCPU(), cloudViewer::ml::contrib::IouBevCPU(), cloudViewer::t::geometry::PointCloud::IsGaussianSplat(), cloudViewer::t::geometry::VoxelBlockGrid::Load(), cloudViewer::t::io::PackColorsToFloat(), cloudViewer::t::geometry::LineSet::PaintUniformColor(), cloudViewer::t::geometry::PointCloud::PaintUniformColor(), cloudViewer::t::pipelines::slac::ControlGrid::Parameterize(), cloudViewer::t::geometry::TriangleMesh::PCAPartition(), cloudViewer::core::HashMap::PrepareIndicesOutput(), cloudViewer::core::HashMap::PrepareMasksOutput(), cloudViewer::core::pybind_core_tensor(), cloudViewer::t::pipelines::registration::pybind_registration_class(), cloudViewer::t::geometry::PointCloud::RandomDownSample(), cloudViewer::t::io::ReadHashMap(), cloudViewer::t::io::ReadTriangleMesh(), cloudViewer::t::geometry::PointCloud::RemoveDuplicatedPoints(), cloudViewer::t::geometry::PointCloud::RemoveNonFinitePoints(), cloudViewer::t::geometry::PointCloud::RemoveRadiusOutliers(), cloudViewer::t::geometry::TriangleMesh::RemoveUnreferencedVertices(), cloudViewer::t::pipelines::slac::RunSLACOptimizerForFragments(), cloudViewer::t::pipelines::slac::SaveCorrespondencesForPointClouds(), cloudViewer::t::geometry::SelectByIndex(), cloudViewer::t::geometry::TriangleMesh::SelectByIndex(), cloudViewer::t::geometry::PointCloud::SelectByIndex(), cloudViewer::t::geometry::PointCloud::SelectByMask(), cloudViewer::t::geometry::TriangleMesh::SelectFacesByMask(), cloudViewer::core::eigen_converter::TensorToEigenVectorNxVector(), cloudViewer::t::geometry::PointCloud::ToString(), cloudViewer::t::geometry::TriangleMesh::ToString(), cloudViewer::t::pipelines::slac::ControlGrid::Touch(), cloudViewer::t::geometry::PointCloud::UniformDownSample(), cloudViewer::t::pipelines::slac::UpdateControlGrid(), cloudViewer::t::pipelines::slac::UpdatePoses(), cloudViewer::t::geometry::UpdateTriangleIndicesByVertexMask(), cloudViewer::t::pipelines::slac::VisualizeGridDeformation(), cloudViewer::t::pipelines::slac::VisualizePointCloudCorrespondences(), cloudViewer::t::geometry::PointCloud::VoxelDownSample(), cloudViewer::t::io::WritePCDData(), cloudViewer::t::io::WritePointCloud(), cloudViewer::t::io::WritePointCloudToPLY(), cloudViewer::t::io::WritePointCloudToPTS(), and cloudViewer::t::io::WritePointCloudToSPLAT().

◆ GetShape() [1/2]

SizeVector cloudViewer::core::Tensor::GetShape ( ) const
inline

Definition at line 1127 of file Tensor.h.

References shape_.

Referenced by cloudViewer::core::AddMM(), cloudViewer::core::tensor_check::AssertTensorShape_(), cloudViewer::t::pipelines::registration::AssertValidCorrespondences(), cloudViewer::core::kernel::BinaryEW(), cloudViewer::t::geometry::BufferRadiusNeighbors(), cloudViewer::core::nns::BuildSpatialHashTableCPU(), cloudViewer::t::geometry::RaycastingScene::CastRays(), cloudViewer::t::geometry::CheckExtrinsicTensor(), cloudViewer::core::CheckInput(), cloudViewer::t::geometry::CheckIntrinsicTensor(), cloudViewer::core::HashMap::CheckKeyCompatibility(), cloudViewer::core::HashMap::CheckValueCompatibility(), cloudViewer::t::geometry::RaycastingScene::ComputeClosestPoints(), cloudViewer::t::pipelines::registration::ComputeDirectionVectors(), cloudViewer::t::geometry::RaycastingScene::ComputeDistance(), cloudViewer::t::pipelines::kernel::ComputeFPFHFeature(), cloudViewer::t::pipelines::registration::ComputeFPFHFeature(), cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBJylanki(), cloudViewer::t::pipelines::odometry::ComputeOdometryResultHybrid(), cloudViewer::t::pipelines::odometry::ComputeOdometryResultIntensity(), cloudViewer::t::pipelines::odometry::ComputeOdometryResultPointToPlane(), cloudViewer::t::pipelines::kernel::ComputeRtPointToPoint(), cloudViewer::t::geometry::RaycastingScene::ComputeSignedDistance(), cloudViewer::core::kernel::Copy(), cloudViewer::core::kernel::CopyCPU(), cloudViewer::core::kernel::CopySYCL(), cloudViewer::t::geometry::RaycastingScene::CountIntersections(), cloudViewer::t::geometry::vtkutils::CreateLineSetFromVtkPolyData(), cloudViewer::t::geometry::vtkutils::CreateTriangleMeshFromVtkPolyData(), cloudViewer::t::geometry::vtkutils::CreateVtkCellArrayFromTensor(), cloudViewer::t::geometry::vtkutils::CreateVtkDataArrayFromTensor(), cloudViewer::t::geometry::vtkutils::CreateVtkImageDataFromTensor(), cloudViewer::core::Det(), Diag(), cloudViewer::t::geometry::ipp::Dilate(), cloudViewer::t::geometry::npp::Dilate(), cloudViewer::t::geometry::kernel::pointcloud::EstimateColorGradientsUsingKNNSearchCPU(), cloudViewer::t::geometry::kernel::pointcloud::EstimateCovariancesUsingKNNSearchCPU(), cloudViewer::t::geometry::npp::Filter(), cloudViewer::t::geometry::ipp::Filter(), cloudViewer::t::geometry::ipp::FilterBilateral(), cloudViewer::t::geometry::npp::FilterBilateral(), cloudViewer::t::geometry::ipp::FilterGaussian(), cloudViewer::t::geometry::ipp::FilterSobel(), cloudViewer::t::geometry::npp::FilterSobel(), cloudViewer::t::geometry::Image::FilterSobel(), cloudViewer::core::nns::FixedRadiusSearchCPU(), Flatten(), cloudViewer::core::TensorList::FromTensor(), cloudViewer::t::geometry::PointCloud::GaussianSplatGetSHOrder(), cloudViewer::t::geometry::Image::GetChannels(), cloudViewer::t::geometry::Image::GetCols(), cloudViewer::core::nns::NNSIndex::GetDatasetSize(), cloudViewer::core::nns::NNSIndex::GetDimension(), GetLength(), cloudViewer::t::geometry::Image::GetRows(), cloudViewer::t::geometry::Image::Image(), IndexAdd_(), cloudViewer::core::kernel::IndexAddSYCL_(), cloudViewer::core::kernel::IndexGet(), cloudViewer::core::Inverse(), IsClose(), cloudViewer::ml::contrib::KnnSearch(), cloudViewer::core::kernel::LaunchIndexReductionKernel(), cloudViewer::core::LeastSquares(), cloudViewer::t::geometry::RaycastingScene::ListIntersections(), cloudViewer::t::geometry::VoxelBlockGrid::Load(), cloudViewer::core::LU(), cloudViewer::core::LUIpiv(), cloudViewer::core::Matmul(), cloudViewer::core::Maximum(), cloudViewer::core::Minimum(), cloudViewer::core::OutputToPLU(), cloudViewer::core::pybind_core_linalg(), cloudViewer::t::geometry::pybind_image(), cloudViewer::ml::contrib::RadiusSearch(), cloudViewer::t::io::ReadHashMap(), cloudViewer::core::kernel::Reduction(), cloudViewer::t::geometry::ipp::Remap(), cloudViewer::t::geometry::PointCloud::RemoveStatisticalOutliers(), cloudViewer::t::geometry::npp::Resize(), cloudViewer::t::geometry::ipp::Resize(), cloudViewer::core::AdvancedIndexPreprocessor::RestrideIndexTensor(), cloudViewer::core::AdvancedIndexPreprocessor::RestrideTensor(), Reverse(), cloudViewer::t::geometry::ipp::RGBToGray(), cloudViewer::t::geometry::npp::RGBToGray(), cloudViewer::core::AdvancedIndexPreprocessor::RunPreprocess(), cloudViewer::t::geometry::kernel::trianglemesh::SamplePointsUniformlyCPU(), cloudViewer::core::nns::FixedRadiusIndex::SearchHybrid(), cloudViewer::core::nns::NanoFlannIndex::SearchHybrid(), cloudViewer::core::nns::KnnIndex::SearchKnn(), cloudViewer::core::nns::NanoFlannIndex::SearchKnn(), cloudViewer::core::nns::NanoFlannIndex::SearchRadius(), cloudViewer::core::nns::FixedRadiusIndex::SearchRadius(), cloudViewer::io::rpc::SetMeshData(), cloudViewer::core::nns::KnnIndex::SetTensorData(), cloudViewer::core::nns::NanoFlannIndex::SetTensorData(), cloudViewer::core::nns::FixedRadiusIndex::SetTensorData(), cloudViewer::core::Solve(), cloudViewer::ml::contrib::Subsample(), cloudViewer::ml::contrib::SubsampleBatch(), cloudViewer::core::SVD(), cloudViewer::t::geometry::kernel::TArrayIndexer< index_t >::TArrayIndexer(), cloudViewer::core::TensorList::TensorList(), cloudViewer::core::TensorRef::TensorRef(), cloudViewer::core::eigen_converter::TensorToEigenMatrix(), cloudViewer::core::TensorToPyArray(), cloudViewer::t::geometry::RaycastingScene::TestOcclusions(), cloudViewer::t::geometry::ipp::To(), cloudViewer::t::geometry::TensorMap::ToString(), cloudViewer::core::Tril(), cloudViewer::core::Triu(), cloudViewer::core::Triul(), cloudViewer::core::kernel::UnaryEW(), cloudViewer::t::io::WriteNpzOneTensor(), and cloudViewer::t::io::WritePointCloudToXYZI().

◆ GetShape() [2/2]

int64_t cloudViewer::core::Tensor::GetShape ( int64_t  dim) const
inline

Definition at line 1131 of file Tensor.h.

References NumDims(), shape_, and cloudViewer::core::shape_util::WrapDim().

◆ GetShapeRef()

const SizeVector& cloudViewer::core::Tensor::GetShapeRef ( ) const
inline

Definition at line 1129 of file Tensor.h.

References shape_.

◆ GetStride()

◆ GetStrides()

SizeVector cloudViewer::core::Tensor::GetStrides ( ) const
inline

◆ GetStridesRef()

const SizeVector& cloudViewer::core::Tensor::GetStridesRef ( ) const
inline

Definition at line 1137 of file Tensor.h.

References strides_.

◆ Gt() [1/2]

Tensor cloudViewer::core::Tensor::Gt ( const Tensor value) const

Element-wise greater-than of tensors, returning a new boolean tensor.

Definition at line 1554 of file Tensor.cpp.

References AssertTensorDevice, cloudViewer::core::kernel::BinaryEW(), cloudViewer::core::Bool, cloudViewer::core::shape_util::BroadcastedShape(), GetDevice(), cloudViewer::core::kernel::Gt, and shape_.

Referenced by Clip_(), Gt(), and operator>().

◆ Gt() [2/2]

Tensor cloudViewer::core::Tensor::Gt ( Scalar  value) const

◆ Gt_() [1/2]

Tensor cloudViewer::core::Tensor::Gt_ ( const Tensor value)

Element-wise greater-than of tensors, in-place. This operation won't change the tensor's dtype.

Definition at line 1572 of file Tensor.cpp.

References AssertTensorDevice, cloudViewer::core::kernel::BinaryEW(), GetDevice(), and cloudViewer::core::kernel::Gt.

Referenced by Gt_().

◆ Gt_() [2/2]

Tensor cloudViewer::core::Tensor::Gt_ ( Scalar  value)

◆ IndexAdd_()

void cloudViewer::core::Tensor::IndexAdd_ ( int64_t  dim,
const Tensor index,
const Tensor src 
)

Advanced in-place reduction by index.

See https://pytorch.org/docs/stable/generated/torch.Tensor.index_add_.html

self[index[i]] = operator(self[index[i]], src[i]).

Note: Only support 1D index and src tensors now.

Definition at line 991 of file Tensor.cpp.

References AssertTensorDtype, GetDtype(), GetShape(), cloudViewer::core::kernel::IndexAdd_(), cloudViewer::core::Int64, LogError, and NumDims().

Referenced by cloudViewer::t::geometry::PointCloud::VoxelDownSample().

◆ IndexExtract()

Tensor cloudViewer::core::Tensor::IndexExtract ( int64_t  dim,
int64_t  idx 
) const

◆ IndexGet()

Tensor cloudViewer::core::Tensor::IndexGet ( const std::vector< Tensor > &  index_tensors) const

Advanced indexing getter. This will always allocate a new Tensor.

We use the Numpy advanced indexing semantics, see: https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html

Definition at line 905 of file Tensor.cpp.

References AssertTensorDtype, AssertTensorShape, cloudViewer::core::Bool, Clone(), dtype_, GetDevice(), GetDtype(), cloudViewer::core::AdvancedIndexPreprocessor::GetIndexedShape(), cloudViewer::core::AdvancedIndexPreprocessor::GetIndexedStrides(), cloudViewer::core::AdvancedIndexPreprocessor::GetIndexTensors(), cloudViewer::core::AdvancedIndexPreprocessor::GetOutputShape(), cloudViewer::core::AdvancedIndexPreprocessor::GetTensor(), cloudViewer::core::kernel::IndexGet(), IsNonZero(), LogError, NumDims(), and Tensor().

Referenced by cloudViewer::t::geometry::BufferRadiusNeighbors(), cloudViewer::t::pipelines::registration::ComputeFPFHFeature(), cloudViewer::t::pipelines::registration::TransformationEstimationPointToPoint::ComputeRMSE(), cloudViewer::t::pipelines::registration::TransformationEstimationPointToPlane::ComputeRMSE(), cloudViewer::t::pipelines::registration::TransformationEstimationForColoredICP::ComputeRMSE(), cloudViewer::t::pipelines::registration::TransformationEstimationForDopplerICP::ComputeRMSE(), cloudViewer::t::pipelines::kernel::ComputeRtPointToPoint(), cloudViewer::visualization::rendering::TMeshBuffersBuilder::ConstructBuffers(), cloudViewer::t::pipelines::slac::ConvertCorrespondencesTargetIndexedToCx2Form(), cloudViewer::t::pipelines::registration::CorrespondencesFromFeatures(), cloudViewer::t::pipelines::slac::ControlGrid::Deform(), cloudViewer::t::pipelines::slac::FillInRigidAlignmentTerm(), cloudViewer::t::pipelines::kernel::FillInRigidAlignmentTermCPU(), cloudViewer::t::pipelines::slac::FillInSLACAlignmentTerm(), cloudViewer::t::pipelines::slac::GetCorrespondenceSetForPointCloudPair(), GetItem(), cloudViewer::t::geometry::VoxelBlockGrid::GetVoxelCoordinates(), cloudViewer::t::geometry::VoxelBlockGrid::GetVoxelIndices(), cloudViewer::core::OutputToPLU(), cloudViewer::t::pipelines::slac::ControlGrid::Parameterize(), cloudViewer::t::geometry::TriangleMesh::PCAPartition(), cloudViewer::t::io::ReadTriangleMeshUsingASSIMP(), cloudViewer::core::HashMap::Reserve(), Reverse(), cloudViewer::t::geometry::VoxelBlockGrid::Save(), cloudViewer::t::geometry::TriangleMesh::SelectByIndex(), cloudViewer::t::geometry::TriangleMesh::SelectFacesByMask(), cloudViewer::core::HashMap::To(), cloudViewer::t::pipelines::slac::VisualizePointCloudDeformation(), cloudViewer::t::pipelines::slac::VisualizePointCloudEmbedding(), and cloudViewer::t::io::WriteHashMap().

◆ IndexSet()

◆ Init() [1/4]

template<typename T >
static Tensor cloudViewer::core::Tensor::Init ( const std::initializer_list< std::initializer_list< std::initializer_list< T >>> &  in_list,
const Device device = Device("CPU:0") 
)
inlinestatic

Create a 3-D tensor with nested initializer list, e.g., core::Tensor::Init<float>({{{0, 1}, {2, 3}}, {{4, 5}, {6, 7}}});

Definition at line 302 of file Tensor.h.

◆ Init() [2/4]

template<typename T >
static Tensor cloudViewer::core::Tensor::Init ( const std::initializer_list< std::initializer_list< T >> &  in_list,
const Device device = Device("CPU:0") 
)
inlinestatic

Create a 2-D tensor with nested initializer list, e.g., core::Tensor::Init<float>({{0, 1, 2}, {3, 4, 5}});

Definition at line 293 of file Tensor.h.

◆ Init() [3/4]

template<typename T >
static Tensor cloudViewer::core::Tensor::Init ( const std::initializer_list< T > &  in_list,
const Device device = Device("CPU:0") 
)
inlinestatic

Create a 1-D tensor with initializer list, e.g., core::Tensor::Init<float>({0, 1, 2});

Definition at line 285 of file Tensor.h.

◆ Init() [4/4]

template<typename T >
static Tensor cloudViewer::core::Tensor::Init ( const T  val,
const Device device = Device("CPU:0") 
)
inlinestatic

Create a 0-D tensor (scalar) with given value, e.g., core::Tensor::Init<float>(0);

Definition at line 275 of file Tensor.h.

References Tensor(), and type.

Referenced by cloudViewer::core::pybind_getitem(), and cloudViewer::core::pybind_setitem().

◆ Inverse()

◆ IsClose()

Tensor cloudViewer::core::Tensor::IsClose ( const Tensor other,
double  rtol = 1e-5,
double  atol = 1e-8 
) const

Element-wise version of Tensor::AllClose().

  • If the device is not the same: throws exception.
  • If the dtype is not the same: throws exception.
  • If the shape is not the same: throws exception.
  • For each element in the returned tensor: abs(self - other) <= (atol + rtol * abs(other)).

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

Parameters
otherThe other tensor to compare with.
rtolRelative tolerance.
atolAbsolute tolerance.
Returns
A boolean tensor indicating where the tensor is close.

Definition at line 1900 of file Tensor.cpp.

References Abs(), AssertTensorDevice, AssertTensorDtype, AssertTensorShape, cloudViewer::core::Float64, GetDevice(), GetDtype(), GetShape(), and To().

Referenced by AllClose().

◆ IsContiguous()

◆ IsFinite()

Tensor cloudViewer::core::Tensor::IsFinite ( ) const

Element-wise check for finite values (not Inf or NaN) in a tensor, returning a new Boolean tensor. Non-floating point tensors return all True values.

Definition at line 1382 of file Tensor.cpp.

References cloudViewer::core::Bool, dtype_, cloudViewer::core::Float32, cloudViewer::core::Float64, GetDevice(), cloudViewer::core::kernel::IsFinite, Ones(), shape_, and cloudViewer::core::kernel::UnaryEW().

Referenced by cloudViewer::core::MakeOperation(), cloudViewer::core::pybind_core_tensor(), and cloudViewer::t::geometry::PointCloud::RemoveNonFinitePoints().

◆ IsInf()

Tensor cloudViewer::core::Tensor::IsInf ( ) const

Element-wise check for Infinity values in a tensor, returning a new Boolean tensor. Non-floating point tensors return all False values.

Definition at line 1372 of file Tensor.cpp.

References cloudViewer::core::Bool, dtype_, cloudViewer::core::Float32, cloudViewer::core::Float64, GetDevice(), cloudViewer::core::kernel::IsInf, shape_, cloudViewer::core::kernel::UnaryEW(), and Zeros().

Referenced by cloudViewer::core::MakeOperation(), cloudViewer::core::pybind_core_tensor(), and cloudViewer::t::geometry::PointCloud::RemoveNonFinitePoints().

◆ IsNan()

Tensor cloudViewer::core::Tensor::IsNan ( ) const

Element-wise check for NaN values in a tensor, returning a new Boolean tensor. Non-floating point tensors return all False values.

Definition at line 1362 of file Tensor.cpp.

References cloudViewer::core::Bool, dtype_, cloudViewer::core::Float32, cloudViewer::core::Float64, GetDevice(), cloudViewer::core::kernel::IsNan, shape_, cloudViewer::core::kernel::UnaryEW(), and Zeros().

Referenced by cloudViewer::core::MakeOperation(), cloudViewer::core::pybind_core_tensor(), and cloudViewer::t::geometry::PointCloud::RemoveNonFinitePoints().

◆ IsNonZero()

bool cloudViewer::core::Tensor::IsNonZero ( ) const

Evaluate a single-element Tensor as a boolean value. This can be used to implement Tensor.__bool__() in Python, e.g.

assert Tensor([True]) # Passes.
assert Tensor([123]) # Passes.
assert Tensor([False]) # AssertionError.
assert Tensor([0]) # AssertionError.
assert Tensor([True, False]) # ValueError: cannot be evaluated as bool.

Definition at line 1757 of file Tensor.cpp.

References DISPATCH_DTYPE_TO_TEMPLATE_WITH_BOOL, dtype_, LogError, cloudViewer::core::SizeVector::NumElements(), and shape_.

Referenced by IndexGet(), IndexSet(), and cloudViewer::core::pybind_core_tensor().

◆ IsSame()

bool cloudViewer::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.

Definition at line 1912 of file Tensor.cpp.

References AssertTensorDevice, blob_, data_ptr_, dtype_, GetDevice(), shape_, and strides_.

◆ Item() [1/2]

◆ Item() [2/2]

template<>
bool cloudViewer::core::Tensor::Item ( ) const
inline

◆ Le() [1/2]

◆ Le() [2/2]

Tensor cloudViewer::core::Tensor::Le ( Scalar  value) const

◆ Le_() [1/2]

Tensor cloudViewer::core::Tensor::Le_ ( const Tensor value)

Element-wise less-than-or-equals-to of tensors, in-place. This operation won't change the tensor's dtype.

Definition at line 1668 of file Tensor.cpp.

References AssertTensorDevice, cloudViewer::core::kernel::BinaryEW(), GetDevice(), and cloudViewer::core::kernel::Le.

Referenced by Le_().

◆ Le_() [2/2]

Tensor cloudViewer::core::Tensor::Le_ ( Scalar  value)

◆ LeastSquares()

Tensor cloudViewer::core::Tensor::LeastSquares ( const Tensor rhs) const

Solves the linear system AX = B with QR decomposition and returns X. A is a (m, n) matrix with m >= n.

Definition at line 1938 of file Tensor.cpp.

References AssertTensorDevice, AssertTensorDtype, AssertTensorDtypes, cloudViewer::core::Float32, cloudViewer::core::Float64, GetDevice(), GetDtype(), and cloudViewer::core::LeastSquares().

Referenced by cloudViewer::core::pybind_core_tensor().

◆ Load()

Tensor cloudViewer::core::Tensor::Load ( const std::string &  file_name)
static

◆ LogicalAnd() [1/2]

Tensor cloudViewer::core::Tensor::LogicalAnd ( const Tensor value) const

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.

Definition at line 1453 of file Tensor.cpp.

References AssertTensorDevice, cloudViewer::core::kernel::BinaryEW(), cloudViewer::core::Bool, cloudViewer::core::shape_util::BroadcastedShape(), GetDevice(), cloudViewer::core::kernel::LogicalAnd, and shape_.

Referenced by LogicalAnd(), and operator&&().

◆ LogicalAnd() [2/2]

Tensor cloudViewer::core::Tensor::LogicalAnd ( Scalar  value) const

◆ LogicalAnd_() [1/2]

Tensor cloudViewer::core::Tensor::LogicalAnd_ ( const Tensor value)

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.

Definition at line 1472 of file Tensor.cpp.

References AssertTensorDevice, cloudViewer::core::kernel::BinaryEW(), GetDevice(), and cloudViewer::core::kernel::LogicalAnd.

Referenced by LogicalAnd_().

◆ LogicalAnd_() [2/2]

Tensor cloudViewer::core::Tensor::LogicalAnd_ ( Scalar  value)

◆ LogicalNot()

Tensor cloudViewer::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.

Definition at line 1442 of file Tensor.cpp.

References cloudViewer::core::Bool, GetDevice(), cloudViewer::core::kernel::LogicalNot, shape_, and cloudViewer::core::kernel::UnaryEW().

Referenced by cloudViewer::core::MakeOperation(), cloudViewer::core::pybind_core_tensor(), cloudViewer::t::geometry::PointCloud::RemoveNonFinitePoints(), and cloudViewer::t::geometry::PointCloud::SelectByMask().

◆ LogicalNot_()

Tensor cloudViewer::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.

Definition at line 1448 of file Tensor.cpp.

References cloudViewer::core::kernel::LogicalNot, and cloudViewer::core::kernel::UnaryEW().

Referenced by cloudViewer::core::pybind_core_tensor().

◆ LogicalOr() [1/2]

Tensor cloudViewer::core::Tensor::LogicalOr ( const Tensor value) const

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.

Definition at line 1487 of file Tensor.cpp.

References AssertTensorDevice, cloudViewer::core::kernel::BinaryEW(), cloudViewer::core::Bool, cloudViewer::core::shape_util::BroadcastedShape(), GetDevice(), cloudViewer::core::kernel::LogicalOr, and shape_.

Referenced by LogicalOr(), and operator||().

◆ LogicalOr() [2/2]

Tensor cloudViewer::core::Tensor::LogicalOr ( Scalar  value) const

◆ LogicalOr_() [1/2]

Tensor cloudViewer::core::Tensor::LogicalOr_ ( const Tensor value)

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.

Definition at line 1506 of file Tensor.cpp.

References AssertTensorDevice, cloudViewer::core::kernel::BinaryEW(), GetDevice(), and cloudViewer::core::kernel::LogicalOr.

Referenced by LogicalOr_().

◆ LogicalOr_() [2/2]

Tensor cloudViewer::core::Tensor::LogicalOr_ ( Scalar  value)

◆ LogicalXor() [1/2]

Tensor cloudViewer::core::Tensor::LogicalXor ( const Tensor value) const

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.

Definition at line 1520 of file Tensor.cpp.

References AssertTensorDevice, cloudViewer::core::kernel::BinaryEW(), cloudViewer::core::Bool, cloudViewer::core::shape_util::BroadcastedShape(), GetDevice(), cloudViewer::core::kernel::LogicalXor, and shape_.

Referenced by LogicalXor(), and cloudViewer::core::MakeOperation().

◆ LogicalXor() [2/2]

Tensor cloudViewer::core::Tensor::LogicalXor ( Scalar  value) const

◆ LogicalXor_() [1/2]

Tensor cloudViewer::core::Tensor::LogicalXor_ ( const Tensor value)

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.

Definition at line 1539 of file Tensor.cpp.

References AssertTensorDevice, cloudViewer::core::kernel::BinaryEW(), GetDevice(), and cloudViewer::core::kernel::LogicalXor.

Referenced by LogicalXor_().

◆ LogicalXor_() [2/2]

Tensor cloudViewer::core::Tensor::LogicalXor_ ( Scalar  value)

◆ Lt() [1/2]

Tensor cloudViewer::core::Tensor::Lt ( const Tensor value) const

Element-wise less-than of tensors, returning a new boolean tensor.

Definition at line 1586 of file Tensor.cpp.

References AssertTensorDevice, cloudViewer::core::kernel::BinaryEW(), cloudViewer::core::Bool, cloudViewer::core::shape_util::BroadcastedShape(), GetDevice(), cloudViewer::core::kernel::Lt, and shape_.

Referenced by Clip_(), Lt(), and operator<().

◆ Lt() [2/2]

Tensor cloudViewer::core::Tensor::Lt ( Scalar  value) const

◆ Lt_() [1/2]

Tensor cloudViewer::core::Tensor::Lt_ ( const Tensor value)

Element-wise less-than of tensors, in-place. This operation won't change the tensor's dtype.

Definition at line 1604 of file Tensor.cpp.

References AssertTensorDevice, cloudViewer::core::kernel::BinaryEW(), GetDevice(), and cloudViewer::core::kernel::Lt.

Referenced by Lt_().

◆ Lt_() [2/2]

Tensor cloudViewer::core::Tensor::Lt_ ( Scalar  value)

◆ LU()

std::tuple< Tensor, Tensor, Tensor > cloudViewer::core::Tensor::LU ( const bool  permute_l = false) const

Computes LU factorisation of the 2D square tensor, using A = P * L * U; where P is the permutation matrix, L is the lower-triangular matrix with diagonal elements as 1.0 and U is the upper-triangular matrix, and returns tuple (P, L, U).

Parameters
permute_l[optional input] If true: returns L as P * L.
Returns
Tuple (P, L, U).

Definition at line 1948 of file Tensor.cpp.

References AssertTensorDtypes, cloudViewer::core::Float32, cloudViewer::core::Float64, and cloudViewer::core::LU().

◆ LUIpiv()

std::tuple< Tensor, Tensor > cloudViewer::core::Tensor::LUIpiv ( ) const

Computes LU factorisation of the 2D square tensor, using A = P * L * U; where P is the permutation matrix, L is the lower-triangular matrix with diagonal elements as 1.0 and U is the upper-triangular matrix, and returns tuple output tensor of shape {n,n} and ipiv tensor of shape {n}, where {n,n} is the shape of input tensor. [ipiv, output = cloudViewer.core.lu_ipiv(a)].

Returns
Tuple {ipiv, output}. Where ipiv is a 1D integer pivort indices tensor. It contains the pivot indices, indicating row i of the matrix was interchanged with row ipiv(i)); and output it has L as lower triangular values and U as upper triangle values including the main diagonal (diagonal elements of L to be taken as unity).

Definition at line 1956 of file Tensor.cpp.

References AssertTensorDtypes, cloudViewer::core::Float32, cloudViewer::core::Float64, and cloudViewer::core::LUIpiv().

Referenced by cloudViewer::core::pybind_core_tensor().

◆ Matmul()

◆ Max()

Tensor cloudViewer::core::Tensor::Max ( const SizeVector dims,
bool  keepdim = false 
) const

◆ Mean()

Tensor cloudViewer::core::Tensor::Mean ( const SizeVector dims,
bool  keepdim = false 
) const

◆ Min()

Tensor cloudViewer::core::Tensor::Min ( const SizeVector dims,
bool  keepdim = false 
) const

◆ Mul() [1/2]

◆ Mul() [2/2]

Tensor cloudViewer::core::Tensor::Mul ( Scalar  value) const

◆ Mul_() [1/2]

◆ Mul_() [2/2]

Tensor cloudViewer::core::Tensor::Mul_ ( Scalar  value)

◆ Ne() [1/2]

◆ Ne() [2/2]

Tensor cloudViewer::core::Tensor::Ne ( Scalar  value) const

◆ Ne_() [1/2]

Tensor cloudViewer::core::Tensor::Ne_ ( const Tensor value)

Element-wise equals-to of tensors, in-place. This operation won't change the tensor's dtype.

Definition at line 1732 of file Tensor.cpp.

References AssertTensorDevice, cloudViewer::core::kernel::BinaryEW(), GetDevice(), and cloudViewer::core::kernel::Ne.

Referenced by Ne_().

◆ Ne_() [2/2]

Tensor cloudViewer::core::Tensor::Ne_ ( Scalar  value)

◆ Neg()

Tensor cloudViewer::core::Tensor::Neg ( ) const

◆ Neg_()

Tensor cloudViewer::core::Tensor::Neg_ ( )

◆ NonZero()

Tensor cloudViewer::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.

Definition at line 1755 of file Tensor.cpp.

References cloudViewer::core::kernel::NonZero().

Referenced by cloudViewer::t::pipelines::registration::ComputeFPFHFeature(), and cloudViewer::t::pipelines::kernel::ComputeFPFHFeatureCPU().

◆ NonZeroNumpy()

std::vector< Tensor > cloudViewer::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.

Definition at line 1746 of file Tensor.cpp.

References Clone(), cloudViewer::core::kernel::NonZero(), NumDims(), and result.

◆ NumDims()

◆ NumElements()

◆ Ones()

◆ operator!=()

Tensor cloudViewer::core::Tensor::operator!= ( const Tensor value) const
inline

Definition at line 922 of file Tensor.h.

References Ne().

◆ operator&&()

Tensor cloudViewer::core::Tensor::operator&& ( const Tensor value) const
inline

Definition at line 822 of file Tensor.h.

References LogicalAnd().

◆ operator*() [1/2]

Tensor cloudViewer::core::Tensor::operator* ( const Tensor value) const
inline

Definition at line 659 of file Tensor.h.

References Mul().

◆ operator*() [2/2]

Tensor cloudViewer::core::Tensor::operator* ( Scalar  value) const
inline

Definition at line 660 of file Tensor.h.

References Mul().

◆ operator*=() [1/2]

Tensor cloudViewer::core::Tensor::operator*= ( const Tensor value)
inline

Definition at line 666 of file Tensor.h.

References Mul_().

◆ operator*=() [2/2]

Tensor cloudViewer::core::Tensor::operator*= ( Scalar  value)
inline

Definition at line 667 of file Tensor.h.

References Mul_().

◆ operator+() [1/2]

Tensor cloudViewer::core::Tensor::operator+ ( const Tensor value) const
inline

Definition at line 633 of file Tensor.h.

References Add().

◆ operator+() [2/2]

Tensor cloudViewer::core::Tensor::operator+ ( Scalar  value) const
inline

Definition at line 634 of file Tensor.h.

References Add().

◆ operator+=() [1/2]

Tensor cloudViewer::core::Tensor::operator+= ( const Tensor value)
inline

Definition at line 640 of file Tensor.h.

References Add_().

◆ operator+=() [2/2]

Tensor cloudViewer::core::Tensor::operator+= ( Scalar  value)
inline

Definition at line 641 of file Tensor.h.

References Add_().

◆ operator-() [1/3]

Tensor cloudViewer::core::Tensor::operator- ( ) const
inline

Unary minus of a tensor, returning a new tensor.

Definition at line 752 of file Tensor.h.

References Neg().

◆ operator-() [2/3]

Tensor cloudViewer::core::Tensor::operator- ( const Tensor value) const
inline

Definition at line 646 of file Tensor.h.

References Sub().

◆ operator-() [3/3]

Tensor cloudViewer::core::Tensor::operator- ( Scalar  value) const
inline

Definition at line 647 of file Tensor.h.

References Sub().

◆ operator-=() [1/2]

Tensor cloudViewer::core::Tensor::operator-= ( const Tensor value)
inline

Definition at line 653 of file Tensor.h.

References Sub_().

◆ operator-=() [2/2]

Tensor cloudViewer::core::Tensor::operator-= ( Scalar  value)
inline

Definition at line 654 of file Tensor.h.

References Sub_().

◆ operator/() [1/2]

Tensor cloudViewer::core::Tensor::operator/ ( const Tensor value) const
inline

Definition at line 672 of file Tensor.h.

References Div().

◆ operator/() [2/2]

Tensor cloudViewer::core::Tensor::operator/ ( Scalar  value) const
inline

Definition at line 673 of file Tensor.h.

References Div().

◆ operator/=() [1/2]

Tensor cloudViewer::core::Tensor::operator/= ( const Tensor value)
inline

Definition at line 679 of file Tensor.h.

References Div_().

◆ operator/=() [2/2]

Tensor cloudViewer::core::Tensor::operator/= ( Scalar  value)
inline

Definition at line 680 of file Tensor.h.

References Div_().

◆ operator<()

Tensor cloudViewer::core::Tensor::operator< ( const Tensor value) const
inline

Definition at line 880 of file Tensor.h.

References Lt().

◆ operator<=()

Tensor cloudViewer::core::Tensor::operator<= ( const Tensor value) const
inline

Definition at line 902 of file Tensor.h.

References Le().

◆ operator=() [1/5]

template<typename T >
Tensor& cloudViewer::core::Tensor::operator= ( const T  v) &&
inline

Tensor assignment rvalue = scalar, e.g. tensor_a[0] = 100 Implicit casting is performed to the underlying dtype.

Note that we don't have lvalue = scalar, e.g. we don't support Tensor a_slice = tensor_a[0]; a_slice = 100;

Definition at line 205 of file Tensor.h.

References Fill().

◆ operator=() [2/5]

Tensor & cloudViewer::core::Tensor::operator= ( const Tensor other) &

Tensor assignment lvalue = lvalue, e.g. tensor_a = tensor_b. This results in a "shallow" copy.

Definition at line 355 of file Tensor.cpp.

References blob_, data_ptr_, dtype_, shape_, and strides_.

◆ operator=() [3/5]

Tensor & cloudViewer::core::Tensor::operator= ( const Tensor other) &&

Tensor assignment rvalue = lvalue, e.g. tensor_a[0] = tensor_b.

Tensor assignment rvalue = lvalue, e.g. tensor_a[0] = tensor_b. An actual copy of the data will be performed.

Definition at line 377 of file Tensor.cpp.

References cloudViewer::core::kernel::Copy().

◆ operator=() [4/5]

Tensor & cloudViewer::core::Tensor::operator= ( Tensor &&  other) &

Tensor assignment lvalue = rvalue, e.g. tensor_a = tensor_b[0]. This results in a "shallow" copy.

Definition at line 367 of file Tensor.cpp.

References blob_, data_ptr_, dtype_, shape_, and strides_.

◆ operator=() [5/5]

Tensor & cloudViewer::core::Tensor::operator= ( Tensor &&  other) &&

Tensor assignment rvalue = rvalue, e.g. tensor_a[0] = tensor_b[0].

Tensor assignment rvalue = rvalue, e.g. tensor_a[0] = tensor_b[0]. An actual copy of the data will be performed.

Definition at line 383 of file Tensor.cpp.

References cloudViewer::core::kernel::Copy().

◆ operator==()

Tensor cloudViewer::core::Tensor::operator== ( const Tensor value) const
inline

Definition at line 912 of file Tensor.h.

References Eq().

◆ operator>()

Tensor cloudViewer::core::Tensor::operator> ( const Tensor value) const
inline

Definition at line 870 of file Tensor.h.

References Gt().

◆ operator>=()

Tensor cloudViewer::core::Tensor::operator>= ( const Tensor value) const
inline

Definition at line 891 of file Tensor.h.

References Ge().

◆ operator[]()

Tensor cloudViewer::core::Tensor::operator[] ( int64_t  i) const

Extract the i-th Tensor along the first axis, returning a new view.

Definition at line 839 of file Tensor.cpp.

References IndexExtract().

Referenced by ToString().

◆ operator||()

Tensor cloudViewer::core::Tensor::operator|| ( const Tensor value) const
inline

Definition at line 839 of file Tensor.h.

References LogicalOr().

◆ Permute()

Tensor cloudViewer::core::Tensor::Permute ( const SizeVector dims) const

Permute (dimension shuffle) the Tensor, returns a view.

Parameters
dimsThe desired ordering of dimensions.
Returns
A Tensor with the desired ordering of the dimensions.

Definition at line 1028 of file Tensor.cpp.

References AsStrided(), LogError, NumDims(), shape_, cloudViewer::core::SmallVectorBase< Size_T >::size(), strides_, and cloudViewer::core::shape_util::WrapDim().

Referenced by cloudViewer::core::kernel::IndexAdd_(), cloudViewer::t::geometry::TriangleMesh::ProjectImagesToAlbedo(), cloudViewer::core::AdvancedIndexPreprocessor::ShuffleIndexedDimsToFront(), and Transpose().

◆ Prod()

Tensor cloudViewer::core::Tensor::Prod ( const SizeVector dims,
bool  keepdim = false 
) const

Returns the product of the tensor along the given dims.

Parameters
dimsA list of dimensions to be reduced.
keepdimIf true, the reduced dims will be retained as size 1.

Definition at line 1261 of file Tensor.cpp.

References dtype_, GetDevice(), cloudViewer::core::kernel::Prod, cloudViewer::core::kernel::Reduction(), cloudViewer::core::shape_util::ReductionShape(), and shape_.

Referenced by cloudViewer::t::geometry::AxisAlignedBoundingBox::Volume(), and cloudViewer::t::geometry::OrientedBoundingBox::Volume().

◆ ReinterpretCast()

Tensor cloudViewer::core::Tensor::ReinterpretCast ( const core::Dtype dtype) const

Tensor reinterpret cast operator. It changes the tensor's dtype without changing the underlying memory blob itself. The byte-size of dtype must be same as the original dtype before casting.

Definition at line 388 of file Tensor.cpp.

References blob_, cloudViewer::core::Dtype::ByteSize(), data_ptr_, dtype_, LogError, shape_, strides_, Tensor(), and cloudViewer::core::Dtype::ToString().

Referenced by cloudViewer::t::geometry::PointCloud::RemoveDuplicatedPoints(), and cloudViewer::t::geometry::Image::Resize().

◆ Reshape()

Tensor cloudViewer::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:

Definition at line 671 of file Tensor.cpp.

References AsStrided(), Contiguous(), cloudViewer::core::shape_util::InferShape(), NumElements(), cloudViewer::core::shape_util::Restride(), shape_, strides_, and View().

Referenced by cloudViewer::t::geometry::ComputeMetricsCommon(), cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBApprox(), cloudViewer::t::pipelines::registration::TransformationEstimationPointToPoint::ComputeRMSE(), cloudViewer::t::pipelines::registration::TransformationEstimationPointToPlane::ComputeRMSE(), cloudViewer::t::pipelines::registration::TransformationEstimationForColoredICP::ComputeRMSE(), cloudViewer::t::pipelines::registration::TransformationEstimationForDopplerICP::ComputeRMSE(), cloudViewer::t::pipelines::kernel::ComputeRtPointToPoint(), cloudViewer::t::pipelines::kernel::ComputeRtPointToPointCPU(), cloudViewer::core::Concatenate(), cloudViewer::t::pipelines::slac::ConvertCorrespondencesTargetIndexedToCx2Form(), cloudViewer::t::geometry::vtkutils::CreateLineSetFromVtkPolyData(), cloudViewer::t::geometry::vtkutils::CreateTriangleMeshFromVtkPolyData(), cloudViewer::t::geometry::vtkutils::CreateVtkCellArrayFromTensor(), cloudViewer::t::geometry::vtkutils::CreateVtkImageDataFromTensor(), Flatten(), cloudViewer::t::geometry::TriangleMesh::FromLegacy(), cloudViewer::t::geometry::AxisAlignedBoundingBox::GetBoxPoints(), cloudViewer::t::geometry::Image::Image(), cloudViewer::core::pybind_core_tensor(), cloudViewer::core::kernel::Reduction(), cloudViewer::core::AdvancedIndexPreprocessor::RestrideIndexTensor(), and cloudViewer::t::pipelines::kernel::RtToTransformation().

◆ Reverse()

Tensor cloudViewer::core::Tensor::Reverse ( ) const

Reverse a Tensor's elements by viewing the tensor as a 1D array.

Definition at line 465 of file Tensor.cpp.

References Arange(), GetShape(), IndexGet(), NumElements(), and View().

Referenced by cloudViewer::t::geometry::npp::Filter().

◆ Round()

Tensor cloudViewer::core::Tensor::Round ( ) const

◆ Save()

void cloudViewer::core::Tensor::Save ( const std::string &  file_name) const

Save tensor to numpy's npy format.

Definition at line 1877 of file Tensor.cpp.

References cloudViewer::t::io::WriteNpy().

Referenced by cloudViewer::core::pybind_core_tensor(), and cloudViewer::t::pipelines::slac::SaveCorrespondencesForPointClouds().

◆ ScalarPtrToString()

std::string cloudViewer::core::Tensor::ScalarPtrToString ( const void *  ptr) const
protected

◆ SetItem() [1/3]

Tensor cloudViewer::core::Tensor::SetItem ( const std::vector< TensorKey > &  tks,
const Tensor value 
)

Pythonic setitem for tensor.

For example, in numpy:

t = np.empty((4, 5), dtype=np.float32)
t[2, 0:4:2] = np.empty((2, 5), dtype=np.float32)

The equivalent CloudViewer C++ calls:

Tensor t({4, 5}, core::Float32);
t.SetItem({TensorIndex(2), TensorSlice(0, 4, 2)},
Tensor({2, 5}, core::Float32));

Definition at line 578 of file Tensor.cpp.

References GetDevice(), cloudViewer::core::TensorKey::GetIndex(), cloudViewer::core::TensorKey::GetIndexTensor(), GetItem(), cloudViewer::core::TensorKey::GetMode(), cloudViewer::core::TensorKey::Index, IndexSet(), cloudViewer::core::TensorKey::IndexTensor, cloudViewer::core::Int64, LogError, cloudViewer::core::None, cloudViewer::core::TensorKey::Slice(), and Tensor().

◆ SetItem() [2/3]

◆ SetItem() [3/3]

Tensor cloudViewer::core::Tensor::SetItem ( const TensorKey tk,
const Tensor value 
)

Pythonic setitem for tensor.

For example, in numpy:

t = np.empty((4, 5), dtype=np.float32)
t[2] = np.empty((5,), dtype=np.float32)
t[0:4:2] = np.empty((2, 5), dtype=np.float32)

The equivalent CloudViewer C++ calls:

Tensor t({4, 5}, core::Float32);
t.SetItem(TensorIndex(2), Tensor({5}, core::Float32));
t.SetItem(TensorSlice(0, 4, 2), Tensor({2, 5}, core::Float32));

Definition at line 569 of file Tensor.cpp.

References cloudViewer::core::TensorKey::GetIndexTensor(), GetItem(), cloudViewer::core::TensorKey::GetMode(), IndexSet(), and cloudViewer::core::TensorKey::IndexTensor.

◆ Sin()

Tensor cloudViewer::core::Tensor::Sin ( ) const

Element-wise sine of a tensor, returning a new tensor.

Definition at line 1307 of file Tensor.cpp.

References dtype_, GetDevice(), shape_, cloudViewer::core::kernel::Sin, and cloudViewer::core::kernel::UnaryEW().

Referenced by cloudViewer::core::MakeOperation(), and cloudViewer::core::pybind_core_tensor().

◆ Sin_()

Tensor cloudViewer::core::Tensor::Sin_ ( )

Element-wise sine of a tensor, in-place.

Definition at line 1313 of file Tensor.cpp.

References cloudViewer::core::kernel::Sin, and cloudViewer::core::kernel::UnaryEW().

Referenced by cloudViewer::core::pybind_core_tensor().

◆ Slice()

◆ Solve()

◆ Sqrt()

Tensor cloudViewer::core::Tensor::Sqrt ( ) const

◆ Sqrt_()

Tensor cloudViewer::core::Tensor::Sqrt_ ( )

Element-wise square root of a tensor, in-place.

Definition at line 1302 of file Tensor.cpp.

References cloudViewer::core::kernel::Sqrt, and cloudViewer::core::kernel::UnaryEW().

Referenced by cloudViewer::t::geometry::PointCloud::ComputeMetrics(), and cloudViewer::core::pybind_core_tensor().

◆ Sub() [1/2]

Tensor cloudViewer::core::Tensor::Sub ( const Tensor value) const

◆ Sub() [2/2]

Tensor cloudViewer::core::Tensor::Sub ( Scalar  value) const

◆ Sub_() [1/2]

Tensor cloudViewer::core::Tensor::Sub_ ( const Tensor value)

◆ Sub_() [2/2]

Tensor cloudViewer::core::Tensor::Sub_ ( Scalar  value)

◆ Sum()

◆ SVD()

std::tuple< Tensor, Tensor, Tensor > cloudViewer::core::Tensor::SVD ( ) const

Computes the matrix SVD decomposition A = U S VT and returns the result. Note VT (V transpose) is returned instead of V.

Definition at line 1990 of file Tensor.cpp.

References AssertTensorDtypes, cloudViewer::core::Float32, cloudViewer::core::Float64, and cloudViewer::core::SVD().

Referenced by cloudViewer::t::pipelines::kernel::ComputeRtPointToPoint(), cloudViewer::t::pipelines::kernel::ComputeRtPointToPointCPU(), and cloudViewer::core::pybind_core_tensor().

◆ T()

◆ To() [1/3]

Tensor cloudViewer::core::Tensor::To ( const Device device,
bool  copy = false 
) const

Returns a tensor with the specified device.

Parameters
deviceThe targeted device to convert to.
copyIf true, a new tensor is always created; if false, the copy is avoided when the original tensor is already on the targeted device.

Definition at line 753 of file Tensor.cpp.

References cloudViewer::core::kernel::Copy(), copy, dtype_, GetDevice(), and shape_.

◆ To() [2/3]

Tensor cloudViewer::core::Tensor::To ( const Device device,
Dtype  dtype,
bool  copy = false 
) const

Returns a tensor with the specified device and dtype.

Parameters
deviceThe targeted device to convert to.
dtypeThe targeted dtype to convert to.
copyIf true, a new tensor is always created; if false, the copy is avoided when the original tensor is already on the targeted device and have the targeted dtype.

Definition at line 762 of file Tensor.cpp.

References copy, and To().

◆ To() [3/3]

Tensor cloudViewer::core::Tensor::To ( Dtype  dtype,
bool  copy = false 
) const

Returns a tensor with the specified dtype.

Parameters
dtypeThe targeted dtype to convert to.
copyIf true, a new tensor is always created; if false, the copy is avoided when the original tensor already has the targeted dtype.

Definition at line 739 of file Tensor.cpp.

References cloudViewer::core::kernel::Copy(), copy, dtype_, GetDevice(), cloudViewer::core::Dtype::IsObject(), LogError, shape_, and cloudViewer::core::Dtype::ToString().

Referenced by cloudViewer::core::AddMM(), cloudViewer::t::geometry::RaycastingScene::AddTriangles(), cloudViewer::t::pipelines::registration::BenchmarkDopplerICP(), cloudViewer::t::geometry::BufferRadiusNeighbors(), cloudViewer::core::CastOptionalDtypeDevice(), Clone(), cloudViewer::t::pipelines::slac::ControlGrid::Compactify(), cloudViewer::t::geometry::ComputeBoundaryPoints(), cloudViewer::t::pipelines::kernel::ComputeFPFHFeature(), cloudViewer::t::pipelines::registration::ComputeFPFHFeature(), cloudViewer::t::pipelines::kernel::ComputeInformationMatrixCPU(), cloudViewer::t::geometry::PointCloud::ComputeMetrics(), cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBApprox(), cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBJylanki(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryInformationMatrix(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryResultHybrid(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryResultIntensity(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryResultPointToPlane(), cloudViewer::t::pipelines::kernel::ComputePoseDopplerICP(), cloudViewer::t::pipelines::registration::ComputeRegistrationResult(), cloudViewer::t::pipelines::kernel::ComputeRtPointToPoint(), cloudViewer::t::pipelines::kernel::ComputeRtPointToPointCPU(), cloudViewer::t::geometry::kernel::trianglemesh::ComputeTriangleAreasCPU(), cloudViewer::t::geometry::kernel::trianglemesh::ComputeTriangleNormalsCPU(), cloudViewer::t::geometry::kernel::uvunwrapping::ComputeUVAtlas(), cloudViewer::t::geometry::kernel::trianglemesh::ComputeVertexNormalsCPU(), cloudViewer::visualization::rendering::TMeshBuffersBuilder::ConstructBuffers(), Contiguous(), cloudViewer::t::io::ConvertColorTensorToUint8(), cloudViewer::core::kernel::CopyCPU(), cloudViewer::core::kernel::CopySYCL(), cloudViewer::t::geometry::TriangleMesh::CreateBox(), cloudViewer::t::geometry::LineSet::CreateCameraVisualization(), cloudViewer::t::geometry::PointCloud::CreateFromDepthImage(), cloudViewer::t::geometry::RaycastingScene::CreateRaysPinhole(), cloudViewer::t::geometry::kernel::image::CreateVertexMap(), cloudViewer::t::pipelines::kernel::DecodeAndSolve6x6(), cloudViewer::core::Det(), cloudViewer::t::pipelines::registration::DoSingleScaleICPIterations(), cloudViewer::core::eigen_converter::EigenVectorNxVectorToTensor(), cloudViewer::t::geometry::kernel::pointcloud::EstimateColorGradientsUsingKNNSearchCPU(), cloudViewer::t::geometry::kernel::pointcloud::EstimateColorGradientsUsingRadiusSearchCPU(), cloudViewer::t::geometry::EstimateNormals(), cloudViewer::t::geometry::kernel::voxel_grid::EstimateRange(), cloudViewer::t::geometry::VoxelBlockGrid::ExtractTriangleMesh(), cloudViewer::t::geometry::vtkutils::ExtrudeLinearPolyData(), cloudViewer::t::geometry::vtkutils::ExtrudeRotationPolyData(), cloudViewer::t::pipelines::slac::FillInRigidAlignmentTerm(), cloudViewer::t::pipelines::slac::FillInSLACAlignmentTerm(), cloudViewer::t::geometry::AxisAlignedBoundingBox::FromLegacy(), cloudViewer::t::geometry::OrientedBoundingBox::FromLegacy(), cloudViewer::io::rpc::messages::Array::FromTensor(), cloudViewer::core::GetColPermutation(), cloudViewer::t::pipelines::slac::GetCorrespondenceSetForPointCloudPair(), cloudViewer::t::pipelines::registration::GetInformationMatrix(), cloudViewer::t::pipelines::slac::ControlGrid::GetNeighborGridMap(), cloudViewer::t::geometry::TriangleMesh::GetNonManifoldEdges(), cloudViewer::t::geometry::AxisAlignedBoundingBox::GetPointIndicesWithinBoundingBox(), cloudViewer::t::geometry::OrientedBoundingBox::GetPointIndicesWithinBoundingBox(), cloudViewer::t::geometry::VoxelBlockGrid::GetVoxelCoordinates(), cloudViewer::t::geometry::AxisAlignedBoundingBox::GetXPercentage(), cloudViewer::t::geometry::AxisAlignedBoundingBox::GetYPercentage(), cloudViewer::t::geometry::AxisAlignedBoundingBox::GetZPercentage(), cloudViewer::core::kernel::IndexSet(), cloudViewer::core::Inverse(), IsClose(), cloudViewer::ml::contrib::KnnSearch(), cloudViewer::t::geometry::RaycastingScene::ListIntersections(), cloudViewer::t::geometry::VoxelBlockGrid::Load(), cloudViewer::t::pipelines::registration::LoadTensorDopplerPointCloudFromFile(), cloudViewer::t::pipelines::registration::LoadTensorPointCloudFromFile(), cloudViewer::core::Matmul(), cloudViewer::t::pipelines::registration::MultiScaleICP(), cloudViewer::t::io::NumpyArray::NumpyArray(), cloudViewer::t::geometry::PointCloud::OrientNormalsToAlignWithDirection(), cloudViewer::t::geometry::PointCloud::OrientNormalsTowardsCameraLocation(), cloudViewer::t::pipelines::slac::ControlGrid::Parameterize(), cloudViewer::t::geometry::TriangleMesh::PCAPartition(), cloudViewer::t::geometry::PointCloud::PCAPartition(), cloudViewer::t::geometry::kernel::pointcloud::Project(), cloudViewer::core::pybind_core_tensor(), cloudViewer::ml::contrib::RadiusSearch(), cloudViewer::benchmarks::Rand(), cloudViewer::t::geometry::TriangleMesh::RemoveNonManifoldEdges(), cloudViewer::t::geometry::PointCloud::RemoveRadiusOutliers(), cloudViewer::t::geometry::TriangleMesh::RemoveUnreferencedVertices(), cloudViewer::core::HashMap::Reserve(), cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScale(), cloudViewer::t::geometry::OrientedBoundingBox::Rotate(), cloudViewer::t::geometry::kernel::transform::RotateNormals(), cloudViewer::t::geometry::kernel::transform::RotatePoints(), cloudViewer::t::geometry::TriangleMesh::SamplePointsUniformly(), cloudViewer::t::geometry::VoxelBlockGrid::Save(), cloudViewer::t::geometry::LineSet::Scale(), cloudViewer::t::geometry::PointCloud::Scale(), cloudViewer::t::geometry::TriangleMesh::Scale(), cloudViewer::t::geometry::AxisAlignedBoundingBox::Scale(), cloudViewer::t::geometry::OrientedBoundingBox::Scale(), cloudViewer::core::nns::FixedRadiusIndex::SearchRadius(), cloudViewer::core::nns::NanoFlannIndex::SearchRadius(), cloudViewer::t::geometry::TriangleMesh::SelectByIndex(), cloudViewer::t::geometry::TriangleMesh::SelectFacesByMask(), cloudViewer::t::geometry::OrientedBoundingBox::SetCenter(), cloudViewer::t::pipelines::slam::Frame::SetData(), cloudViewer::t::geometry::OrientedBoundingBox::SetExtent(), cloudViewer::t::geometry::AxisAlignedBoundingBox::SetMaxBound(), cloudViewer::t::geometry::AxisAlignedBoundingBox::SetMinBound(), cloudViewer::t::geometry::OrientedBoundingBox::SetRotation(), cloudViewer::t::io::DepthNoiseSimulator::Simulate(), cloudViewer::core::eigen_converter::TensorToEigenMatrix(), cloudViewer::core::eigen_converter::TensorToEigenVectorNxVector(), cloudViewer::visualization::rendering::TLineSetBuffersBuilder::TLineSetBuffersBuilder(), cloudViewer::visualization::rendering::TMeshBuffersBuilder::TMeshBuffersBuilder(), cloudViewer::t::geometry::AxisAlignedBoundingBox::To(), cloudViewer::t::geometry::OrientedBoundingBox::To(), cloudViewer::t::geometry::Image::To(), cloudViewer::core::HashMap::To(), To(), cloudViewer::t::geometry::PointCloud::ToLegacy(), ToString(), cloudViewer::core::ToTensorKey(), cloudViewer::t::pipelines::slac::ControlGrid::Touch(), cloudViewer::visualization::rendering::TPointCloudBuffersBuilder::TPointCloudBuffersBuilder(), cloudViewer::t::geometry::OrientedBoundingBox::Transform(), cloudViewer::t::geometry::kernel::transform::TransformNormals(), cloudViewer::t::geometry::kernel::transform::TransformPoints(), cloudViewer::t::geometry::AxisAlignedBoundingBox::Translate(), cloudViewer::t::geometry::OrientedBoundingBox::Translate(), cloudViewer::t::geometry::LineSet::Translate(), cloudViewer::t::geometry::PointCloud::Translate(), cloudViewer::t::geometry::TriangleMesh::Translate(), cloudViewer::t::geometry::kernel::pointcloud::Unproject(), cloudViewer::t::pipelines::slac::UpdatePoses(), cloudViewer::t::pipelines::slac::VisualizeGridDeformation(), cloudViewer::t::pipelines::slac::VisualizePointCloudCorrespondences(), cloudViewer::t::geometry::PointCloud::VoxelDownSample(), cloudViewer::t::io::WriteHashMap(), cloudViewer::t::io::WriteNpz(), and cloudViewer::t::io::WritePointCloudToPTS().

◆ ToDLPack()

DLManagedTensor * cloudViewer::core::Tensor::ToDLPack ( ) const

Convert the Tensor to DLManagedTensor (DLPack v0.x).

Definition at line 1808 of file Tensor.cpp.

References cloudViewer::core::Open3DDLManagedTensor< DLMT >::Create().

◆ ToDLPackVersioned()

DLManagedTensorVersioned * cloudViewer::core::Tensor::ToDLPackVersioned ( ) const

Convert the Tensor to DLManagedTensorVersioned (DLPack v1.x).

Definition at line 1811 of file Tensor.cpp.

References cloudViewer::core::Open3DDLManagedTensor< DLMT >::Create().

◆ ToFlatVector() [1/2]

template<typename T >
std::vector<T> cloudViewer::core::Tensor::ToFlatVector ( ) const
inline

Retrieve all values as an std::vector, for debugging and testing.

Definition at line 1025 of file Tensor.h.

References Contiguous(), GetDataPtr(), GetDevice(), GetDtype(), cloudViewer::core::MemoryManager::MemcpyToHost(), and NumElements().

Referenced by cloudViewer::ml::contrib::Subsample(), and cloudViewer::ml::contrib::SubsampleBatch().

◆ ToFlatVector() [2/2]

template<>
std::vector<bool> cloudViewer::core::Tensor::ToFlatVector ( ) const
inline

◆ ToString()

◆ Transpose()

Tensor cloudViewer::core::Tensor::Transpose ( int64_t  dim0,
int64_t  dim1 
) const

Transpose a Tensor by swapping dimension dim0 and dim1.

Parameters
dim0The first dimension to be transposed.
dim1The second dimension to be transposed.

Definition at line 1068 of file Tensor.cpp.

References cloudViewer::core::SmallVectorTemplateCommon< T, typename >::begin(), cloudViewer::core::SmallVectorTemplateCommon< T, typename >::end(), NumDims(), Permute(), and cloudViewer::core::shape_util::WrapDim().

Referenced by cloudViewer::t::geometry::kernel::pointcloud::GetPointMaskWithinOBBCPU(), and T().

◆ Tril()

Tensor cloudViewer::core::Tensor::Tril ( const int  diagonal = 0) const

Returns the lower triangular matrix of the 2D tensor, above the given diagonal index. [The value of diagonal = col - row, therefore 0 is the main diagonal (row = col), and it shifts towards right for positive values (for diagonal = 1, col - row = 1), and towards left for negative values. The value of the diagonal parameter must be between [-m, n] where {m, n} is the shape of input tensor.

Parameters
diagonalvalue of [col - row], below which the elements are to be taken for lower triangular matrix.

Definition at line 1970 of file Tensor.cpp.

References cloudViewer::core::Tril().

Referenced by cloudViewer::core::pybind_core_tensor().

◆ Triu()

Tensor cloudViewer::core::Tensor::Triu ( const int  diagonal = 0) const

Returns the upper triangular matrix of the 2D tensor, above the given diagonal index. [The value of diagonal = col - row, therefore 0 is the main diagonal (row = col), and it shifts towards right for positive values (for diagonal = 1, col - row = 1), and towards left for negative values. The value of the diagonal parameter must be between [-m, n] for a {m,n} shaped tensor.

Parameters
diagonalvalue of [col - row], above which the elements are to be taken for upper triangular matrix.

Definition at line 1964 of file Tensor.cpp.

References cloudViewer::core::Triu().

Referenced by cloudViewer::core::pybind_core_tensor().

◆ Triul()

std::tuple< Tensor, Tensor > cloudViewer::core::Tensor::Triul ( const int  diagonal = 0) const

Returns the tuple of upper and lower triangular matrix of the 2D tensor, above and below the given diagonal index. The diagonal elements of lower triangular matrix are taken to be unity. [The value of diagonal = col - row, therefore 0 is the main diagonal (row = col), and it shifts towards right for positive values (for diagonal = 1, col - row = 1), and towards left for negative values. The value of the diagonal parameter must be between [-m, n] where {m, n} is the shape of input tensor.

Parameters
diagonalvalue of [col - row], above and below which the elements are to be taken for upper (diag. included) and lower triangular matrix.

Definition at line 1976 of file Tensor.cpp.

References cloudViewer::core::Triul().

Referenced by cloudViewer::core::pybind_core_tensor().

◆ Trunc()

Tensor cloudViewer::core::Tensor::Trunc ( ) const

Element-wise trunc value of a tensor, returning a new tensor.

Definition at line 1429 of file Tensor.cpp.

References dtype_, GetDevice(), shape_, cloudViewer::core::kernel::Trunc, and cloudViewer::core::kernel::UnaryEW().

Referenced by cloudViewer::core::MakeOperation(), and cloudViewer::core::pybind_core_tensor().

◆ View()

Tensor cloudViewer::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:

Definition at line 721 of file Tensor.cpp.

References AsStrided(), cloudViewer::core::shape_util::InferShape(), LogError, NumElements(), cloudViewer::core::shape_util::Restride(), shape_, and strides_.

Referenced by cloudViewer::t::geometry::BufferRadiusNeighbors(), cloudViewer::t::pipelines::registration::CorrespondencesFromFeatures(), cloudViewer::t::pipelines::slac::ControlGrid::Deform(), cloudViewer::t::pipelines::kernel::FillInRigidAlignmentTermCPU(), cloudViewer::t::geometry::npp::FilterGaussian(), cloudViewer::t::pipelines::slac::ControlGrid::GetNeighborGridMap(), cloudViewer::t::pipelines::slac::ControlGrid::Parameterize(), cloudViewer::ml::contrib::RadiusSearch(), Reshape(), Reverse(), cloudViewer::core::nns::FixedRadiusIndex::SearchHybrid(), cloudViewer::core::nns::NanoFlannIndex::SearchHybrid(), cloudViewer::core::nns::NanoFlannIndex::SearchKnn(), cloudViewer::t::pipelines::slac::ControlGrid::Touch(), cloudViewer::t::pipelines::slac::UpdateControlGrid(), and cloudViewer::t::pipelines::slac::UpdatePoses().

◆ Zeros()

Tensor cloudViewer::core::Tensor::Zeros ( const SizeVector shape,
Dtype  dtype,
const Device device = Device("CPU:0") 
)
static

Create a tensor fill with zeros.

Definition at line 406 of file Tensor.cpp.

References Full().

Referenced by cloudViewer::t::geometry::AxisAlignedBoundingBox::Clear(), cloudViewer::t::geometry::OrientedBoundingBox::Clear(), cloudViewer::t::geometry::PointCloud::ComputeBoundaryPoints(), cloudViewer::t::pipelines::registration::ComputeFPFHFeature(), cloudViewer::t::pipelines::kernel::ComputeFPFHFeatureCPU(), cloudViewer::t::pipelines::kernel::ComputeInformationMatrixCPU(), cloudViewer::t::pipelines::kernel::ComputePoseColoredICPCPU(), cloudViewer::t::pipelines::kernel::ComputePoseDopplerICPCPU(), cloudViewer::t::pipelines::kernel::ComputePosePointToPlaneCPU(), cloudViewer::t::geometry::TriangleMesh::ComputeVertexNormals(), cloudViewer::t::io::DepthNoiseSimulator::DepthNoiseSimulator(), Diag(), cloudViewer::t::geometry::kernel::voxel_grid::ExtractTriangleMeshCPU(), Eye(), cloudViewer::t::geometry::PointCloud::FarthestPointDownSample(), cloudViewer::t::pipelines::kernel::FillInRigidAlignmentTermCPU(), cloudViewer::t::geometry::Image::GetMinBound(), cloudViewer::t::geometry::RGBDImage::GetMinBound(), cloudViewer::t::geometry::AxisAlignedBoundingBox::GetPointIndicesWithinBoundingBox(), cloudViewer::t::geometry::OrientedBoundingBox::GetPointIndicesWithinBoundingBox(), cloudViewer::core::Inverse(), IsInf(), IsNan(), cloudViewer::t::pipelines::kernel::PoseToTransformation(), cloudViewer::t::geometry::TriangleMesh::ProjectImagesToAlbedo(), cloudViewer::t::geometry::PointCloud::ProjectToDepthImage(), cloudViewer::t::geometry::PointCloud::ProjectToRGBDImage(), cloudViewer::core::pybind_core_tensor(), cloudViewer::t::geometry::pybind_pointcloud(), cloudViewer::t::geometry::TriangleMesh::RemoveUnreferencedVertices(), cloudViewer::t::pipelines::kernel::RtToTransformation(), cloudViewer::t::pipelines::slac::RunRigidOptimizerForFragments(), cloudViewer::t::pipelines::slac::RunSLACOptimizerForFragments(), cloudViewer::t::geometry::VoxelBlockGrid::Save(), cloudViewer::t::geometry::PointCloud::SegmentPlane(), cloudViewer::t::geometry::TriangleMesh::SelectByIndex(), cloudViewer::t::geometry::PointCloud::SelectByIndex(), cloudViewer::t::pipelines::kernel::TransformationToPose(), cloudViewer::core::Tril(), cloudViewer::core::Triu(), cloudViewer::core::Triul(), cloudViewer::t::geometry::PointCloud::VoxelDownSample(), and cloudViewer::core::Zeros().

Member Data Documentation

◆ blob_

std::shared_ptr<Blob> cloudViewer::core::Tensor::blob_ = nullptr
protected

Underlying memory buffer for Tensor.

Definition at line 1339 of file Tensor.h.

Referenced by AsStrided(), GetBlob(), GetDevice(), IndexExtract(), IsSame(), operator=(), ReinterpretCast(), Slice(), and Tensor().

◆ data_ptr_

void* cloudViewer::core::Tensor::data_ptr_ = nullptr
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:

// a.GetDataPtr() == a.GetBlob().GetDataPtr()
Tensor a({2, 3}, dtype, "CPU:0");
// b.GetDataPtr() != b.GetBlob().GetDataPtr()
b = a[1];

Definition at line 1333 of file Tensor.h.

Referenced by AsStrided(), GetDataPtr(), IndexExtract(), IsSame(), Item(), operator=(), ReinterpretCast(), Slice(), Tensor(), and ToString().

◆ dtype_

◆ shape_

◆ strides_

SizeVector cloudViewer::core::Tensor::strides_ = {1}
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 reaching 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.

Definition at line 1318 of file Tensor.h.

Referenced by Diag(), Expand(), Eye(), GetStride(), GetStrides(), GetStridesRef(), IndexExtract(), IsContiguous(), IsSame(), operator=(), Permute(), ReinterpretCast(), Reshape(), Slice(), ToString(), and View().


The documentation for this class was generated from the following files: