ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
TensorCheck.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include "cloudViewer/Macro.h"
12 #include "cloudViewer/core/Dtype.h"
14 
21 #define AssertTensorDtype(tensor, ...) \
22  tensor_check::AssertTensorDtype_( \
23  __FILE__, __LINE__, \
24  static_cast<const char*>(CLOUDVIEWER_FUNCTION), tensor, \
25  __VA_ARGS__)
26 
33 #define AssertTensorDtypes(tensor, ...) \
34  tensor_check::AssertTensorDtypes_( \
35  __FILE__, __LINE__, \
36  static_cast<const char*>(CLOUDVIEWER_FUNCTION), tensor, \
37  __VA_ARGS__)
38 
45 #define AssertTensorDevice(tensor, ...) \
46  tensor_check::AssertTensorDevice_( \
47  __FILE__, __LINE__, \
48  static_cast<const char*>(CLOUDVIEWER_FUNCTION), tensor, \
49  __VA_ARGS__)
50 
61 #define AssertTensorShape(tensor, ...) \
62  tensor_check::AssertTensorShape_( \
63  __FILE__, __LINE__, \
64  static_cast<const char*>(CLOUDVIEWER_FUNCTION), tensor, \
65  __VA_ARGS__)
66 
67 namespace cloudViewer {
68 namespace core {
69 namespace tensor_check {
70 
71 void AssertTensorDtype_(const char* file,
72  int line,
73  const char* function,
74  const Tensor& tensor,
75  const Dtype& dtype);
76 
77 void AssertTensorDtypes_(const char* file,
78  int line,
79  const char* function,
80  const Tensor& tensor,
81  const std::vector<Dtype>& dtypes);
82 
83 void AssertTensorDevice_(const char* file,
84  int line,
85  const char* function,
86  const Tensor& tensor,
87  const Device& device);
88 
89 void AssertTensorShape_(const char* file,
90  int line,
91  const char* function,
92  const Tensor& tensor,
93  const DynamicSizeVector& shape);
94 
95 } // namespace tensor_check
96 } // namespace core
97 } // namespace cloudViewer
cloudViewer
Generic file read and write utility for python interface.
Definition: CloudViewerConfig.cpp:12
cloudViewer::core::Tensor::GetDtype
Dtype GetDtype() const
Definition: Tensor.h:1164
cloudViewer::core::tensor_check::AssertTensorDtype_
void AssertTensorDtype_(const char *file, int line, const char *function, const Tensor &tensor, const Dtype &dtype)
Definition: TensorCheck.cpp:23
cloudViewer::core::tensor_check::AssertTensorShape_
void AssertTensorShape_(const char *file, int line, const char *function, const Tensor &tensor, const DynamicSizeVector &shape)
Definition: TensorCheck.cpp:72
Device.h
cloudViewer::core::Tensor::GetShape
SizeVector GetShape() const
Definition: Tensor.h:1127
format
filament::Texture::InternalFormat format
Definition: FilamentResourceManager.cpp:181
cloudViewer::utility::JoinStrings
std::string JoinStrings(const std::vector< std::string > &strs, const std::string &delimiter=", ")
Definition: Helper.cpp:168
cloudViewer::core::SizeVector::IsCompatible
bool IsCompatible(const DynamicSizeVector &dsv) const
Definition: SizeVector.cpp:149
cloudViewer::core::Tensor
Definition: Tensor.h:32
cloudViewer::core::Dtype
Definition: Dtype.h:21
cloudViewer::core::Device::ToString
std::string ToString() const
Returns string representation of device, e.g. "CPU:0", "CUDA:0".
Definition: Device.cpp:89
cloudViewer::core::tensor_check::AssertTensorDtypes_
void AssertTensorDtypes_(const char *file, int line, const char *function, const Tensor &tensor, const std::vector< Dtype > &dtypes)
Definition: TensorCheck.cpp:37
cloudViewer::core::tensor_check::AssertTensorDevice_
void AssertTensorDevice_(const char *file, int line, const char *function, const Tensor &tensor, const Device &device)
Definition: TensorCheck.cpp:58
cloudViewer::core::DynamicSizeVector
Definition: SizeVector.h:32
cloudViewer::core::SizeVector::ToString
std::string ToString() const
Definition: SizeVector.cpp:132
cloudViewer::core::Device
Definition: Device.h:18
TensorCheck.h
core
cloudViewer::core::Dtype::ToString
std::string ToString() const
Definition: Dtype.h:65
cloudViewer::core::Tensor::GetDevice
Device GetDevice() const override
Definition: Tensor.cpp:1435
cloudViewer::core::SizeVector
Definition: SizeVector.h:70
Macro.h
cloudViewer::core::DynamicSizeVector::ToString
std::string ToString() const
Definition: SizeVector.cpp:61
cloudViewer::core::DynamicSizeVector::IsDynamic
bool IsDynamic() const
Definition: SizeVector.cpp:81
Tensor.h
cloudViewer::utility::Logger::LogError_
static void LogError_(const char *file, int line, const char *function, const char *format, Args &&...args)
Definition: Logging.h:189
cloudViewer::core::DynamicSizeVector::ToSizeVector
SizeVector ToSizeVector() const
Definition: SizeVector.cpp:40
Dtype.h