(d32b4fc (Mon Sep 14 15:46:25 2026 -0700))
#include <torch/script.h>
#include <sstream>
#include <type_traits>
#include "open3d/core/Device.h"
#include "open3d/ml/ShapeChecking.h"
#include "open3d/utility/Logging.h"
Go to the source code of this file.
|
| template<class T > |
| TorchDtype_t | ToTorchDtype () |
| |
| template<> |
| TorchDtype_t | ToTorchDtype< uint8_t > () |
| |
| template<> |
| TorchDtype_t | ToTorchDtype< int8_t > () |
| |
| template<> |
| TorchDtype_t | ToTorchDtype< int16_t > () |
| |
| template<> |
| TorchDtype_t | ToTorchDtype< int32_t > () |
| |
| template<> |
| TorchDtype_t | ToTorchDtype< int64_t > () |
| |
| template<> |
| TorchDtype_t | ToTorchDtype< float > () |
| |
| template<> |
| TorchDtype_t | ToTorchDtype< double > () |
| |
| template<class T , class TDtype > |
| bool | CompareTorchDtype (const TDtype &t) |
| |
| bool | SameDeviceType (std::initializer_list< torch::Tensor > tensors) |
| |
| bool | SameDtype (std::initializer_list< torch::Tensor > tensors) |
| |
| std::string | TensorInfoStr (std::initializer_list< torch::Tensor > tensors) |
| |
| torch::Tensor | CreateTempTensor (const int64_t size, const torch::Device &device, void **ptr=nullptr) |
| |
| void | WarnIfTF32NotSupported (bool allow_tf32) |
| |
| template<class Fn > |
| void | RunSYCLWithTempMemory (const torch::Device &device, int64_t max_temp_mem_MB, Fn &&run_fn) |
| |
| std::vector< open3d::ml::op_util::DimValue > | GetShapeVector (torch::Tensor tensor) |
| |
| template<open3d::ml::op_util::CSOpt Opt = open3d::ml::op_util::CSOpt::NONE, class TDimX , class... TArgs> |
| std::tuple< bool, std::string > | CheckShape (torch::Tensor tensor, TDimX &&dimex, TArgs &&... args) |
| |
◆ CHECK_CONTIGUOUS
| #define CHECK_CONTIGUOUS |
( |
|
x | ) |
|
Value: do { \
TORCH_CHECK(
x.is_contiguous(), #
x " must be contiguous") \
} while (0)
◆ CHECK_CUDA
Value: do { \
TORCH_CHECK(
x.is_cuda(), #
x " must be a CUDA tensor") \
} while (0)
◆ CHECK_SAME_DEVICE_TYPE
| #define CHECK_SAME_DEVICE_TYPE |
( |
|
... | ) |
|
Value: do { \
TORCH_CHECK( \
false, \
#__VA_ARGS__ \
" must all have the same device type but got " + \
} \
} while (0)
std::string TensorInfoStr(std::initializer_list< torch::Tensor > tensors)
Definition TorchHelper.h:126
bool SameDeviceType(std::initializer_list< torch::Tensor > tensors)
Definition TorchHelper.h:101
◆ CHECK_SAME_DTYPE
| #define CHECK_SAME_DTYPE |
( |
|
... | ) |
|
Value: do { \
TORCH_CHECK(false, \
#__VA_ARGS__ \
" must all have the same dtype but got " + \
} \
} while (0)
bool SameDtype(std::initializer_list< torch::Tensor > tensors)
Definition TorchHelper.h:114
◆ CHECK_SHAPE
| #define CHECK_SHAPE |
( |
|
tensor, |
|
|
|
... |
|
) |
| |
Value: do { \
bool cs_success_; \
std::string cs_errstr_; \
std::tie(cs_success_, cs_errstr_) =
CheckShape(tensor, __VA_ARGS__); \
TORCH_CHECK(cs_success_, \
"invalid shape for '" #tensor "', " + cs_errstr_) \
} while (0)
std::tuple< bool, std::string > CheckShape(torch::Tensor tensor, TDimX &&dimex, TArgs &&... args)
Definition TorchHelper.h:204
◆ CHECK_SHAPE_COMBINE_FIRST_DIMS
| #define CHECK_SHAPE_COMBINE_FIRST_DIMS |
( |
|
tensor, |
|
|
|
... |
|
) |
| |
Value: do { \
bool cs_success_; \
std::string cs_errstr_; \
std::tie(cs_success_, cs_errstr_) = \
CheckShape<CSOpt::COMBINE_FIRST_DIMS>(tensor, __VA_ARGS__); \
TORCH_CHECK(cs_success_, \
"invalid shape for '" #tensor "', " + cs_errstr_) \
} while (0)
◆ CHECK_SHAPE_COMBINE_LAST_DIMS
| #define CHECK_SHAPE_COMBINE_LAST_DIMS |
( |
|
tensor, |
|
|
|
... |
|
) |
| |
Value: do { \
bool cs_success_; \
std::string cs_errstr_; \
std::tie(cs_success_, cs_errstr_) = \
CheckShape<CSOpt::COMBINE_LAST_DIMS>(tensor, __VA_ARGS__); \
TORCH_CHECK(cs_success_, \
"invalid shape for '" #tensor "', " + cs_errstr_) \
} while (0)
◆ CHECK_SHAPE_IGNORE_FIRST_DIMS
| #define CHECK_SHAPE_IGNORE_FIRST_DIMS |
( |
|
tensor, |
|
|
|
... |
|
) |
| |
Value: do { \
bool cs_success_; \
std::string cs_errstr_; \
std::tie(cs_success_, cs_errstr_) = \
CheckShape<CSOpt::IGNORE_FIRST_DIMS>(tensor, __VA_ARGS__); \
TORCH_CHECK(cs_success_, \
"invalid shape for '" #tensor "', " + cs_errstr_) \
} while (0)
◆ CHECK_SHAPE_IGNORE_LAST_DIMS
| #define CHECK_SHAPE_IGNORE_LAST_DIMS |
( |
|
tensor, |
|
|
|
... |
|
) |
| |
Value: do { \
bool cs_success_; \
std::string cs_errstr_; \
std::tie(cs_success_, cs_errstr_) = \
CheckShape<CSOpt::IGNORE_LAST_DIMS>(tensor, __VA_ARGS__); \
TORCH_CHECK(cs_success_, \
"invalid shape for '" #tensor "', " + cs_errstr_) \
} while (0)
◆ CHECK_TYPE
| #define CHECK_TYPE |
( |
|
x, |
|
|
|
type |
|
) |
| |
Value: do { \
TORCH_CHECK(
x.dtype() == torch::type, #
x " must have type " #
type) \
} while (0)
◆ TorchDtype_t
◆ CheckShape()
| std::tuple< bool, std::string > CheckShape |
( |
torch::Tensor |
tensor, |
|
|
TDimX && |
dimex, |
|
|
TArgs &&... |
args |
|
) |
| |
◆ CompareTorchDtype()
template<class T , class TDtype >
| bool CompareTorchDtype |
( |
const TDtype & |
t | ) |
|
|
inline |
◆ CreateTempTensor()
| torch::Tensor CreateTempTensor |
( |
const int64_t |
size, |
|
|
const torch::Device & |
device, |
|
|
void ** |
ptr = nullptr |
|
) |
| |
|
inline |
◆ GetShapeVector()
◆ RunSYCLWithTempMemory()
template<class Fn >
| void RunSYCLWithTempMemory |
( |
const torch::Device & |
device, |
|
|
int64_t |
max_temp_mem_MB, |
|
|
Fn && |
run_fn |
|
) |
| |
|
inline |
◆ SameDeviceType()
| bool SameDeviceType |
( |
std::initializer_list< torch::Tensor > |
tensors | ) |
|
|
inline |
◆ SameDtype()
| bool SameDtype |
( |
std::initializer_list< torch::Tensor > |
tensors | ) |
|
|
inline |
◆ TensorInfoStr()
| std::string TensorInfoStr |
( |
std::initializer_list< torch::Tensor > |
tensors | ) |
|
|
inline |
◆ ToTorchDtype()
◆ ToTorchDtype< double >()
◆ ToTorchDtype< float >()
◆ ToTorchDtype< int16_t >()
◆ ToTorchDtype< int32_t >()
◆ ToTorchDtype< int64_t >()
◆ ToTorchDtype< int8_t >()
◆ ToTorchDtype< uint8_t >()
◆ WarnIfTF32NotSupported()
| void WarnIfTF32NotSupported |
( |
bool |
allow_tf32 | ) |
|
|
inline |