---
title: "ClikaRT::dtype::pack"
sidebar_label: "pack"
description: "Pack several sub-byte values into one storage byte."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--namespace">namespace</span>

Pack several sub-byte values into one storage byte.

## Functions

### int4x2() {#int4x2}

<div class="api-signature">

`constexpr` `std::uint8_t` **`int4x2`**([`int4_t`](../int4_t.md) `a`, [`int4_t`](../int4_t.md) `b`) `noexcept`

</div>

Two [int4\_t](../int4_t.md): low nibble = `a`, high nibble = `b`.

<div class="api-declared">

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

</div>

### uint4x2() {#uint4x2}

<div class="api-signature">

`constexpr` `std::uint8_t` **`uint4x2`**([`uint4_t`](../uint4_t.md) `a`, [`uint4_t`](../uint4_t.md) `b`) `noexcept`

</div>

Two [uint4\_t](../uint4_t.md): low nibble = `a`, high nibble = `b`.

<div class="api-declared">

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

</div>

### int2x4() {#int2x4}

<div class="api-signature">

`constexpr` `std::uint8_t` **`int2x4`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`int2_t`](../int2_t.md) `a`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`int2_t`](../int2_t.md) `b`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`int2_t`](../int2_t.md) `c`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`int2_t`](../int2_t.md) `d`<br />
) `noexcept`

</div>

Four [int2\_t](../int2_t.md): bits 0-1 = `a`, 2-3 = `b`, 4-5 = `c`, 6-7 = `d`.

<div class="api-declared">

Declared in `ClikaRT/compute/scalar_types.h`, line 488

</div>

### uint1x8() {#uint1x8}

<div class="api-signature">

`constexpr` `std::uint8_t` **`uint1x8`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`uint1_t`](../uint1_t.md) `b0`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`uint1_t`](../uint1_t.md) `b1`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`uint1_t`](../uint1_t.md) `b2`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`uint1_t`](../uint1_t.md) `b3`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`uint1_t`](../uint1_t.md) `b4`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`uint1_t`](../uint1_t.md) `b5`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`uint1_t`](../uint1_t.md) `b6`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`uint1_t`](../uint1_t.md) `b7`<br />
) `noexcept`

</div>

Eight [uint1\_t](../uint1_t.md): `b0` at the LSB through `b7` at the MSB.

<div class="api-declared">

Declared in `ClikaRT/compute/scalar_types.h`, line 494

</div>

## `ClikaRT/compute/scalar_types.h` {#scalar_types-h}

```cpp
#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`](../index.md#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.
