Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[Core, python, tests] U3/U6 tight layout (#37430)

Oleg Pipikind015add94c13
diff --git a/src/bindings/python/src/openvino/helpers/packing.py b/src/bindings/python/src/openvino/helpers/packing.py
index f85a84bfd0e..8ff664df5fc 100644
--- a/src/bindings/python/src/openvino/helpers/packing.py
+++ b/src/bindings/python/src/openvino/helpers/packing.py
@@ -11,9 +11,8 @@ from openvino import Type, Shape
def pack_data(array: np.ndarray, type: Type) -> np.ndarray:
"""Represent array values as u1, u2, u3, u4, u6 or i4 openvino element type and pack them into uint8 numpy array.
- For u1, u4, i4: Standard bit packing where 8 % bitwidth == 0
- For u3: Transposed packing - 8 values in 3 bytes
- For u6: Transposed packing - 4 values in 3 bytes
+ For u1, u2, u4, i4: Standard bit packing where 8 % bitwidth == 0
+ For u3, u6: Linear LSB-first bit-stream packing, values may straddle a byte boundary
If the number of elements in array is odd we pad them with zero value to be able to fit the bit
sequence into the uint8 array.
@@ -27,11 +26,11 @@ def pack_data(array: np.ndarray, type: Type) -> np.ndarray:
:param type: Type to interpret the array values. Type must be u1, u2, u3, u4, u6, i4, nf4 or f4e2m1.
:type type: openvino.Type
"""
- # Handle u3 and u6 with special transposed packing
+ # Handle u3 and u6 with linear LSB-first bit-stream packing
if type == Type.u3:
- return _pack_u3(array)
+ return _pack_linear(array, 3)
elif type == Type.u6:
- return _pack_u6(array)
+ return _pack_linear(array, 6)
assert type in [Type.u1, Type.u2, Type.u4, Type.i4, Type.nf4, Type.f4e2m1], "Packing algorithm for the" "data types stored in 1, 2 or 4 bits"
@@ -61,9 +60,8 @@ def pack_data(array: np.ndarray, type: Type) -> np.ndarray:
def unpack_data(array: np.ndarray, type: Type, shape: Union[list, Shape]) -> np.ndarray:
"""Extract openvino element type values from array into new uint8/int8 array given shape.
- For u1, u4, i4: Standard bit unpacking where 8 % bitwidth == 0
- For u3: Transposed unpacking - 8 values from 3 bytes
- For u6: Transposed unpacking - 4 values from 3 bytes
+ For u1, u2, u4, i4: Standard bit unpacking where 8 % bitwidth == 0
+ For u3, u6: Linear LSB-first bit-stream unpacking, values may straddle a byte boundary
Example: uint8 value [120] can be represented as two u4 values and be unpacked into [7, 8]
because [120] bit representation is [01111000] will be viewed as [0111, 1000],
@@ -76,11 +74,11 @@ def unpack_data(array: np.ndarray, type: Type, shape: Union[list, Shape]) -> np.
:param shape: the new shape for the unpacked array.
:type shape: Union[list, openvino.Shape]
"""
- # Handle u3 and u6 with special transposed unpacking
+ # Handle u3 and u6 with linear LSB-first bit-stream unpacking
if type == Type.u3:
- return _unpack_u3(array, shape)
+ return _unpack_linear(array, 3, shape)
elif type == Type.u6:
- return _unpack_u6(array, shape)
+ return _unpack_linear(array, 6, shape)
assert type in [Type.u1, Type.u2, Type.u4, Type.i4, Type.nf4, Type.f4e2m1], "Unpacking algorithm for the" "data types stored in 1, 2 or 4 bits"
unpacked = np.unpackbits(array.view(np.uint8))
@@ -107,148 +105,23 @@ def unpack_data(array: np.ndarray, type: Type, shape: Union[list, Shape]) -> np.
return np.resize(packed, shape)
-def _pack_u3(array: np.ndarray) -> np.ndarray:
- """Pack u3 values using transposed packing scheme.
-
- 8 values (each 3 bits) are packed into 3 bytes:
- - Byte 0: bits [1:0] of values 0-3 (4 values * 2 bits = 8 bits)
- - Byte 1: bits [1:0] of values 4-7 (4 values * 2 bits = 8 bits)
- - Byte 2: bits [2] of all 8 values (8 values * 1 bit = 8 bits)
+def _pack_linear(array: np.ndarray, bits: int) -> np.ndarray:
+ """Pack values into a linear, LSB-first bit-stream (used for u3/u6): value i occupies bits
+ [i * bits, i * bits + bits), possibly straddling a byte boundary.
"""
array = array.astype(np.uint8, casting="unsafe").flatten()
- # Pad to multiple of 8
- pad = (-len(array)) % 8
- if pad:
- array = np.concatenate([array, np.zeros(pad, dtype=np.uint8)])
-
- groups = array.reshape(-1, 8)
- result = []
-
- for group in groups:
- # Extract lower 2 bits and MSB for each value
- lower_bits = group & 0x03 # bits [1:0]
- msb = (group >> 2) & 0x01 # bit [2]
-
- # Pack into 3 bytes
- byte0 = (lower_bits[0] << 6) | (lower_bits[1] << 4) | (lower_bits[2] << 2) | lower_bits[3]
- byte1 = (lower_bits[4] << 6) | (lower_bits[5] << 4) | (lower_bits[6] << 2) | lower_bits[7]
- byte2 = (msb[0] << 7) | (msb[1] << 6) | (msb[2] << 5) | (msb[3] << 4) | \
- (msb[4] << 3) | (msb[5] << 2) | (msb[6] << 1) | msb[7]
+ bit_order_little = (array[:, None] & (1 << np.arange(bits)) > 0).astype(np.uint8)
+ return np.packbits(bit_order_little.flatten(), bitorder="little")
- result.extend([byte0, byte1, byte2])
- return np.array(result, dtype=np.uint8)
-
-
-def _unpack_u3(array: np.ndarray, shape: Union[list, Shape]) -> np.ndarray:
- """Unpack u3 values using transposed unpacking scheme.
-
- 3 bytes are unpacked into 8 values (each 3 bits).
- """
- array = array.view(np.uint8)
- shape = list(shape)
-
- # Process 3 bytes at a time
- result = []
- for i in range(0, len(array), 3):
- if i + 2 >= len(array):
- break
- byte0, byte1, byte2 = array[i:i+3]
-
- # Unpack lower 2 bits from first two bytes
- val0 = (byte0 >> 6) & 0x03
- val1 = (byte0 >> 4) & 0x03
- val2 = (byte0 >> 2) & 0x03
- val3 = byte0 & 0x03
- val4 = (byte1 >> 6) & 0x03
- val5 = (byte1 >> 4) & 0x03
- val6 = (byte1 >> 2) & 0x03
- val7 = byte1 & 0x03
-
- # Unpack MSBs from third byte
- msb0 = (byte2 >> 7) & 0x01
- msb1 = (byte2 >> 6) & 0x01
- msb2 = (byte2 >> 5) & 0x01
- msb3 = (byte2 >> 4) & 0x01
- msb4 = (byte2 >> 3) & 0x01
- msb5 = (byte2 >> 2) & 0x01
- msb6 = (byte2 >> 1) & 0x01
- msb7 = byte2 & 0x01
-
- # Combine to form 3-bit values
- result.extend([
- val0 | (msb0 << 2), val1 | (msb1 << 2), val2 | (msb2 << 2), val3 | (msb3 << 2),
- val4 | (msb4 << 2), val5 | (msb5 << 2), val6 | (msb6 << 2), val7 | (msb7 << 2)
- ])
-
- result = np.array(result, dtype=np.uint8)
- return np.resize(result, shape)
-
-
-def _pack_u6(array: np.ndarray) -> np.ndarray:
- """Pack u6 values using transposed packing scheme.
-
- 4 values (each 6 bits) are packed into 3 bytes:
- - Byte 0: bits [3:0] of values 0-1 (2 values * 4 bits = 8 bits)
- - Byte 1: bits [3:0] of values 2-3 (2 values * 4 bits = 8 bits)
- - Byte 2: bits [5:4] of all 4 values (4 values * 2 bits = 8 bits)
- """
- array = array.astype(np.uint8, casting="unsafe").flatten()
- # Pad to multiple of 4
- pad = (-len(array)) % 4
- if pad:
- array = np.concatenate([array, np.zeros(pad, dtype=np.uint8)])
-
- groups = array.reshape(-1, 4)
- result = []
-
- for group in groups:
- lower_bits = group & 0x0F # bits [3:0]
- upper_bits = (group >> 4) & 0x03 # bits [5:4]
-
- # Pack into 3 bytes
- byte0 = (lower_bits[0] << 4) | lower_bits[1]
- byte1 = (lower_bits[2] << 4) | lower_bits[3]
- byte2 = (upper_bits[0] << 6) | (upper_bits[1] << 4) | (upper_bits[2] << 2) | upper_bits[3]
-
- result.extend([byte0, byte1, byte2])
-
- return np.array(result, dtype=np.uint8)
-
-
-def _unpack_u6(array: np.ndarray, shape: Union[list, Shape]) -> np.ndarray:
- """Unpack u6 values using transposed unpacking scheme.
-
- 3 bytes are unpacked into 4 values (each 6 bits).
- """
+def _unpack_linear(array: np.ndarray, bits: int, shape: Union[list, Shape]) -> np.ndarray:
+ """Unpack values from a linear, LSB-first bit-stream (used for u3/u6), inverse of _pack_linear."""
array = array.view(np.uint8)
shape = list(shape)
num_values = int(np.prod(shape))
-
- # Process 3 bytes at a time
- result = []
- for i in range(0, len(array), 3):
- if i + 2 >= len(array):
- break
- byte0, byte1, byte2 = array[i:i+3]
-
- # Unpack lower 4 bits from first two bytes
- val0 = (byte0 >> 4) & 0x0F
- val1 = byte0 & 0x0F
- val2 = (byte1 >> 4) & 0x0F
- val3 = byte1 & 0x0F
-
- # Unpack upper 2 bits from third byte
- upper0 = (byte2 >> 6) & 0x03
- upper1 = (byte2 >> 4) & 0x03
- upper2 = (byte2 >> 2) & 0x03
- upper3 = byte2 & 0x03
-
- # Combine to form 6-bit values
- result.extend([
- val0 | (upper0 << 4), val1 | (upper1 << 4),
- val2 | (upper2 << 4), val3 | (upper3 << 4)
- ])
-
- result = np.array(result, dtype=np.uint8)
+
+ bits_unpacked = np.unpackbits(array, bitorder="little")[: num_values * bits]
+ values = bits_unpacked.reshape(-1, bits)
+ weights = (1 << np.arange(bits)).astype(np.uint8)
+ result = (values * weights).sum(axis=1).astype(np.uint8)
return np.resize(result, shape)
diff --git a/src/bindings/python/src/openvino/helpers/packing.pyi b/src/bindings/python/src/openvino/helpers/packing.pyi
index d1070cae5b9..5907e82a2e6 100644
--- a/src/bindings/python/src/openvino/helpers/packing.pyi
+++ b/src/bindings/python/src/openvino/helpers/packing.pyi
@@ -6,47 +6,22 @@ import numpy
import numpy as np
import openvino._pyopenvino
__all__: list[str] = ['Shape', 'Type', 'np', 'pack_data', 'unpack_data']
-def _pack_u3(array: numpy.ndarray) -> numpy.ndarray:
+def _pack_linear(array: numpy.ndarray, bits: int) -> numpy.ndarray:
"""
- Pack u3 values using transposed packing scheme.
-
- 8 values (each 3 bits) are packed into 3 bytes:
- - Byte 0: bits [1:0] of values 0-3 (4 values * 2 bits = 8 bits)
- - Byte 1: bits [1:0] of values 4-7 (4 values * 2 bits = 8 bits)
- - Byte 2: bits [2] of all 8 values (8 values * 1 bit = 8 bits)
-
- """
-def _pack_u6(array: numpy.ndarray) -> numpy.ndarray:
- """
- Pack u6 values using transposed packing scheme.
-
- 4 values (each 6 bits) are packed into 3 bytes:
- - Byte 0: bits [3:0] of values 0-1 (2 values * 4 bits = 8 bits)
- - Byte 1: bits [3:0] of values 2-3 (2 values * 4 bits = 8 bits)
- - Byte 2: bits [5:4] of all 4 values (4 values * 2 bits = 8 bits)
+ Pack values into a linear, LSB-first bit-stream (used for u3/u6): value i occupies bits
+ [i * bits, i * bits + bits), possibly straddling a byte boundary.
"""
-def _unpack_u3(array: numpy.ndarray, shape: typing.Union[list, openvino._pyopenvino.Shape]) -> numpy.ndarray:
+def _unpack_linear(array: numpy.ndarray, bits: int, shape: typing.Union[list, openvino._pyopenvino.Shape]) -> numpy.ndarray:
"""
- Unpack u3 values using transposed unpacking scheme.
-
- 3 bytes are unpacked into 8 values (each 3 bits).
-
- """
-def _unpack_u6(array: numpy.ndarray, shape: typing.Union[list, openvino._pyopenvino.Shape]) -> numpy.ndarray:
- """
- Unpack u6 values using transposed unpacking scheme.
-
- 3 bytes are unpacked into 4 values (each 6 bits).
-
+ Unpack values from a linear, LSB-first bit-stream (used for u3/u6), inverse of _pack_linear.
"""
def pack_data(array: numpy.ndarray, type: openvino._pyopenvino.Type) -> numpy.ndarray:
"""
Represent array values as u1, u2, u3, u4, u6 or i4 openvino element type and pack them into uint8 numpy array.
- For u1, u4, i4: Standard bit packing where 8 % bitwidth == 0
- For u3: Transposed packing - 8 values in 3 bytes
- For u6: Transposed packing - 4 values in 3 bytes
+ For u1, u2, u4, i4: Standard bit packing where 8 % bitwidth == 0
+ For u3, u6: Linear LSB-first bit-stream packing, values may straddle a byte boundary
If the number of elements in array is odd we pad them with zero value to be able to fit the bit
sequence into the uint8 array.
@@ -65,9 +40,8 @@ def unpack_data(array: numpy.ndarray, type: openvino._pyopenvino.Type, shape: ty
"""
Extract openvino element type values from array into new uint8/int8 array given shape.
- For u1, u4, i4: Standard bit unpacking where 8 % bitwidth == 0
- For u3: Transposed unpacking - 8 values from 3 bytes
- For u6: Transposed unpacking - 4 values from 3 bytes
+ For u1, u2, u4, i4: Standard bit unpacking where 8 % bitwidth == 0
+ For u3, u6: Linear LSB-first bit-stream unpacking, values may straddle a byte boundary
Example: uint8 value [120] can be represented as two u4 values and be unpacked into [7, 8]
because [120] bit representation is [01111000] will be viewed as [0111, 1000],
diff --git a/src/bindings/python/tests/test_graph/test_constant.py b/src/bindings/python/tests/test_graph/test_constant.py
index c2091051b05..5766a6c074b 100644
--- a/src/bindings/python/tests/test_graph/test_constant.py
+++ b/src/bindings/python/tests/test_graph/test_constant.py
@@ -292,6 +292,24 @@ def test_constant_direct_packing(ov_type, src_dtype, shared_flag, data_getter):
assert not np.shares_memory(unpacked, data)
+ ("ov_type", "high"),
+ [
+ (Type.u3, 8),
+ (Type.u6, 64),
+ ],
+)
[email protected]("num_elements", [1, 3, 13, 64])
+def test_pack_data_matches_core_layout(ov_type, high, num_elements):
+ # `pack_data` must produce byte-for-byte the same buffer as the core packs a Constant into,
+ # including sizes where the bit-stream ends in the middle of the last byte.
+ data = (np.arange(num_elements) % high).astype(np.uint8)
+
+ ov_const = ops.constant(data, dtype=ov_type)
+
+ assert np.array_equal(ov_const.data, pack_data(data, ov_type))
+
+
@pytest.mark.parametrize(
("shared_flag"),
[
diff --git a/src/bindings/python/tests/test_runtime/test_tensor.py b/src/bindings/python/tests/test_runtime/test_tensor.py
index 6fec354357c..00de7a942c2 100644
--- a/src/bindings/python/tests/test_runtime/test_tensor.py
+++ b/src/bindings/python/tests/test_runtime/test_tensor.py
@@ -422,15 +422,18 @@ def test_cannot_get_strides_for_packed_tensor(ov_type):
[
(ov.Type.u1),
(ov.Type.u2),
+ (ov.Type.u3),
(ov.Type.u4),
+ (ov.Type.u6),
(ov.Type.i4),
],
)
def test_init_with_packed_buffer(dtype, ov_type):
shape = [1, 3, 32, 32]
- fit = np.dtype(dtype).itemsize * 8 / ov_type.bitwidth
- assert np.prod(shape) % fit == 0
- size = int(np.prod(shape) // fit)
+ byte_size = (np.prod(shape) * ov_type.bitwidth + 7) // 8
+ itemsize = np.dtype(dtype).itemsize
+ assert byte_size % itemsize == 0 # noqa: S001 - flake8-pep3101 known bug, misdetects modulo as string formatting
+ size = int(byte_size // itemsize)
buffer = np.random.normal(size=size).astype(dtype)
ov_tensor = ov.Tensor(buffer, shape, ov_type)
assert ov_tensor.data.nbytes == ov_tensor.byte_size
@@ -683,18 +686,14 @@ def test_tensor_from_pillow(numpy_dtype, shape):
def test_pack_unpack_u3_numerical():
"""Test u3 packing/unpacking with known numerical values."""
- # 8 values packed into 3 bytes
+ # 8 values packed into 3 bytes, linear LSB-first bit-stream (value i at bits [3i, 3i+3))
# Decimal values: [0, 1, 2, 3, 4, 5, 6, 7]
# In binary: [000, 001, 010, 011, 100, 101, 110, 111]
data = np.array([0, 1, 2, 3, 4, 5, 6, 7], dtype=np.uint8)
packed = pack_data(data, ov.Type.u3)
- # Expected packing:
- # Byte 0: bits[1:0] of values 0-3 = [00, 01, 10, 11] = 0x1B
- # Byte 1: bits[1:0] of values 4-7 = [00, 01, 10, 11] = 0x1B
- # Byte 2: bits[2] of all 8 values = [0,0,0,0,1,1,1,1] = 0x0F
- expected = np.array([0x1B, 0x1B, 0x0F], dtype=np.uint8)
+ expected = np.array([0x88, 0xC6, 0xFA], dtype=np.uint8)
assert len(packed) == 3
assert np.array_equal(packed, expected), f"Expected {expected.tolist()}, got {packed.tolist()}"
@@ -721,17 +720,13 @@ def test_pack_unpack_u3_edge_cases():
def test_pack_unpack_u6_numerical():
- # 4 values packed into 3 bytes
+ # 4 values packed into 3 bytes, linear LSB-first bit-stream (value i at bits [6i, 6i+6))
# Decimal values: [0, 15, 48, 63]
# In binary: [000000, 001111, 110000, 111111]
data = np.array([0, 15, 48, 63], dtype=np.uint8)
packed = pack_data(data, ov.Type.u6)
- # Expected packing:
- # Byte 0: bits[3:0] of values 0-1 = [0000, 1111] = 0x0F
- # Byte 1: bits[3:0] of values 2-3 = [0000, 1111] = 0x0F
- # Byte 2: bits[5:4] of all 4 values = [00, 00, 11, 11] = 0x0F
- expected = np.array([0x0F, 0x0F, 0x0F], dtype=np.uint8)
+ expected = np.array([0xC0, 0x03, 0xFF], dtype=np.uint8)
assert len(packed) == 3
assert np.array_equal(packed, expected), f"Expected {expected.tolist()}, got {packed.tolist()}"
diff --git a/src/core/dev_api/openvino/core/type/element_iterator.hpp b/src/core/dev_api/openvino/core/type/element_iterator.hpp
index d6c9593e61f..09369a14b27 100644
--- a/src/core/dev_api/openvino/core/type/element_iterator.hpp
+++ b/src/core/dev_api/openvino/core/type/element_iterator.hpp
@@ -28,11 +28,14 @@ namespace element {
/**
* @brief Checks if element type is N in-raw bits type.
*
+ * The values are packed as a linear bit-stream, value `i` occupies bits `[i * bitwidth, i * bitwidth + bitwidth)`
+ * and can straddle a byte boundary if the bit width is not a divisor of 8 (u3, u6).
+ *
* @param et Element type to check
* @return True if element type is bit type otherwise false.
*/
constexpr bool is_bit_type(Type_t et) {
- return et == u1 || et == u2;
+ return et == u1 || et == u2 || et == u3 || et == u6;
}
/**
@@ -45,18 +48,6 @@ constexpr bool is_nibble_type(Type_t et) {
return et == u4 || et == i4 || et == nf4 || et == f4e2m1;
}
-/**
- * @brief Checks if element type is split bit type.
- *
- * The value is stored in byte(s) like [b0, b1, x, .., x, b2, b3].
- *
- * @param et Element type to check
- * @return True if element type is split bit type otherwise false.
- */
-constexpr bool is_split_bit_type(Type_t et) {
- return et == u3 || et == u6;
-}
-
/**
* @brief Checks element type is using only N bytes as value.
*
@@ -64,7 +55,7 @@ constexpr bool is_split_bit_type(Type_t et) {
* @return True if element type use byte(s) for its value, false otherwise.
*/
constexpr bool is_byte_type(Type_t et) {
- return !is_bit_type(et) && !is_split_bit_type(et) && !is_nibble_type(et) && et != string;
+ return !is_bit_type(et) && !is_nibble_type(et) && et != string;
}
/**
@@ -130,7 +121,7 @@ constexpr size_t bit_width<Type_t::f4e2m1>() {
/**
* @brief The BitProxy value class used by ov::element::Iterator to access values which has no standard byte(s) layout.
*
- * It used by iterator to access values represented by precisions like u2, i4, u6 etc. in the way like stored
+ * It used by iterator to access values represented by precisions like u1, u2, u3, i4, u6 etc. in the way like stored
* on bytes.
* The R/W access is done via conversion and copy assignment operators.
* The public members are used to work on sub-byte value like on its fundamental type defined by T.
@@ -143,7 +134,7 @@ template <class T, Type_t ET, class Enable = void>
class BitProxy {};
/**
- * @brief The BitProxy specialization for types which are represented by N in-raw bits in byte.
+ * @brief The BitProxy specialization for types which are represented by N bits in the packed bit-stream.
*
* @tparam T Fundamental type of sub-byte value which must be same as fundamental type of element::Type_t.
* @tparam ET OpenVINO element type.
@@ -157,9 +148,9 @@ private:
using Bits = std::conditional_t<std::is_const_v<T>, const uint8_t, uint8_t>;
static constexpr size_t m_bits = bit_width<ET>(); //!< Number of bit for single value.
+ static constexpr bool m_straddles_bytes = (8 % m_bits) != 0; //!< Value can span two bytes.
static constexpr size_t m_num_values = 8 / m_bits; //!< Number values in byte.
static constexpr size_t m_shift_init = is_lsb_packed(ET) ? 0 : 8 - m_bits; //!< Initial value for bit shift.
- static constexpr size_t m_shift_last = is_lsb_packed(ET) ? 8 - m_bits : 0; //!< Last value for bit shift.
Bits* m_ptr; //!< Pointer to T as Bits used to get value from bits.
size_t m_bit_shift; //!< Current bit shift to get value.
@@ -168,13 +159,34 @@ private:
uint8_t get_bit_value() const {
constexpr auto value_mask = util::make_n_bit_mask(m_bits);
- return (*m_ptr >> m_bit_shift) & value_mask;
+ if constexpr (m_straddles_bytes) {
+ // Read the next byte only if the value spans it, to not access memory past the buffer end.
+ auto bits = static_cast<uint16_t>(m_ptr[0]);
+ if (m_bit_shift + m_bits > 8) {
+ bits |= static_cast<uint16_t>(m_ptr[1]) << 8U;
+ }
+ return static_cast<uint8_t>((bits >> m_bit_shift) & value_mask);
+ } else {
+ return (*m_ptr >> m_bit_shift) & value_mask;
+ }
}
void set_bit_value(uint8_t value) {
constexpr auto value_mask = util::make_n_bit_mask(m_bits);
- *m_ptr &= ~(value_mask << m_bit_shift);
- *m_ptr |= value << m_bit_shift;
+ if constexpr (m_straddles_bytes) {
+ const auto shifted_mask = static_cast<uint16_t>(value_mask << m_bit_shift);
+ const auto shifted_value = static_cast<uint16_t>(value << m_bit_shift);
+
+ m_ptr[0] = static_cast<uint8_t>((m_ptr[0] & ~static_cast<uint8_t>(shifted_mask)) |
+ static_cast<uint8_t>(shifted_value));
+ if (m_bit_shift + m_bits > 8) {
+ m_ptr[1] = static_cast<uint8_t>((m_ptr[1] & ~static_cast<uint8_t>(shifted_mask >> 8U)) |
+ static_cast<uint8_t>(shifted_value >> 8U));
+ }
+ } else {
+ *m_ptr &= ~(value_mask << m_bit_shift);
+ *m_ptr |= value << m_bit_shift;
+ }
}
public:
@@ -291,108 +303,6 @@ public:
}
};
-/**
- * @brief The BitProxy specialization for u3, u6 precisions.
- *
- * @note The input pointer must point on buffer which has got 3 * n bytes.
- *
- * @tparam T Fundamental type of sub-byte value which must be same as fundamental type of element::Type_t.
- * @tparam ET OpenVINO element type.
- */
-template <class T, Type_t ET>
-class BitProxy<T, ET, std::enable_if_t<is_split_bit_type(ET)>> {
-private:
- template <Type_t, class>
- friend class Iterator; //!< Iterator class is friend to access private members to manipulate pointer.
-
- static constexpr size_t m_bits = bit_width<ET>(); //!< Number of bit for single value.
- static constexpr size_t m_num_values = (3 * 8) / m_bits; //!< Number values in byte.
- static constexpr size_t m_shift_init = m_num_values - 1; //!< Initial value for bit shift.
-
- struct ByteValue {
- uint8_t b0;
- uint8_t b1;
- uint8_t b2;
- };
-
- union {
- T* m_ptr; //!< Pointer to T buffer.
- ByteValue* m_bytes; //!< Pointer to buffer as 3 bytes representation.
- };
-
- size_t m_bit_shift; //!< Current bit shift to get value.
-
- constexpr BitProxy(T* ptr) noexcept : m_ptr{ptr}, m_bit_shift{m_shift_init} {}
-
-public:
- using value_type = std::decay_t<T>; //!< Fundamental type of sub-byte.
-
- /**
- * @brief Compare proxy value is equal than rhs.
- *
- * @tparam U Type of value to compare.
- * @param rhs Value to compare.
- * @return True if equal, false otherwise.
- */
- template <class U>
- constexpr bool operator==(const U& rhs) const {
- return static_cast<value_type>(*this) == rhs;
- }
-
- /**
- * @brief Compare proxy value is less than rhs.
- *
- * @tparam U Type of value to compare.
- * @param rhs Value to compare.
- * @return True if less otherwise false.
- */
- template <class U>
- constexpr bool operator<(const U& rhs) const {
- return static_cast<value_type>(*this) < rhs;
- }
-
- /**
- * @brief Converts to fundamental type.
- *
- * @return Value of BitProxy.
- */
- operator value_type() const {
- constexpr uint16_t lower_mask_bits = 16 / m_num_values;
- constexpr uint16_t upper_mask_bits = 8 / m_num_values;
- constexpr uint16_t mask_lower = util::make_n_bit_mask(lower_mask_bits);
- constexpr uint16_t mask_upper = util::make_n_bit_mask(upper_mask_bits) << lower_mask_bits;
-
- // get lower part of value
- uint16_t v = ((m_bytes->b0 << 8U) | m_bytes->b1) >> (lower_mask_bits * m_bit_shift);
- v &= mask_lower;
- // get upper part of value
- v |= ((m_bytes->b2 << lower_mask_bits) >> (upper_mask_bits * m_bit_shift)) & mask_upper;
- return static_cast<value_type>(v);
- }
-
- /**
- * @brief Sets current ProxyBit to value.
- * @param v Value to be set.
- */
- BitProxy<T, ET>& operator=(const value_type v) {
- constexpr uint16_t lower_mask_bits = 16 / m_num_values;
- constexpr uint16_t upper_mask_bits = 8 / m_num_values;
- constexpr uint16_t mask_lower = util::make_n_bit_mask(lower_mask_bits);
- constexpr uint16_t mask_upper = util::make_n_bit_mask(upper_mask_bits) << lower_mask_bits;
-
- uint16_t tmp = (m_bytes->b0 << 8U) | m_bytes->b1;
- tmp &= ~(mask_lower << (lower_mask_bits * m_bit_shift));
- tmp |= (v & mask_lower) << (lower_mask_bits * m_bit_shift);
- m_bytes->b0 = tmp >> 8U;
- m_bytes->b1 = tmp & 0x00ff;
-
- tmp = m_bytes->b2 & ~((mask_upper >> lower_mask_bits) << (upper_mask_bits * m_bit_shift));
- tmp |= (((v & mask_upper) >> lower_mask_bits) << (upper_mask_bits * m_bit_shift));
- m_bytes->b2 = tmp & 0x00ff;
- return *this;
- }
-};
-
/**
* @brief Put BitProxy value to output stream.
*
@@ -441,17 +351,13 @@ public:
if constexpr (is_nibble_type(ET)) {
m_et_ptr.m_bit_shift ^= m_et_ptr.m_bits;
m_et_ptr.m_ptr += static_cast<std::ptrdiff_t>(m_et_ptr.m_bit_shift == m_et_ptr.m_shift_init);
- } else if constexpr (is_split_bit_type(ET)) {
- --m_et_ptr.m_bit_shift;
- m_et_ptr.m_bit_shift = m_et_ptr.m_bit_shift % m_et_ptr.m_num_values;
- m_et_ptr.m_ptr += (m_et_ptr.m_bit_shift == m_et_ptr.m_shift_init) ? 3 : 0;
+ } else if constexpr (is_lsb_packed(ET)) {
+ m_et_ptr.m_bit_shift += m_et_ptr.m_bits;
+ m_et_ptr.m_ptr += static_cast<std::ptrdiff_t>(m_et_ptr.m_bit_shift / 8);
+ m_et_ptr.m_bit_shift %= 8;
} else {
- if constexpr (is_lsb_packed(ET)) {
- m_et_ptr.m_bit_shift += m_et_ptr.m_bits;
- } else {
- m_et_ptr.m_bit_shift -= m_et_ptr.m_bits;
- }
- m_et_ptr.m_bit_shift = m_et_ptr.m_bit_shift % (m_et_ptr.m_num_values * m_et_ptr.m_bits);
+ m_et_ptr.m_bit_shift -= m_et_ptr.m_bits;
+ m_et_ptr.m_bit_shift = m_et_ptr.m_bit_shift % 8;
m_et_ptr.m_ptr += static_cast<std::ptrdiff_t>(m_et_ptr.m_bit_shift == m_et_ptr.m_shift_init);
}
return *this;
@@ -469,14 +375,11 @@ public:
if (n % m_et_ptr.m_num_values) {
++*this;
}
- } else if constexpr (is_split_bit_type(ET)) {
- const auto advance = n + m_et_ptr.m_shift_init - m_et_ptr.m_bit_shift;
- m_et_ptr.m_bit_shift = m_et_ptr.m_shift_init - (advance % m_et_ptr.m_num_values);
- m_et_ptr.m_ptr += 3 * (advance / m_et_ptr.m_num_values);
} else if constexpr (is_lsb_packed(ET)) {
- const auto advance = n + m_et_ptr.m_bit_shift / m_et_ptr.m_bits;
- m_et_ptr.m_bit_shift = (advance % m_et_ptr.m_num_values) * m_et_ptr.m_bits;
- m_et_ptr.m_ptr += advance / m_et_ptr.m_num_values;
+ const auto advance =
+ static_cast<difference_type>(m_et_ptr.m_bit_shift) + n * static_cast<difference_type>(m_et_ptr.m_bits);
+ m_et_ptr.m_bit_shift = static_cast<size_t>(advance % 8);
+ m_et_ptr.m_ptr += advance / 8;
} else {
const auto advance = n + (m_et_ptr.m_shift_init - m_et_ptr.m_bit_shift) / m_et_ptr.m_bits;
m_et_ptr.m_bit_shift = m_et_ptr.m_shift_init - (advance % m_et_ptr.m_num_values) * m_et_ptr.m_bits;
@@ -495,18 +398,15 @@ public:
if constexpr (is_nibble_type(ET)) {
m_et_ptr.m_bit_shift ^= m_et_ptr.m_bits;
m_et_ptr.m_ptr -= static_cast<std::ptrdiff_t>(m_et_ptr.m_bit_shift == 4);
- } else if constexpr (is_split_bit_type(ET)) {
- ++m_et_ptr.m_bit_shift;
- m_et_ptr.m_bit_shift = m_et_ptr.m_bit_shift % m_et_ptr.m_num_values;
- m_et_ptr.m_ptr -= m_et_ptr.m_bit_shift == 0 ? 3 : 0;
+ } else if constexpr (is_lsb_packed(ET)) {
+ // Biased by one byte to keep the arithmetic unsigned when the value starts in the previous byte.
+ const auto shift = m_et_ptr.m_bit_shift + 8 - m_et_ptr.m_bits;
+ m_et_ptr.m_ptr += static_cast<std::ptrdiff_t>(shift / 8) - 1;
+ m_et_ptr.m_bit_shift = shift % 8;
} else {
- if constexpr (is_lsb_packed(ET)) {
- m_et_ptr.m_bit_shift -= m_et_ptr.m_bits;
- } else {
- m_et_ptr.m_bit_shift += m_et_ptr.m_bits;
- }
- m_et_ptr.m_bit_shift = m_et_ptr.m_bit_shift % (m_et_ptr.m_num_values * m_et_ptr.m_bits);
- m_et_ptr.m_ptr -= static_cast<std::ptrdiff_t>(m_et_ptr.m_bit_shift == m_et_ptr.m_shift_last);
+ m_et_ptr.m_bit_shift += m_et_ptr.m_bits;
+ m_et_ptr.m_bit_shift = m_et_ptr.m_bit_shift % 8;
+ m_et_ptr.m_ptr -= static_cast<std::ptrdiff_t>(m_et_ptr.m_bit_shift == 0);
}
return *this;
}
@@ -523,14 +423,11 @@ public:
if (n % m_et_ptr.m_num_values) {
--*this;
}
- } else if constexpr (is_split_bit_type(ET)) {
- const auto advance = m_et_ptr.m_bit_shift + n;
- m_et_ptr.m_bit_shift = advance % m_et_ptr.m_num_values;
- m_et_ptr.m_ptr -= 3 * (advance / m_et_ptr.m_num_values);
} else if constexpr (is_lsb_packed(ET)) {
- const auto advance = n + (m_et_ptr.m_shift_last - m_et_ptr.m_bit_shift) / m_et_ptr.m_bits;
- m_et_ptr.m_bit_shift = m_et_ptr.m_shift_last - (advance % m_et_ptr.m_num_values) * m_et_ptr.m_bits;
- m_et_ptr.m_ptr -= advance / m_et_ptr.m_num_values;
+ const auto advance =
+ n * static_cast<difference_type>(m_et_ptr.m_bits) - static_cast<difference_type>(m_et_ptr.m_bit_shift);
+ m_et_ptr.m_bit_shift = static_cast<size_t>((8 - advance % 8) % 8);
+ m_et_ptr.m_ptr -= (advance + 7) / 8;
} else {
const auto advance = m_et_ptr.m_bit_shift / m_et_ptr.m_bits + n;
m_et_ptr.m_bit_shift = (advance % m_et_ptr.m_num_values) * m_et_ptr.m_bits;
diff --git a/src/core/src/memory_util.cpp b/src/core/src/memory_util.cpp
index 9d11c9d9210..1cc6aebf14c 100644
--- a/src/core/src/memory_util.cpp
+++ b/src/core/src/memory_util.cpp
@@ -10,34 +10,21 @@
namespace ov::util {
namespace {
-constexpr size_t split_unit_bit_size = 24;
-constexpr size_t split_unit_byte_size = split_unit_bit_size / 8;
-size_t get_split_bit_memory_size(const element::Type& type, const size_t elements_count) {
- const size_t elements_per_storage_unit = split_unit_bit_size / type.bitwidth();
- auto units_count = elements_count / elements_per_storage_unit;
- units_count += static_cast<size_t>(units_count * elements_per_storage_unit != elements_count);
- return units_count * split_unit_byte_size;
-}
-
-size_t get_split_elements_count(const element::Type& type, const size_t memory_size) {
- const size_t elements_per_storage_unit = split_unit_bit_size / type.bitwidth();
- const size_t storage_unit_count = memory_size / split_unit_byte_size;
- size_t elements_count;
- OPENVINO_ASSERT(!mul_overflow<size_t>(storage_unit_count, elements_per_storage_unit, elements_count));
- return elements_count;
-}
-
-size_t get_bit_memory_size(const element::Type& type, const size_t shape_size) {
- const auto elements_per_byte = 8 / type.bitwidth();
- auto byte_size = shape_size / elements_per_byte;
- byte_size += static_cast<size_t>((byte_size * elements_per_byte) != shape_size);
- return byte_size;
+size_t get_bit_memory_size(const element::Type& type, const size_t elements_count) {
+ const auto bit_width = type.bitwidth();
+ // Any 8 elements occupy exactly bit_width bytes, so ceil(elements_count * bit_width / 8) is taken in two steps
+ const auto full_bytes = (elements_count / 8) * bit_width;
+ const auto tail_bytes = ((elements_count % 8) * bit_width + 7) / 8;
+ return full_bytes + tail_bytes;
}
size_t get_bit_elements_count(const element::Type& type, const size_t memory_size) {
- const size_t elements_per_byte = 8 / type.bitwidth();
+ const auto bit_width = type.bitwidth();
+ // Any bit_width bytes hold exactly 8 elements, so memory_size * 8 / bit_width is taken in two steps
size_t elements_count;
- OPENVINO_ASSERT(!mul_overflow<size_t>(memory_size, elements_per_byte, elements_count));
+ const auto tail_elements = ((memory_size % bit_width) * 8) / bit_width;
+ OPENVINO_ASSERT(!mul_overflow<size_t>(memory_size / bit_width, 8, elements_count) &&
+ !add_overflow<size_t>(elements_count, tail_elements, elements_count));
return elements_count;
}
} // namespace
@@ -45,8 +32,6 @@ size_t get_bit_elements_count(const element::Type& type, const size_t memory_siz
size_t get_memory_size(const element::Type& type, const size_t n) {
if (n == 0) {
return n;
- } else if (element::is_split_bit_type(type)) {
- return get_split_bit_memory_size(type, n);
} else if (element::is_bit_type(type) || element::is_nibble_type(type)) {
return get_bit_memory_size(type, n);
} else {
@@ -70,8 +55,6 @@ std::optional<size_t> get_memory_size_safe(const element::Type& type, const ov::
size_t get_elements_capacity(const element::Type& type, const size_t memory_size) {
if (type.bitwidth() == 0) {
return 0;
- } else if (element::is_split_bit_type(type)) {
- return get_split_elements_count(type, memory_size);
} else if (element::is_bit_type(type) || element::is_nibble_type(type)) {
return get_bit_elements_count(type, memory_size);
} else {
diff --git a/src/core/src/op/constant.cpp b/src/core/src/op/constant.cpp
index 1b6f2546305..15c31318ce9 100644
--- a/src/core/src/op/constant.cpp
+++ b/src/core/src/op/constant.cpp
@@ -291,25 +291,16 @@ void Constant::set_unused_bits(void* buffer) const {
const auto num_elements = shape_size(m_shape);
if (element::is_bit_type(m_element_type)) {
- constexpr size_t storage_unit_byte_size = 1;
- const auto not_aligned_elements = num_elements % (8 / m_element_type.bitwidth());
- const uint8_t not_used_bits_mask = element::is_lsb_packed(m_element_type)
- ? 0xff << (m_element_type.bitwidth() * not_aligned_elements)
- : 0xff >> (m_element_type.bitwidth() * not_aligned_elements);
- reinterpret_cast<uint8_t*>(buffer)[byte_size - storage_unit_byte_size] &= ~not_used_bits_mask;
+ // Mask off the unused tail bits of the last byte, fully unused bytes are not allocated.
+ if (const auto tail_bits = ((num_elements % 8) * m_element_type.bitwidth()) % 8) {
+ const uint8_t used_bits_mask = element::is_lsb_packed(m_element_type)
+ ? static_cast<uint8_t>(0xffU >> (8 - tail_bits))
+ : static_cast<uint8_t>(0xffU << (8 - tail_bits));
+ reinterpret_cast<uint8_t*>(buffer)[byte_size - 1] &= used_bits_mask;
+ }
} else if (element::is_nibble_type(m_element_type) && (num_elements % 2)) {
constexpr size_t storage_unit_byte_size = 1;
reinterpret_cast<uint8_t*>(buffer)[byte_size - storage_unit_byte_size] &= 0x0FU;
- } else if (element::is_split_bit_type(m_element_type)) {
- constexpr size_t storage_unit_byte_size = 3;
- const auto num_values = (24U / m_element_type.bitwidth());
- const auto not_aligned_elements = num_elements % num_values;
- const uint16_t not_used_upper_mask = ~(0xffff >> (not_aligned_elements * (16U / num_values)));
-
- auto ptr = reinterpret_cast<uint8_t*>(buffer) + (byte_size - storage_unit_byte_size);
- ptr[0] &= not_used_upper_mask >> 8U;
- ptr[1] &= not_used_upper_mask & 0x00ff;
- ptr[2] &= ~(0xff >> (not_aligned_elements * (8U / num_values)));
}
}
}
diff --git a/src/core/tests/constant.cpp b/src/core/tests/constant.cpp
index 0f29758bbb4..da7550bb89c 100644
--- a/src/core/tests/constant.cpp
+++ b/src/core/tests/constant.cpp
@@ -970,9 +970,9 @@ TEST(constant, uint3_string) {
EXPECT_THAT(v, ElementsAre(3, 0, 1, 2, 4, 7, 5, 6));
const auto p = c.get_data_ptr<uint8_t>();
- EXPECT_EQ(p[0], 0b11000110);
- EXPECT_EQ(p[1], 0b00110110);
- EXPECT_EQ(p[2], 0b00001111);
+ EXPECT_EQ(p[0], 0b01000011);
+ EXPECT_EQ(p[1], 0b11000100);
+ EXPECT_EQ(p[2], 0b11010111);
EXPECT_EQ(c.convert_value_to_string(6), "5");
EXPECT_THAT(c.get_value_strings(), ElementsAre("3", "0", "1", "2", "4", "7", "5", "6"));
@@ -989,12 +989,11 @@ TEST(constant, uint3_string_broadcast) {
EXPECT_THAT(v, Each(5));
const auto p = c.get_data_ptr<uint8_t>();
- EXPECT_EQ(p[0], 0b01010101);
- EXPECT_EQ(p[1], 0b01000000);
- EXPECT_EQ(p[2], 0b11111000);
+ EXPECT_EQ(p[0], 0b01101101);
+ EXPECT_EQ(p[1], 0b01011011);
}
-TEST(constant, uint3_vector_less_than_one_storage_unit) {
+TEST(constant, uint3_vector_with_tail_bits) {
const auto shape = Shape{3};
const auto input = std::vector<uint8_t>{5, 3, 1};
@@ -1005,12 +1004,11 @@ TEST(constant, uint3_vector_less_than_one_storage_unit) {
EXPECT_THAT(v, ElementsAre(5, 3, 1));
const auto p = c.get_vector<uint8_t>();
- EXPECT_EQ(p[0], 0b01110100);
+ EXPECT_EQ(p[0], 0b01011101);
EXPECT_EQ(p[1], 0);
- EXPECT_EQ(p[2], 0b10000000);
}
-TEST(constant, uint3_vector_greater_than_one_storage_unit) {
+TEST(constant, uint3_vector_multiple_bytes_with_tail_bits) {
const auto shape = Shape{10};
const auto input = std::vector<uint8_t>{2, 3, 1, 0, 4, 5, 6, 7, 5, 2};
@@ -1021,13 +1019,10 @@ TEST(constant, uint3_vector_greater_than_one_storage_unit) {
EXPECT_THAT(v, ElementsAre(2, 3, 1, 0, 4, 5, 6, 7, 5, 2));
const auto p = c.get_vector<uint8_t>();
- EXPECT_EQ(p[0], 0b10110100);
- EXPECT_EQ(p[1], 0b00011011);
- EXPECT_EQ(p[2], 0b00001111);
-
- EXPECT_EQ(p[3], 0b01100000);
- EXPECT_EQ(p[4], 0);
- EXPECT_EQ(p[5], 0b10000000);
+ EXPECT_EQ(p[0], 0b01011010);
+ EXPECT_EQ(p[1], 0b11000000);
+ EXPECT_EQ(p[2], 0b11111010);
+ EXPECT_EQ(p[3], 0b00010101);
}
TEST(constant, uint3_vector_broadcast) {
@@ -1039,9 +1034,27 @@ TEST(constant, uint3_vector_broadcast) {
EXPECT_THAT(v, Each(2));
const auto p = c.get_data_ptr<uint8_t>();
- EXPECT_EQ(p[0], 0b10101010);
- EXPECT_EQ(p[1], 0b10101010);
- EXPECT_EQ(p[2], 0b00000000);
+ EXPECT_EQ(p[0], 0b10010010);
+ EXPECT_EQ(p[1], 0b00100100);
+ EXPECT_EQ(p[2], 0b01001001);
+}
+
+TEST(constant, uint3_single_element) {
+ op::v0::Constant c(element::u3, Shape{1}, std::vector<uint8_t>{7});
+
+ ASSERT_EQ(c.get_byte_size(), 1);
+ EXPECT_EQ(c.get_data_ptr<uint8_t>()[0], 0b00000111);
+ EXPECT_THAT(c.cast_vector<uint8_t>(), ElementsAre(7));
+}
+
+TEST(constant, uint3_unused_tail_bits_are_zeroed) {
+ // 5 values * 3 bits = 15 bits -> 2 bytes, the most significant bit of the last byte is unused.
+ op::v0::Constant c(element::u3, Shape{5}, std::vector<uint8_t>{7, 7, 7, 7, 7});
+
+ ASSERT_EQ(c.get_byte_size(), 2);
+ const auto p = c.get_data_ptr<uint8_t>();
+ EXPECT_EQ(p[0], 0xff);
+ EXPECT_EQ(p[1], 0x7f);
}
TEST(constant, uint3_write_then_cast_custom_type) {
@@ -1173,9 +1186,9 @@ TEST(constant, uint6_string) {
EXPECT_THAT(v, ElementsAre(4, 9, 15, 16));
const auto p = c.get_data_ptr<uint8_t>();
- EXPECT_EQ(p[0], 0x49);
- EXPECT_EQ(p[1], 0xf0);
- EXPECT_EQ(p[2], 0b00000001);
+ EXPECT_EQ(p[0], 0x44);
+ EXPECT_EQ(p[1], 0xf2);
+ EXPECT_EQ(p[2], 0x40);
EXPECT_EQ(c.convert_value_to_string(2), "15");
EXPECT_THAT(c.get_value_strings(), ElementsAre("4", "9", "15", "16"));
@@ -1192,12 +1205,12 @@ TEST(constant, uint6_string_broadcast) {
EXPECT_THAT(v, Each(5));
const auto p = c.get_data_ptr<uint8_t>();
- EXPECT_EQ(p[0], 0x55);
- EXPECT_EQ(p[1], 0x55);
- EXPECT_EQ(p[2], 0b00000000);
+ EXPECT_EQ(p[0], 0x45);
+ EXPECT_EQ(p[1], 0x51);
+ EXPECT_EQ(p[2], 0x14);
}
-TEST(constant, uint6_vector_less_than_one_storage_unit) {
+TEST(constant, uint6_vector_with_tail_bits) {
const auto shape = Shape{3};
const auto input = std::vector<uint8_t>{5, 23, 1};
@@ -1208,12 +1221,12 @@ TEST(constant, uint6_vector_less_than_one_storage_unit) {
EXPECT_THAT(v, ElementsAre(5, 23, 1));
const auto p = c.get_data_ptr<uint8_t>();
- EXPECT_EQ(p[0], 0x57);
- EXPECT_EQ(p[1], 0x10);
- EXPECT_EQ(p[2], 0b00010000);
+ EXPECT_EQ(p[0], 0xc5);
+ EXPECT_EQ(p[1], 0x15);
+ EXPECT_EQ(p[2], 0);
}
-TEST(constant, uint6_vector_greater_than_one_storage_unit) {
+TEST(constant, uint6_vector_multiple_bytes_with_tail_bits) {
const auto shape = Shape{6};
const auto input = std::vector<uint8_t>{25, 3, 1, 0, 45, 5};
@@ -1224,13 +1237,11 @@ TEST(constant, uint6_vector_greater_than_one_storage_unit) {
EXPECT_THAT(v, ElementsAre(25, 3, 1, 0, 45, 5));
const auto p = c.get_vector<uint8_t>();
- EXPECT_EQ(p[0], 0x93);
+ EXPECT_EQ(p[0], 0xd9);
EXPECT_EQ(p[1], 0x10);
- EXPECT_EQ(p[2], 0b01000000);
-
- EXPECT_EQ(p[3], 0xd5);
- EXPECT_EQ(p[4], 0);
- EXPECT_EQ(p[5], 0b10000000);
+ EXPECT_EQ(p[2], 0x00);
+ EXPECT_EQ(p[3], 0x6d);
+ EXPECT_EQ(p[4], 0x01);
}
TEST(constant, uint6_vector_broadcast) {
@@ -1242,9 +1253,29 @@ TEST(constant, uint6_vector_broadcast) {
EXPECT_THAT(v, Each(45));
const auto p = c.get_data_ptr<uint8_t>();
- EXPECT_EQ(p[0], 0xdd);
- EXPECT_EQ(p[1], 0xdd);
- EXPECT_EQ(p[2], 0b10101010);
+ EXPECT_EQ(p[0], 0x6d);
+ EXPECT_EQ(p[1], 0xdb);
+ EXPECT_EQ(p[2], 0xb6);
+}
+
+TEST(constant, uint6_single_element) {
+ op::v0::Constant c(element::u6, Shape{1}, std::vector<uint8_t>{63});
+
+ ASSERT_EQ(c.get_byte_size(), 1);
+ EXPECT_EQ(c.get_data_ptr<uint8_t>()[0], 0b00111111);
+ EXPECT_THAT(c.cast_vector<uint8_t>(), ElementsAre(63));
+}
+
+TEST(constant, uint6_unused_tail_bits_are_zeroed) {
+ // 5 values * 6 bits = 30 bits -> 4 bytes, the two most significant bits of the last byte are unused.
+ op::v0::Constant c(element::u6, Shape{5}, std::vector<uint8_t>{63, 63, 63, 63, 63});
+
+ ASSERT_EQ(c.get_byte_size(), 4);
+ const auto p = c.get_data_ptr<uint8_t>();
+ EXPECT_EQ(p[0], 0xff);
+ EXPECT_EQ(p[1], 0xff);
+ EXPECT_EQ(p[2], 0xff);
+ EXPECT_EQ(p[3], 0x3f);
}
TEST(constant, uint6_write_then_cast_custom_type) {
diff --git a/src/core/tests/element_iterator_test.cpp b/src/core/tests/element_iterator_test.cpp
index 0bf59ba0b93..794bd160c44 100644
--- a/src/core/tests/element_iterator_test.cpp
+++ b/src/core/tests/element_iterator_test.cpp
@@ -7,6 +7,8 @@
#include <gmock/gmock.h>
#include <array>
+#include <utility>
+#include <vector>
#include "openvino/runtime/tensor.hpp"
@@ -194,12 +196,17 @@ TEST(ElementIteratorTest, write_u3_data) {
std::copy(input.begin(), input.end(), iter);
- EXPECT_THAT(output, ElementsAre(0b10110001, 0b00011011, 0b00001111));
+ EXPECT_THAT(output, ElementsAre(0x1a, 0xc2, 0xfa));
}
TEST(ElementIteratorTest, read_non_const_u3_data) {
constexpr auto elements_count = 16;
- auto input = std::array<int8_t, 6>{0x7a, 0x6f, 0x55, static_cast<int8_t>(0xb1), 0x1b, 0x0f};
+ auto input = std::array<int8_t, 6>{static_cast<int8_t>(0xb9),
+ 0x1c,
+ static_cast<int8_t>(0xef),
+ 0x1a,
+ static_cast<int8_t>(0xc2),
+ static_cast<int8_t>(0xfa)};
auto iter = element::iterator<element::u3>(input.data());
EXPECT_THAT(std::vector<int8_t>(iter, iter + elements_count),
@@ -208,7 +215,7 @@ TEST(ElementIteratorTest, read_non_const_u3_data) {
TEST(ElementIteratorTest, read_const_u3_data) {
constexpr auto elements_count = 8;
- constexpr auto input = std::array<int8_t, 3>{static_cast<int8_t>(0b10110001), 0b00011011, 0b00001111};
+ constexpr auto input = std::array<int8_t, 3>{0x1a, static_cast<int8_t>(0xc2), static_cast<int8_t>(0xfa)};
auto iter = element::iterator<element::u3>(input.data());
EXPECT_THAT(std::vector<int8_t>(iter, iter + elements_count), ElementsAre(2, 3, 0, 1, 4, 5, 6, 7));
@@ -216,7 +223,12 @@ TEST(ElementIteratorTest, read_const_u3_data) {
TEST(ElementIteratorTest, read_u3_data_iterator_with_offset) {
// Has values {1, 7, 2, 6, 1, 6, 3, 7, [2], 3, 0, 1, 4, 5, 6, 7}
- auto input = std::array<int8_t, 6>{0x7a, 0x6f, 0x55, static_cast<int8_t>(0xb1), 0x1b, 0x0f};
+ auto input = std::array<int8_t, 6>{static_cast<int8_t>(0xb9),
+ 0x1c,
+ static_cast<int8_t>(0xef),
+ 0x1a,
+ static_cast<int8_t>(0xc2),
+ static_cast<int8_t>(0xfa)};
auto iter = element::iterator<element::u3>(input.data() + 3);
EXPECT_EQ(*iter, 2);
@@ -232,9 +244,46 @@ TEST(ElementIteratorTest, read_u3_data_iterator_with_offset) {
EXPECT_EQ(*std::next(iter, 2), 0);
}
+TEST(ElementIteratorTest, read_u3_data_increment_decrement_iterator) {
+ // Has values {1, 7, 2, 6, 1, 6, 3, 7, [2], 3, 0, 1, 4, 5, 6, 7}
+ auto input = std::array<int8_t, 6>{static_cast<int8_t>(0xb9),
+ 0x1c,
+ static_cast<int8_t>(0xef),
+ 0x1a,
+ static_cast<int8_t>(0xc2),
+ static_cast<int8_t>(0xfa)};
+ auto iter = element::iterator<element::u3>(input.data() + 3);
+
+ EXPECT_EQ(*iter--, 2);
+ EXPECT_EQ(*iter++, 7);
+ EXPECT_EQ(*++iter, 3);
+ EXPECT_EQ(*iter--, 3);
+ EXPECT_EQ(*--iter, 7);
+}
+
+TEST(ElementIteratorTest, u3_last_value_straddles_byte_boundary) {
+ // 3 values * 3 bits = 9 bits -> 2 bytes, the last value spans both bytes.
+ auto buffer = std::vector<int8_t>(2, 0);
+ auto iter = element::iterator<element::u3>(buffer.data());
+
+ *iter = 1;
+ *(iter + 1) = 2;
+ *(iter + 2) = 7;
+
+ EXPECT_THAT(buffer, ElementsAre(static_cast<int8_t>(0b11010001), 0b00000001));
+
+ auto const_iter = element::iterator<element::u3>(std::as_const(buffer).data());
+ EXPECT_THAT(std::vector<int8_t>(const_iter, const_iter + 3), ElementsAre(1, 2, 7));
+}
+
TEST(ElementIteratorTest, read_u3_from_tensor) {
// Has values {1, 7, 2, 6, 1, 6, 3, 7, [2], 3, 0, 1, 4, 5, 6, 7}
- auto input = std::array<int8_t, 6>{0x7a, 0x6f, 0x55, static_cast<int8_t>(0xb1), 0x1b, 0x0f};
+ auto input = std::array<int8_t, 6>{static_cast<int8_t>(0xb9),
+ 0x1c,
+ static_cast<int8_t>(0xef),
+ 0x1a,
+ static_cast<int8_t>(0xc2),
+ static_cast<int8_t>(0xfa)};
auto t = ov::Tensor(element::u3, Shape{4, 2, 2}, input.data());
auto iter = element::iterator<element::u3>(static_cast<int8_t*>(t.data(element::u3)));
@@ -419,12 +468,12 @@ TEST(ElementIteratorTest, write_u6_data) {
std::copy(input.begin(), input.end(), iter);
- EXPECT_THAT(output, ElementsAre(0x21, 0x03, 0x00, 0x21, 0x30, 0x79));
+ EXPECT_THAT(output, ElementsAre(0x42, 0x00, 0x0c, 0x52, 0x3c, 0x42));
}
TEST(ElementIteratorTest, read_non_const_u6_data) {
constexpr auto elements_count = 8;
- auto input = std::array<int8_t, 6>{0x21, 0x03, 0x00, 0x21, 0x30, 0x79};
+ auto input = std::array<int8_t, 6>{0x42, 0x00, 0x0c, 0x52, 0x3c, 0x42};
auto iter = element::iterator<element::u6>(input.data());
EXPECT_THAT(std::vector<int8_t>(iter, iter + elements_count), ElementsAre(2, 1, 0, 3, 18, 49, 35, 16));
@@ -432,7 +481,7 @@ TEST(ElementIteratorTest, read_non_const_u6_data) {
TEST(ElementIteratorTest, read_const_u6_data) {
constexpr auto elements_count = 8;
- constexpr auto input = std::array<int8_t, 6>{0x21, 0x03, 0x00, 0x21, 0x30, 0x79};
+ constexpr auto input = std::array<int8_t, 6>{0x42, 0x00, 0x0c, 0x52, 0x3c, 0x42};
auto iter = element::iterator<element::u6>(input.data());
EXPECT_THAT(std::vector<int8_t>(iter, iter + elements_count), ElementsAre(2, 1, 0, 3, 18, 49, 35, 16));
@@ -440,7 +489,7 @@ TEST(ElementIteratorTest, read_const_u6_data) {
TEST(ElementIteratorTest, read_u6_data_increment_decrement_iterator) {
// Has values {1, 2, 3, 10, [3], 8, 7, 2}
- auto input = std::array<int8_t, 6>{0x12, 0x3a, 0x00, 0x38, 0x72, 0x00};
+ auto input = std::array<int8_t, 6>{static_cast<int8_t>(0x81), 0x30, 0x28, 0x03, 0x72, 0x08};
auto iter = element::iterator<element::u6>(input.data() + 3);
EXPECT_EQ(*iter--, 3);
@@ -452,7 +501,9 @@ TEST(ElementIteratorTest, read_u6_data_increment_decrement_iterator) {
TEST(ElementIteratorTest, read_u6_data_iterator_with_offset) {
// Has values {1, 2, 3, 10, [3], 8, 7, 2, 1, 42, 4, 20}
- auto input = std::array<int8_t, 9>{0x12, 0x3a, 0x00, 0x38, 0x72, 0x00, 0x1a, 0x44, 0x21};
+ auto input =
+ std::array<int8_t,
+ 9>{static_cast<int8_t>(0x81), 0x30, 0x28, 0x03, 0x72, 0x08, static_cast<int8_t>(0x81), 0x4a, 0x50};
auto iter = element::iterator<element::u6>(input.data() + 3);
EXPECT_EQ(*iter, 3);
@@ -467,7 +518,7 @@ TEST(ElementIteratorTest, read_u6_data_iterator_with_offset) {
}
TEST(ElementIteratorTest, u6_value_to_output_stream) {
- auto input = std::array<int8_t, 3>{0x12, 0x3a, 0x00};
+ auto input = std::array<int8_t, 3>{0x01, 0x00, 0x00};
auto iter = element::iterator<element::u6>(input.data());
std::stringstream s;
@@ -476,9 +527,26 @@ TEST(ElementIteratorTest, u6_value_to_output_stream) {
EXPECT_EQ(s.str(), "1");
}
+TEST(ElementIteratorTest, u6_last_value_straddles_byte_boundary) {
+ // 3 values * 6 bits = 18 bits -> 3 bytes, the last value spans bytes 1 and 2.
+ auto buffer = std::vector<int8_t>(3, 0);
+ auto iter = element::iterator<element::u6>(buffer.data());
+
+ *iter = 1;
+ *(iter + 1) = 2;
+ *(iter + 2) = 63;
+
+ EXPECT_THAT(buffer, ElementsAre(static_cast<int8_t>(0b10000001), static_cast<int8_t>(0b11110000), 0b00000011));
+
+ auto const_iter = element::iterator<element::u6>(std::as_const(buffer).data());
+ EXPECT_THAT(std::vector<int8_t>(const_iter, const_iter + 3), ElementsAre(1, 2, 63));
+}
+
TEST(ElementIteratorTest, read_u6_from_tensor) {
// Has values {1, 2, 3, 10, 3, 8, 7, 2, 1, 42, 4, 20}
- auto input = std::array<int8_t, 9>{0x12, 0x3a, 0x00, 0x38, 0x72, 0x00, 0x1a, 0x44, 0x21};
+ auto input =
+ std::array<int8_t,
+ 9>{static_cast<int8_t>(0x81), 0x30, 0x28, 0x03, 0x72, 0x08, static_cast<int8_t>(0x81), 0x4a, 0x50};
auto t = ov::Tensor(element::u6, Shape{4, 1, 3}, input.data());
auto iter = element::iterator<element::u6>(static_cast<int8_t*>(t.data(element::u6)));
diff --git a/src/core/tests/memory_util.cpp b/src/core/tests/memory_util.cpp
index 4708f7508b7..6a327807755 100644
--- a/src/core/tests/memory_util.cpp
+++ b/src/core/tests/memory_util.cpp
@@ -61,6 +61,26 @@ INSTANTIATE_TEST_SUITE_P(
std::make_tuple(element::u4, Shape{2, max_dim}, std::nullopt)),
GetMemorySizeOverflowTest::get_test_name);
+INSTANTIATE_TEST_SUITE_P(
+ cross_byte_bit_type_precision,
+ GetMemorySizeOverflowTest,
+ testing::Values(std::make_tuple(element::u3, Shape{}, std::optional<size_t>(1)),
+ std::make_tuple(element::u3, Shape{3}, std::optional<size_t>(2)),
+ std::make_tuple(element::u3, Shape{8}, std::optional<size_t>(3)),
+ std::make_tuple(element::u3, Shape{17}, std::optional<size_t>(7)),
+ // elements_count * bitwidth overflows, but the resulting byte size still fits
+ std::make_tuple(element::u3, Shape{max_dim}, std::optional<size_t>(max_dim / 8 * 3 + 3)),
+ std::make_tuple(element::u3, Shape{max_dim - 1}, std::optional<size_t>(max_dim / 8 * 3 + 3)),
+ std::make_tuple(element::u3, Shape{2, max_dim}, std::nullopt),
+ std::make_tuple(element::u6, Shape{}, std::optional<size_t>(1)),
+ std::make_tuple(element::u6, Shape{3}, std::optional<size_t>(3)),
+ std::make_tuple(element::u6, Shape{8}, std::optional<size_t>(6)),
+ std::make_tuple(element::u6, Shape{17}, std::optional<size_t>(13)),
+ std::make_tuple(element::u6, Shape{max_dim}, std::optional<size_t>(max_dim / 8 * 6 + 6)),
+ std::make_tuple(element::u6, Shape{max_dim - 1}, std::optional<size_t>(max_dim / 8 * 6 + 5)),
+ std::make_tuple(element::u6, Shape{1, 2, max_dim}, std::nullopt)),
+ GetMemorySizeOverflowTest::get_test_name);
+
INSTANTIATE_TEST_SUITE_P(
byte_type_precision,
GetMemorySizeOverflowTest,
@@ -113,7 +133,9 @@ INSTANTIATE_TEST_SUITE_P(bit_type_precision,
std::make_tuple(element::u2, 1, 4),
std::make_tuple(element::u2, 2, 8),
std::make_tuple(element::u2, 3, 12),
- std::make_tuple(element::u2, 4, 16)));
+ std::make_tuple(element::u2, 4, 16),
+ // memory size * 8 overflows, but the elements count is still representable
+ std::make_tuple(element::u2, max_dim / 4, max_dim - 3)));
INSTANTIATE_TEST_SUITE_P(nibble_type_precision,
GetMaxElementsForMemorySizeTest,
@@ -122,27 +144,32 @@ INSTANTIATE_TEST_SUITE_P(nibble_type_precision,
std::make_tuple(element::u4, 1, 2),
std::make_tuple(element::u4, 2, 4),
std::make_tuple(element::i4, 3, 6),
- std::make_tuple(element::i4, 4, 8)));
+ std::make_tuple(element::i4, 4, 8),
+ // memory size * 8 overflows, but the elements count is still representable
+ std::make_tuple(element::u4, max_dim / 2, max_dim - 1)));
-INSTANTIATE_TEST_SUITE_P(split_bit_type_precision,
+INSTANTIATE_TEST_SUITE_P(cross_byte_bit_type_precision,
GetMaxElementsForMemorySizeTest,
testing::Values(std::make_tuple(element::u3, 0, 0),
- std::make_tuple(element::u3, 1, 0),
- std::make_tuple(element::u3, 2, 0),
+ std::make_tuple(element::u3, 1, 2),
+ std::make_tuple(element::u3, 2, 5),
std::make_tuple(element::u3, 3, 8),
- std::make_tuple(element::u3, 5, 8),
+ std::make_tuple(element::u3, 5, 13),
std::make_tuple(element::u3, 6, 16),
- std::make_tuple(element::u3, 11, 24),
+ std::make_tuple(element::u3, 11, 29),
std::make_tuple(element::u3, 12, 32),
std::make_tuple(element::u6, 0, 0),
- std::make_tuple(element::u6, 1, 0),
- std::make_tuple(element::u6, 2, 0),
+ std::make_tuple(element::u6, 1, 1),
+ std::make_tuple(element::u6, 2, 2),
std::make_tuple(element::u6, 3, 4),
- std::make_tuple(element::u6, 4, 4),
- std::make_tuple(element::u6, 5, 4),
+ std::make_tuple(element::u6, 4, 5),
+ std::make_tuple(element::u6, 5, 6),
std::make_tuple(element::u6, 6, 8),
- std::make_tuple(element::u6, 11, 12),
- std::make_tuple(element::u6, 12, 16)));
+ std::make_tuple(element::u6, 11, 14),
+ std::make_tuple(element::u6, 12, 16),
+ // memory size * 8 overflows, but the elements count is still representable
+ std::make_tuple(element::u3, 3 * (max_dim / 8), 8 * (max_dim / 8)),
+ std::make_tuple(element::u6, 6 * (max_dim / 16), 8 * (max_dim / 16))));
INSTANTIATE_TEST_SUITE_P(byte_type_precision,
GetMaxElementsForMemorySizeTest,
diff --git a/src/core/tests/ov_tensor_test.cpp b/src/core/tests/ov_tensor_test.cpp
index 6dd2fa2e1de..f997b8bec8e 100644
--- a/src/core/tests/ov_tensor_test.cpp
+++ b/src/core/tests/ov_tensor_test.cpp
@@ -248,7 +248,7 @@ TEST_F(OVTensorTest, canCreateTensorU3UsingMockAllocator) {
}
TEST_F(OVTensorTest, canCreateTensorU6UsingMockAllocator) {
- constexpr size_t exp_size = 6;
+ constexpr size_t exp_size = 5;
ov::Shape shape = {1, 2, 3};
OVMockAllocator allocator;
@@ -805,34 +805,34 @@ TEST_F(OVTensorTest, getByteSizeU2NotEvenDivByStorageUnit) {
EXPECT_EQ(tensor.get_byte_size(), 5);
}
-TEST_F(OVTensorTest, getByteSizeU3LessThanMinStorageUnit) {
+TEST_F(OVTensorTest, getByteSizeU3SmallShapeWithTailBits) {
const auto tensor = ov::Tensor(ov::element::u3, ov::Shape{3});
- EXPECT_EQ(tensor.get_byte_size(), 3);
+ EXPECT_EQ(tensor.get_byte_size(), 2);
}
-TEST_F(OVTensorTest, getByteSizeU3EvenDivByStorageUnit) {
+TEST_F(OVTensorTest, getByteSizeU3ShapeWithoutTailBits) {
const auto tensor = ov::Tensor(ov::element::u3, ov::Shape{16});
EXPECT_EQ(tensor.get_byte_size(), 2 * 3);
}
-TEST_F(OVTensorTest, getByteSizeU3NotEvenDivByStorageUnit) {
+TEST_F(OVTensorTest, getByteSizeU3LargeShapeWithTailBits) {
const auto tensor = ov::Tensor(ov::element::u3, ov::Shape{17});
- EXPECT_EQ(tensor.get_byte_size(), 3 + 2 * 3);
+ EXPECT_EQ(tensor.get_byte_size(), 7);
}
-TEST_F(OVTensorTest, getByteSizeU6LessThanMinStorageUnit) {
+TEST_F(OVTensorTest, getByteSizeU6SmallShapeWithTailBits) {
const auto tensor = ov::Tensor(ov::element::u6, ov::Shape{3});
EXPECT_EQ(tensor.get_byte_size(), 3);
}
-TEST_F(OVTensorTest, getByteSizeU6EvenDivByStorageUnit) {
+TEST_F(OVTensorTest, getByteSizeU6ShapeWithoutTailBits) {
const auto tensor = ov::Tensor(ov::element::u6, ov::Shape{16});
EXPECT_EQ(tensor.get_byte_size(), 4 * 3);
}
-TEST_F(OVTensorTest, getByteSizeU6NotEvenDivByStorageUnit) {
+TEST_F(OVTensorTest, getByteSizeU6LargeShapeWithTailBits) {
const auto tensor = ov::Tensor(ov::element::u6, ov::Shape{17});
- EXPECT_EQ(tensor.get_byte_size(), 3 + 4 * 3);
+ EXPECT_EQ(tensor.get_byte_size(), 13);
}
TEST_F(OVTensorTest, checkIsContinuousTensorScalar) {
diff --git a/src/plugins/template/tests/functional/op_reference/base_reference_test.cpp b/src/plugins/template/tests/functional/op_reference/base_reference_test.cpp
index c5523da75b4..8ada301138f 100644
--- a/src/plugins/template/tests/functional/op_reference/base_reference_test.cpp
+++ b/src/plugins/template/tests/functional/op_reference/base_reference_test.cpp
@@ -262,19 +262,24 @@ void CommonReferenceTest::ValidateBlobs(const ov::Tensor& refBlob,
abs_threshold);
break;
case ov::element::u3:
- ov::test::utils::compare_raw_data<int8_t, int8_t>(static_cast<const int8_t*>(refBlob.data()),
- static_cast<const int8_t*>(outBlob.data()),
- 3 * (actual_comparision_size / 8),
- threshold,
- abs_threshold);
- break;
- case ov::element::u6:
- ov::test::utils::compare_raw_data<int8_t, int8_t>(static_cast<const int8_t*>(refBlob.data()),
- static_cast<const int8_t*>(outBlob.data()),
- 3 * (actual_comparision_size / 4),
+ case ov::element::u6: {
+ // Linear LSB-first bit-stream. The unused tail bits of the last byte hold no value,
+ // so they are masked out instead of being compared.
+ const auto used_bits = actual_comparision_size * element_type.bitwidth();
+ const auto* ref_ptr = static_cast<const uint8_t*>(refBlob.data());
+ const auto* out_ptr = static_cast<const uint8_t*>(outBlob.data());
+ ov::test::utils::compare_raw_data<int8_t, int8_t>(reinterpret_cast<const int8_t*>(ref_ptr),
+ reinterpret_cast<const int8_t*>(out_ptr),
+ used_bits / 8,
threshold,
abs_threshold);
+ if (const auto tail_bits = used_bits % 8) {
+ const auto mask = static_cast<uint8_t>(0xffU >> (8 - tail_bits));
+ EXPECT_EQ(ref_ptr[used_bits / 8] & mask, out_ptr[used_bits / 8] & mask)
+ << "Mismatch in the tail bits of blob with index " << blob_idx;
+ }
break;
+ }
case ov::element::nf4:
ov::test::utils::compare_raw_data<int8_t, int8_t>(static_cast<const int8_t*>(refBlob.data()),
static_cast<const int8_t*>(outBlob.data()),
diff --git a/src/plugins/template/tests/functional/op_reference/convert_like.cpp b/src/plugins/template/tests/functional/op_reference/convert_like.cpp
index 22cd32690d7..d8fc6352bf9 100644
--- a/src/plugins/template/tests/functional/op_reference/convert_like.cpp
+++ b/src/plugins/template/tests/functional/op_reference/convert_like.cpp
@@ -37,13 +37,13 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{8},
ov::element::u3,
ov::element::boolean,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x10, 0x02, 0x60},
std::vector<char>{0, 1, 0, 1, 0, 0, 0, 1}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
ov::element::u6,
ov::element::boolean,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x42, 0x00, 0x0c},
std::vector<char>{1, 1, 0, 1}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 3},
@@ -92,13 +92,13 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{8},
ov::element::u3,
ov::element::bf16,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x10, 0x02, 0x60},
std::vector<bfloat16>{0.0f, 2.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 3.0f}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
ov::element::u6,
ov::element::bf16,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x42, 0x00, 0x0c},
std::vector<bfloat16>{2.0f, 1.0f, 0.0f, 3.0f}),
ConvertParams(
ConversionTypes::CONVERT_LIKE,
@@ -140,13 +140,13 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{8},
ov::element::u3,
ov::element::f16,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x10, 0x02, 0x60},
std::vector<float16>{0.0f, 2.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 3.0f}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
ov::element::u6,
ov::element::f16,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x42, 0x00, 0x0c},
std::vector<float16>{2.0f, 1.0f, 0.0f, 3.0f}),
ConvertParams(
ConversionTypes::CONVERT_LIKE,
@@ -204,7 +204,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{8},
ov::element::u3,
ov::element::f32,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x10, 0x02, 0x60},
std::vector<float>{0.0f, 2.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 3.0f}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 2},
@@ -216,7 +216,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{4},
ov::element::u6,
ov::element::f32,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x42, 0x00, 0x0c},
std::vector<float>{2.0f, 1.0f, 0.0f, 3.0f}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 2},
@@ -385,7 +385,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{8},
ov::element::u3,
ov::element::i4,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x10, 0x02, 0x60},
std::vector<uint8_t>{0x20, 0x10, 0x00, 0x30}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -397,7 +397,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{4},
ov::element::u6,
ov::element::i4,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x42, 0x00, 0x0c},
std::vector<uint8_t>{0x12, 0x30}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -488,7 +488,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{8},
ov::element::u3,
ov::element::i8,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x10, 0x02, 0x60},
std::vector<int8_t>{0, 2, 0, 1, 0, 0, 0, 3}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -500,7 +500,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{4},
ov::element::u6,
ov::element::i8,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x42, 0x00, 0x0c},
std::vector<int8_t>{2, 1, 0, 3}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -591,7 +591,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{8},
ov::element::u3,
ov::element::i16,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x10, 0x02, 0x60},
std::vector<int16_t>{0, 2, 0, 1, 0, 0, 0, 3}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -603,7 +603,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{4},
ov::element::u6,
ov::element::i16,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x42, 0x00, 0x0c},
std::vector<int16_t>{2, 1, 0, 3}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -694,7 +694,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{8},
ov::element::u3,
ov::element::i32,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x10, 0x02, 0x60},
std::vector<int32_t>{0, 2, 0, 1, 0, 0, 0, 3}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -706,7 +706,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{4},
ov::element::u6,
ov::element::i32,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x42, 0x00, 0x0c},
std::vector<int32_t>{2, 1, 0, 3}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -797,7 +797,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{8},
ov::element::u3,
ov::element::i64,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x10, 0x02, 0x60},
std::vector<int64_t>{0, 2, 0, 1, 0, 0, 0, 3}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -809,7 +809,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{4},
ov::element::u6,
ov::element::i64,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x42, 0x00, 0x0c},
std::vector<int64_t>{2, 1, 0, 3}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -901,7 +901,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{8},
ov::element::u3,
ov::element::u1,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x10, 0x02, 0x60},
std::vector<uint8_t>{0b00010001}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{8},
@@ -913,7 +913,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{8},
ov::element::u6,
ov::element::u1,
- std::vector<uint8_t>{0x21, 0x03, 0x00, 0x00, 0x00, 0x00},
+ std::vector<uint8_t>{0x42, 0x00, 0x0c, 0x00, 0x00, 0x00},
std::vector<uint8_t>{0b01010000}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{8},
@@ -1005,7 +1005,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{8},
ov::element::u3,
ov::element::u4,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x10, 0x02, 0x60},
std::vector<uint8_t>{0x20, 0x10, 0x00, 0x30}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -1017,7 +1017,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{4},
ov::element::u6,
ov::element::u4,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x42, 0x00, 0x0c},
std::vector<uint8_t>{0x12, 0x30}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -1109,7 +1109,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{8},
ov::element::u3,
ov::element::u8,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x10, 0x02, 0x60},
std::vector<uint8_t>{0, 2, 0, 1, 0, 0, 0, 3}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -1121,7 +1121,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{4},
ov::element::u6,
ov::element::u8,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x42, 0x00, 0x0c},
std::vector<uint8_t>{2, 1, 0, 3}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -1213,7 +1213,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{8},
ov::element::u3,
ov::element::u16,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x10, 0x02, 0x60},
std::vector<uint16_t>{0, 2, 0, 1, 0, 0, 0, 3}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -1225,7 +1225,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{4},
ov::element::u6,
ov::element::u16,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x42, 0x00, 0x0c},
std::vector<uint16_t>{2, 1, 0, 3}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -1317,7 +1317,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{8},
ov::element::u3,
ov::element::u32,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x10, 0x02, 0x60},
std::vector<uint32_t>{0, 2, 0, 1, 0, 0, 0, 3}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -1329,7 +1329,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{4},
ov::element::u6,
ov::element::u32,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x42, 0x00, 0x0c},
std::vector<uint32_t>{2, 1, 0, 3}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -1420,7 +1420,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{8},
ov::element::u3,
ov::element::u64,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x10, 0x02, 0x60},
std::vector<uint64_t>{0, 2, 0, 1, 0, 0, 0, 3}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -1432,7 +1432,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{4},
ov::element::u6,
ov::element::u64,
- std::vector<uint8_t>{0x21, 0x03, 0x00},
+ std::vector<uint8_t>{0x42, 0x00, 0x0c},
std::vector<uint64_t>{2, 1, 0, 3}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{4},
@@ -1536,7 +1536,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{1, 8},
ov::element::u3,
ov::element::u2,
- std::vector<uint8_t>{0b00100111, 0b00011010, 0b00001000},
+ std::vector<uint8_t>{0b01010000, 0b11000110, 0b01001000},
std::vector<uint8_t>{0b11011000, 0b10100100}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
@@ -1548,7 +1548,7 @@ INSTANTIATE_TEST_SUITE_P(
ov::PartialShape{1, 8},
ov::element::u6,
ov::element::u2,
- std::vector<uint8_t>{0x02, 0x13, 0x00, 0x81, 0x04, 0b01001011},
+ std::vector<uint8_t>{128, 16, 12, 88, 0, 210},
std::vector<uint8_t>{0b11011000, 0b00000100}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
@@ -1628,236 +1628,236 @@ INSTANTIATE_TEST_SUITE_P(
ov::element::boolean,
ov::element::u3,
std::vector<char>{1, 0, 1, 1, 0, 1, 0, 0},
- std::vector<uint8_t>{0b01000101, 0b00010000, 0x00}),
+ std::vector<uint8_t>{65, 130, 0}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::u1,
ov::element::u3,
std::vector<uint8_t>{0b11001011},
- std::vector<uint8_t>{0b01010000, 0b01000101, 0x00}),
+ std::vector<uint8_t>{9, 16, 36}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{1, 8},
ov::element::u2,
ov::element::u3,
std::vector<uint8_t>{0b11011000, 0b10100100},
- std::vector<uint8_t>{0b00100111, 0b00011010, 0x00}),
+ std::vector<uint8_t>{80, 134, 72}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::u4,
ov::element::u3,
std::vector<uint8_t>{0x21, 0x01, 0x31, 0xff},
- std::vector<uint8_t>{0b01100100, 0b01111111, 0b00000011}),
+ std::vector<uint8_t>{0b01010001, 0b10010000, 0b11111101}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{1, 8},
ov::element::u6,
ov::element::u3,
- std::vector<uint8_t>{0x02, 0x13, 0x00, 0x41, 0x26, 0x00},
- std::vector<uint8_t>{0b00100111, 0b00011010, 0b00001001}),
+ std::vector<uint8_t>{0x80, 0x10, 0x0c, 0x44, 0x20, 0x18},
+ std::vector<uint8_t>{0b01010000, 0b11000110, 0b11001000}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::u8,
ov::element::u3,
std::vector<uint8_t>{0, 2, 1, 3, 4, 1, 2, 2},
- std::vector<uint8_t>{0b00100111, 0b00011010, 0b00001000}),
+ std::vector<uint8_t>{0b01010000, 0b11000110, 0b01001000}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::u16,
ov::element::u3,
std::vector<uint16_t>{0, 2, 1, 3, 4, 1, 2, 2},
- std::vector<uint8_t>{0b00100111, 0b00011010, 0b00001000}),
+ std::vector<uint8_t>{0b01010000, 0b11000110, 0b01001000}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::u32,
ov::element::u3,
std::vector<uint32_t>{0, 2, 1, 3, 4, 1, 2, 2},
- std::vector<uint8_t>{0b00100111, 0b00011010, 0b00001000}),
+ std::vector<uint8_t>{0b01010000, 0b11000110, 0b01001000}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::u64,
ov::element::u3,
std::vector<uint64_t>{0, 2, 1, 3, 4, 1, 2, 2},
- std::vector<uint8_t>{0b00100111, 0b00011010, 0b00001000}),
+ std::vector<uint8_t>{0b01010000, 0b11000110, 0b01001000}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::i8,
ov::element::u3,
std::vector<int8_t>{0, 2, 1, -3, 4, -1, 8, 7},
- std::vector<uint8_t>{0b00100101, 0b00110011, 0b00011101}),
+ std::vector<uint8_t>{0b01010000, 0b11001010, 0b11100011}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::i16,
ov::element::u3,
std::vector<int16_t>{0, 2, 1, -3, 4, -1, 8, 7},
- std::vector<uint8_t>{0b00100101, 0b00110011, 0b00011101}),
+ std::vector<uint8_t>{0b01010000, 0b11001010, 0b11100011}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::i32,
ov::element::u3,
std::vector<int32_t>{0, 2, 1, -3, 4, -1, 8, 7},
- std::vector<uint8_t>{0b00100101, 0b00110011, 0b00011101}),
+ std::vector<uint8_t>{0b01010000, 0b11001010, 0b11100011}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::i64,
ov::element::u3,
std::vector<int64_t>{0, 2, 1, -3, 4, -1, 8, 7},
- std::vector<uint8_t>{0b00100101, 0b00110011, 0b00011101}),
+ std::vector<uint8_t>{0b01010000, 0b11001010, 0b11100011}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::f8e4m3,
ov::element::u3,
std::vector<float8_e4m3>{0.0f, 2.1f, 1.7f, -3.1f, 4.0f, -1.0f, 8.0f, 7.2f},
- std::vector<uint8_t>{0b00100101, 0b00110011, 0b00011101}),
+ std::vector<uint8_t>{0b01010000, 0b11001010, 0b11100011}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::f8e5m2,
ov::element::u3,
std::vector<float8_e5m2>{0.0f, 2.1f, 1.7f, -3.1f, 4.0f, -1.0f, 8.0f, 7.2f},
- std::vector<uint8_t>{0b00100101, 0b00110011, 0b00011101}),
+ std::vector<uint8_t>{0b01010000, 0b11001010, 0b11100011}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::f16,
ov::element::u3,
std::vector<float16>{0.0f, 2.1f, 1.7f, -3.1f, 4.0f, -1.0f, 8.0f, 7.2f},
- std::vector<uint8_t>{0b00100101, 0b00110011, 0b00011101}),
+ std::vector<uint8_t>{0b01010000, 0b11001010, 0b11100011}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::bf16,
ov::element::u3,
std::vector<bfloat16>{0.0f, 2.1f, 1.7f, -3.1f, 4.0f, -1.0f, 8.0f, 7.2f},
- std::vector<uint8_t>{0b00100101, 0b00110011, 0b00011101}),
+ std::vector<uint8_t>{0b01010000, 0b11001010, 0b11100011}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::f32,
ov::element::u3,
std::vector<float>{0.0f, 2.1f, 1.7f, -3.1f, 4.0f, -1.0f, 8.0f, 7.2f},
- std::vector<uint8_t>{0b00100101, 0b00110011, 0b00011101}),
+ std::vector<uint8_t>{0b01010000, 0b11001010, 0b11100011}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::f64,
ov::element::u3,
std::vector<double>{0.0, 2.1, 1.7, -3.1, 4.0, -1.0, 8.0, 7.2},
- std::vector<uint8_t>{0b00100101, 0b00110011, 0b00011101}),
+ std::vector<uint8_t>{0b01010000, 0b11001010, 0b11100011}),
// destination u6
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::boolean,
ov::element::u6,
std::vector<char>{1, 0, 1, 1, 0, 1, 0, 0},
- std::vector<uint8_t>{0x10, 0x11, 0x00, 0x01, 0x00, 0x00}),
+ std::vector<uint8_t>{0x01, 0x10, 0x04, 0x40, 0x00, 0x00}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::u1,
ov::element::u6,
std::vector<uint8_t>{0b11001011},
- std::vector<uint8_t>{0x11, 0x00, 0x00, 0x10, 0x11, 0x00}),
+ std::vector<uint8_t>{0x41, 0x00, 0x00, 0x01, 0x10, 0x04}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{1, 8},
ov::element::u2,
ov::element::u6,
std::vector<uint8_t>{0b11011000, 0b00000100},
- std::vector<uint8_t>{0x02, 0x13, 0x00, 0x01, 0x00, 0x00}),
+ std::vector<uint8_t>{0x80, 0x10, 0x0c, 0x40, 0x00, 0x00}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{1, 8},
ov::element::u3,
ov::element::u6,
- std::vector<uint8_t>{0b00100111, 0b00011010, 0b00001001},
- std::vector<uint8_t>{0x02, 0x13, 0x00, 0x41, 0x26, 0x00}),
+ std::vector<uint8_t>{0b01010000, 0b11000110, 0b11001000},
+ std::vector<uint8_t>{0x80, 0x10, 0x0c, 0x44, 0x20, 0x18}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::u4,
ov::element::u6,
std::vector<uint8_t>{0x21, 0x01, 0x31, 0xff},
- std::vector<uint8_t>{0x12, 0x10, 0x00, 0x13, 0xff, 0x00}),
+ std::vector<uint8_t>{0x81, 0x10, 0x00, 0xc1, 0xf0, 0x3c}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::u8,
ov::element::u6,
std::vector<uint8_t>{0, 2, 1, 3, 24, 1, 32, 52},
- std::vector<uint8_t>{0x02, 0x13, 0x00, 0x81, 0x04, 0b01001011}),
+ std::vector<uint8_t>{128, 16, 12, 88, 0, 210}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::u16,
ov::element::u6,
std::vector<uint16_t>{0, 2, 1, 3, 24, 1, 32, 52},
- std::vector<uint8_t>{0x02, 0x13, 0x00, 0x81, 0x04, 0b01001011}),
+ std::vector<uint8_t>{128, 16, 12, 88, 0, 210}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::u32,
ov::element::u6,
std::vector<uint32_t>{0, 2, 1, 3, 24, 1, 32, 52},
- std::vector<uint8_t>{0x02, 0x13, 0x00, 0x81, 0x04, 0b01001011}),
+ std::vector<uint8_t>{128, 16, 12, 88, 0, 210}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::u64,
ov::element::u6,
std::vector<uint64_t>{0, 2, 1, 3, 24, 1, 32, 52},
- std::vector<uint8_t>{0x02, 0x13, 0x00, 0x81, 0x04, 0b01001011}),
+ std::vector<uint8_t>{128, 16, 12, 88, 0, 210}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::i4,
ov::element::u6,
std::vector<uint8_t>{0x21, 0x01, 0x31, 0xff},
- std::vector<uint8_t>{0x12, 0x10, 0x00, 0x13, 0xff, 0b00001111}),
+ std::vector<uint8_t>{129, 16, 0, 193, 240, 255}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::i8,
ov::element::u6,
std::vector<int8_t>{0, 2, 1, -3, 24, -1, 32, 52},
- std::vector<uint8_t>{0x02, 0x1d, 0b00000011, 0x8f, 0x04, 0b01111011}),
+ std::vector<uint8_t>{128, 16, 244, 216, 15, 210}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::i16,
ov::element::u6,
std::vector<int16_t>{0, 2, 1, -3, 24, -1, 32, 52},
- std::vector<uint8_t>{0x02, 0x1d, 0b00000011, 0x8f, 0x04, 0b01111011}),
+ std::vector<uint8_t>{128, 16, 244, 216, 15, 210}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::i32,
ov::element::u6,
std::vector<int32_t>{0, 2, 1, -3, 24, -1, 32, 52},
- std::vector<uint8_t>{0x02, 0x1d, 0b00000011, 0x8f, 0x04, 0b01111011}),
+ std::vector<uint8_t>{128, 16, 244, 216, 15, 210}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::i64,
ov::element::u6,
std::vector<int64_t>{0, 2, 1, -3, 24, -1, 32, 52},
- std::vector<uint8_t>{0x02, 0x1d, 0b00000011, 0x8f, 0x04, 0b01111011}),
+ std::vector<uint8_t>{128, 16, 244, 216, 15, 210}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::f8e4m3,
ov::element::u6,
std::vector<float8_e4m3>{0.0f, 2.1f, 1.7f, -3.1f, 24.0f, -1.0f, 32.0f, 52.0f},
- std::vector<uint8_t>{0x02, 0x1d, 0b00000011, 0x8f, 0x04, 0b01111011}),
+ std::vector<uint8_t>{128, 16, 244, 216, 15, 210}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::f8e5m2,
ov::element::u6,
std::vector<float8_e5m2>{0.0f, 2.1f, 1.7f, -3.1f, 24.0f, -1.0f, 32.0f, 56.0f},
- std::vector<uint8_t>{0x02, 0x1d, 0b00000011, 0x8f, 0x08, 0b01111011}),
+ std::vector<uint8_t>{128, 16, 244, 216, 15, 226}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::f16,
ov::element::u6,
std::vector<float16>{0.0f, 2.1f, 1.7f, -3.1f, 24.0f, -1.0f, 32.0f, 52.0f},
- std::vector<uint8_t>{0x02, 0x1d, 0b00000011, 0x8f, 0x04, 0b01111011}),
+ std::vector<uint8_t>{128, 16, 244, 216, 15, 210}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::bf16,
ov::element::u6,
std::vector<bfloat16>{0.0f, 2.1f, 1.7f, -3.1f, 24.0f, -1.0f, 32.0f, 52.0f},
- std::vector<uint8_t>{0x02, 0x1d, 0b00000011, 0x8f, 0x04, 0b01111011}),
+ std::vector<uint8_t>{128, 16, 244, 216, 15, 210}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::f32,
ov::element::u6,
std::vector<float>{0.0f, 2.1f, 1.7f, -3.1f, 24.0f, -1.0f, 32.0f, 52.0f},
- std::vector<uint8_t>{0x02, 0x1d, 0b00000011, 0x8f, 0x04, 0b01111011}),
+ std::vector<uint8_t>{128, 16, 244, 216, 15, 210}),
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{2, 4},
ov::element::f64,
ov::element::u6,
std::vector<double>{0.0, 2.1, 1.7, -3.1, 24.0, -1.0, 32.0, 52.0},
- std::vector<uint8_t>{0x02, 0x1d, 0b00000011, 0x8f, 0x04, 0b01111011}),
+ std::vector<uint8_t>{128, 16, 244, 216, 15, 210}),
// destination f4e2m1
ConvertParams(ConversionTypes::CONVERT_LIKE,
ov::PartialShape{11},