41#define DEFINE_DTYPE(type, torch_dtype) \
43 template <> struct dtype_traits<type> { \
45 static constexpr torch::Dtype value = torch_dtype; \
66concept DType =
requires { dtype_traits<normalized_type_t<T>>::value; };
87#define DEFINE_TYPE_NAME(type) \
90 struct type_name<type> { \
92 static constexpr std::string_view value = #type; \
120#undef DEFINE_TYPE_NAME
126 static constexpr std::string_view value =
127 "std::complex<half>";
134 static constexpr std::string_view value =
135 "std::complex<float>";
142 static constexpr std::string_view value =
143 "std::complex<double>";
150 static constexpr std::string_view value =
151 "std::complex<long double>";
158 static constexpr std::string_view value =
"std::nullptr_t";
Concept to identify template parameters that are acceptable as DTypes.
Definition dtype.hpp:66
#define DEFINE_TYPE_NAME(type)
Defines a type_name specialization.
Definition dtype.hpp:87
#define DEFINE_DTYPE(type, torch_dtype)
Defines a dtype_traits specialization.
Definition dtype.hpp:41
constexpr std::string_view type_name_v
Human-readable name associated with a supported C++ type.
Definition dtype.hpp:166
std::remove_cv_t< T > normalized_type_t
Removes top-level const and volatile qualifiers from a type.
Definition dtype.hpp:31
constexpr torch::Dtype dtype_v
Determines the LibTorch dtype from a template parameter.
Definition dtype.hpp:75
Type trait that maps C++ types to LibTorch dtypes.
Definition dtype.hpp:36
Tag type representing IEEE 754 half-precision floating-point data.
Definition dtype.hpp:27
Type trait to obtain the name of a fundamental type as std::string_view.
Definition dtype.hpp:83