ClikaRT::dtype::pack
namespace
Pack several sub-byte values into one storage byte.
Functions
int4x2()
Two int4_t: low nibble = a, high nibble = b.
Declared in ClikaRT/compute/scalar_types.h, line 480
uint4x2()
Two uint4_t: low nibble = a, high nibble = b.
Declared in ClikaRT/compute/scalar_types.h, line 484
int2x4()
Four int2_t: bits 0-1 = a, 2-3 = b, 4-5 = c, 6-7 = d.
Declared in ClikaRT/compute/scalar_types.h, line 488
uint1x8()
constexpr std::uint8_t uint1x8(
uint1_t b0,
uint1_t b1,
uint1_t b2,
uint1_t b3,
uint1_t b4,
uint1_t b5,
uint1_t b6,
uint1_t b7
) noexcept
Eight uint1_t: b0 at the LSB through b7 at the MSB.
Declared in ClikaRT/compute/scalar_types.h, line 494
ClikaRT/compute/scalar_types.h
#include <ClikaRT/compute/scalar_types.h>
The narrow scalar element types: the C++ value types that back a tensor's non-native element formats.
float, double, and the standard int*_t / uint*_t need no wrapper. The types here cover the formats that have no built-in C++ counterpart: the reduced-precision floats (float16_t, bfloat16_t, tfloat32_t), the 8/6/4-bit quantized floats (the FP8 / FP6 / FP4 families), the nf4_t lookup-quantized format, and the packed sub-byte integers (int4_t / uint4_t / int2_t / uint2_t / uint1_t). Each maps to a DataType (data_type.h) where one exists; tfloat32_t and nf4_t are compute/quantization types with no storage DataType.
Every type is an ABI-stable value type: a single bits field of fixed width, so it interconverts losslessly with raw buffers via from_bits / .bits. The floating types convert to and from float:
T(f)quantizes anfp32(round-to-nearest-even; the no-Inf/NaN formats saturate on overflow).float(x)dequantizes, losslessly.from_bits(b)reinterprets a stored encoding without converting.
Per-element float conversion crosses the library boundary; for bulk conversion of many values, operate on a Tensor and let the op layer do it in one pass.