 |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
Go to the documentation of this file.
19 namespace eigen_converter {
28 template <
class Derived>
30 typedef typename Derived::Scalar
Scalar;
31 core::Dtype dtype = core::Dtype::FromType<Scalar>();
32 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
33 matrix_row_major = matrix;
34 return core::Tensor(matrix_row_major.data(), {matrix.rows(), matrix.cols()},
43 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
51 Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
59 Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
107 const std::vector<Eigen::Vector3d> &values,
121 const std::vector<Eigen::Vector2d> &values,
135 const std::vector<Eigen::Vector2i> &values,
148 const std::vector<Eigen::Vector3i> &values,
Generic file read and write utility for python interface.
Definition: CloudViewerConfig.cpp:12
Dtype GetDtype() const
Definition: Tensor.h:1164
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > TensorToEigenMatrixXd(const core::Tensor &tensor)
Converts a 2D tensor to Eigen::MatrixXd of same shape. Regardless of the tensor dtype,...
Definition: EigenConverter.cpp:67
int64_t GetLength() const
Definition: Tensor.h:1125
static std::vector< Eigen::Matrix< T, N, 1 > > TensorToEigenVectorNxVector(const core::Tensor &tensor)
Definition: EigenConverter.cpp:82
SizeVector GetShape() const
Definition: Tensor.h:1127
std::vector< Eigen::Vector2d > TensorToEigenVector2dVector(const core::Tensor &tensor)
Converts a tensor of shape (N, 2) to std::vector<Eigen::Vector2d>. An exception will be thrown if the...
Definition: EigenConverter.cpp:145
static Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > TensorToEigenMatrix(const core::Tensor &tensor)
Definition: EigenConverter.cpp:37
std::vector< Eigen::Vector2i > TensorToEigenVector2iVector(const core::Tensor &tensor)
Converts a tensor of shape (N, 2) to std::vector<Eigen::Vector2i>. An exception will be thrown if the...
Definition: EigenConverter.cpp:160
Tensor Contiguous() const
Definition: Tensor.cpp:772
int64_t ByteSize() const
Definition: Dtype.h:59
core::Tensor EigenVector2iVectorToTensor(const std::vector< Eigen::Vector2i > &values, core::Dtype dtype, const core::Device &device)
Converts a vector of Eigen::Vector2i to a (N, 2) tensor. This function also takes care of dtype conve...
Definition: EigenConverter.cpp:185
const Dtype Int32
Definition: Dtype.cpp:46
core::Tensor EigenVector3iVectorToTensor(const std::vector< Eigen::Vector3i > &values, core::Dtype dtype, const core::Device &device)
Converts a vector of Eigen::Vector3i to a (N, 3) tensor. This function also takes care of dtype conve...
Definition: EigenConverter.cpp:179
const Dtype Float64
Definition: Dtype.cpp:43
Device GetDevice() const override
Definition: Tensor.cpp:1435
Definition: SizeVector.h:70
Indexer indexer
Definition: BinaryEWSYCL.cpp:30
#define LogError(...)
Definition: Logging.h:60
#define DISPATCH_DTYPE_TO_TEMPLATE(DTYPE,...)
Definition: Dispatch.h:31
Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > TensorToEigenMatrixXf(const core::Tensor &tensor)
Converts a 2D tensor to Eigen::MatrixXf of same shape. Regardless of the tensor dtype,...
Definition: EigenConverter.cpp:72
static void LaunchIndexFillKernel(const Indexer &indexer, const func_t &func)
Definition: EigenConverter.cpp:28
core::Tensor EigenMatrixToTensor(const Eigen::MatrixBase< Derived > &matrix)
Converts a eigen matrix of shape (M, N) with alignment A and type T to a tensor.
Definition: EigenConverter.h:29
static Tensor Empty(const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0"))
Create a tensor with uninitialized values.
Definition: Tensor.cpp:400
int64_t NumElements() const
Definition: Tensor.h:1170
Eigen::Matrix< int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > TensorToEigenMatrixXi(const core::Tensor &tensor)
Converts a 2D tensor to Eigen::MatrixXi of same shape. Regardless of the tensor dtype,...
Definition: EigenConverter.cpp:77
constexpr nullopt_t nullopt
Definition: Optional.h:136
core::Tensor EigenVector2dVectorToTensor(const std::vector< Eigen::Vector2d > &values, core::Dtype dtype, const core::Device &device)
Converts a vector of Eigen::Vector2d to a (N, 2) tensor. This function also takes care of dtype conve...
Definition: EigenConverter.cpp:172
void ParallelFor(const Device &device, int64_t n, const func_t &func)
Definition: ParallelFor.h:111
std::vector< Eigen::Vector3i > TensorToEigenVector3iVector(const core::Tensor &tensor)
Converts a tensor of shape (N, 3) to std::vector<Eigen::Vector3i>. An exception will be thrown if the...
Definition: EigenConverter.cpp:155
#define AssertTensorShape(tensor,...)
Definition: TensorCheck.h:61
static void MemcpyToHost(void *host_ptr, const void *src_ptr, const Device &src_device, size_t num_bytes)
Same as Memcpy, but with host (CPU:0) as default dst_device.
Definition: MemoryManager.cpp:86
static core::Tensor EigenVectorNxVectorToTensor(const std::vector< Eigen::Matrix< T, N, 1 >> &values, core::Dtype dtype, const core::Device &device)
Definition: EigenConverter.cpp:113
std::vector< Eigen::Vector3d > TensorToEigenVector3dVector(const core::Tensor &tensor)
Converts a tensor of shape (N, 3) to std::vector<Eigen::Vector3d>. An exception will be thrown if the...
Definition: EigenConverter.cpp:150
Definition: Indexer.h:262
Tensor To(Dtype dtype, bool copy=false) const
Definition: Tensor.cpp:739
core::Tensor EigenVector3dVectorToTensor(const std::vector< Eigen::Vector3d > &values, core::Dtype dtype, const core::Device &device)
Converts a vector of Eigen::Vector3d to a (N, 3) tensor. This function also takes care of dtype conve...
Definition: EigenConverter.cpp:165
T * GetDataPtr()
Definition: Tensor.h:1144