MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Kakshya::TensorDType Struct Reference

Element type as kind, bit width and lane count. More...

#include <TensorDType.hpp>

Collaboration diagram for MayaFlux::Kakshya::TensorDType:

Public Member Functions

constexpr size_t element_bits () const noexcept
 Bits of one element, lanes included.
constexpr size_t element_bytes () const noexcept
 Bytes of one element, zero for a sub-byte type.
std::optional< GpuDataFormat > gpu_format () const noexcept
 GpuDataFormat holding exactly this element, when one exists.
template<TensorElement T>
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.
std::string name () const
 Short readable name such as f32, bf16, i64, u8.
constexpr bool operator== (const TensorDType &) const noexcept=default
std::optional< size_t > storage_bytes (uint64_t count) const noexcept
 Packed bytes needed for count elements.

Static Public Member Functions

static constexpr TensorDType bfloat16 () noexcept
 Brain floating point, 16 bits.
static constexpr TensorDType float16 () noexcept
 IEEE half precision.
template<TensorElement T>
static constexpr TensorDType of () noexcept
 Type for a C++ scalar or complex element.

Public Attributes

uint8_t bits { 32 }
TensorDTypeKind kind { TensorDTypeKind::FLOAT }
uint16_t lanes { 1 }

Detailed Description

Element type as kind, bit width and lane count.

Mirrors the DLPack data type, so half, bfloat16, float8, int4 and every integer width are first class and nothing is widened. Sub-byte types are packed; their storage is rounded up to whole bytes for the tensor.

Usage:

bool same = f.is<float>();
static constexpr TensorDType float16() noexcept
IEEE half precision.
static constexpr TensorDType of() noexcept
Type for a C++ scalar or complex element.

Definition at line 64 of file TensorDType.hpp.


The documentation for this struct was generated from the following files: