21 namespace tensor_check {
31 std::string error_message =
32 fmt::format(
"Tensor has dtype {}, but is expected to have {}.",
41 const std::vector<Dtype>& dtypes) {
42 for (
auto& it : dtypes) {
48 std::vector<std::string> dtype_strings;
49 for (
const Dtype& dtype : dtypes) {
50 dtype_strings.push_back(dtype.ToString());
53 "Tensor has dtype {}, but is expected to have dtype among {{{}}}.",
66 std::string error_message =
67 fmt::format(
"Tensor has device {}, but is expected to have {}.",
82 "Tensor has shape {}, but is expected to have compatible with "
88 if (tensor.
GetShape() == static_shape) {
92 "Tensor has shape {}, but is expected to have {}.",
filament::Texture::InternalFormat format
std::string ToString() const
Returns string representation of device, e.g. "CPU:0", "CUDA:0".
std::string ToString() const
std::string ToString() const
SizeVector ToSizeVector() const
bool IsCompatible(const DynamicSizeVector &dsv) const
std::string ToString() const
Device GetDevice() const override
SizeVector GetShape() const
static void LogError_(const char *file, int line, const char *function, const char *format, Args &&...args)
Helper functions for the ml ops.
void AssertTensorDtypes_(const char *file, int line, const char *function, const Tensor &tensor, const std::vector< Dtype > &dtypes)
void AssertTensorDtype_(const char *file, int line, const char *function, const Tensor &tensor, const Dtype &dtype)
void AssertTensorDevice_(const char *file, int line, const char *function, const Tensor &tensor, const Device &device)
void AssertTensorShape_(const char *file, int line, const char *function, const Tensor &tensor, const DynamicSizeVector &shape)
std::string JoinStrings(const std::vector< std::string > &strs, const std::string &delimiter=", ")
Generic file read and write utility for python interface.