39 struct is_std_complex<
std::complex<T>> : std::bool_constant<std::is_floating_point_v<T>> { };
46 && (!std::is_floating_point_v<T> ||
sizeof(T) == 4 ||
sizeof(T) == 8))
72 template <TensorElement T>
75 constexpr auto width =
static_cast<uint8_t
>(
sizeof(T) * 8);
76 if constexpr (std::same_as<T, bool>) {
78 }
else if constexpr (std::is_floating_point_v<T>) {
80 }
else if constexpr (std::is_integral_v<T>) {
93 template <TensorElement T>
94 [[nodiscard]]
constexpr bool is() const noexcept {
return *
this ==
of<T>(); }
107 [[nodiscard]] std::optional<size_t> storage_bytes(uint64_t count)
const noexcept;
110 [[nodiscard]] std::string name()
const;
117 [[nodiscard]] std::optional<GpuDataFormat> gpu_format() const noexcept;
A C++ scalar or std::complex that maps to a TensorDType.
TensorDTypeKind
Element family of a tensor.
@ COMPLEX
2 rows → complex (row 0 = real, row 1 = imag)
constexpr size_t element_bits() const noexcept
Bits of one element, lanes included.
static constexpr TensorDType float16() noexcept
IEEE half precision.
constexpr bool operator==(const TensorDType &) const noexcept=default
constexpr size_t element_bytes() const noexcept
Bytes of one element, zero for a sub-byte type.
static constexpr TensorDType bfloat16() noexcept
Brain floating point, 16 bits.
constexpr bool is() const noexcept
Whether this type is exactly the C++ element type T.
constexpr bool is_sub_byte() const noexcept
Whether one element is not a whole number of bytes.
static constexpr TensorDType of() noexcept
Type for a C++ scalar or complex element.
Element type as kind, bit width and lane count.