Skip to main content

ClikaRT::dtype::pack

namespace

Pack several sub-byte values into one storage byte.

Functions

int4x2()

constexpr std::uint8_t int4x2(int4_t a, int4_t b) noexcept

Two int4_t: low nibble = a, high nibble = b.

Declared in ClikaRT/compute/scalar_types.h, line 480

uint4x2()

constexpr std::uint8_t uint4x2(uint4_t a, uint4_t b) noexcept

Two uint4_t: low nibble = a, high nibble = b.

Declared in ClikaRT/compute/scalar_types.h, line 484

int2x4()

constexpr std::uint8_t int2x4(
    int2_t a,
    int2_t b,
    int2_t c,
    int2_t d
) noexcept

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 an fp32 (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.