HDK
|
Stores 2 packed 4-bit elements in 1 byte. More...
#include <int4.h>
Public Types | |
using | UnpackedType = typename Int4Traits< Signed >::UnpackedType |
Public Member Functions | |
Int4x2Base ()=default | |
Int4x2Base (std::byte bits) | |
Int4x2Base (UnpackedType val0, UnpackedType val1) | |
UnpackedType | GetElem (size_t index) const |
void | SetElem (size_t index, UnpackedType val) |
std::byte | ToBits () const |
Static Public Member Functions | |
static int8_t | SignExtendLower4Bits (std::byte bits) |
static size_t | CalcNumInt4Pairs (size_t num_int4_elems) |
static bool | Unpack (gsl::span< UnpackedType > dst, gsl::span< const Int4x2Base< Signed >> src) |
Copy a source buffer of 4-bit elements (packed) into a destination buffer of 8-bit elements (unpacked). More... | |
static bool | Pack (gsl::span< Int4x2Base< Signed >> dst, gsl::span< const UnpackedType > src) |
Copy a source buffer of 8-bit elements (unpacked) into a destination buffer of 4-bit elements (packed). More... | |
static std::pair< size_t, size_t > | GetTensorElemIndices (size_t index) |
Returns hierarchical indices for a packed int4 element from the given element index. More... | |
Public Attributes | |
std::byte | bits_ {} |
Static Public Attributes | |
static constexpr UnpackedType | min_val = Int4Traits<Signed>::min_val |
static constexpr UnpackedType | max_val = Int4Traits<Signed>::max_val |
Stores 2 packed 4-bit elements in 1 byte.
Signed | Set to true if signed int4, or false if unsigned uint4. |
using onnxruntime::Int4x2Base< Signed >::UnpackedType = typename Int4Traits<Signed>::UnpackedType |
|
default |
|
inlineexplicit |
|
inline |
|
inlinestatic |
|
inline |
|
inlinestatic |
Returns hierarchical indices for a packed int4 element from the given element index.
Usage: Int4x2* data = ...; auto indices = GetTensorElemIndices(3); // 4th int4 element int8_t elem = data[indices.first].GetElem(indices.second);
index | Index of 4-bit element |
|
inlinestatic |
|
inline |
|
inlinestatic |
|
inline |
|
inlinestatic |
std::byte onnxruntime::Int4x2Base< Signed >::bits_ {} |
|
static |
|
static |