Q4MemorySegmentTensorData

class Q4MemorySegmentTensorData(initialShape: Shape, val segment: MemorySegment, val segmentByteOffset: Long = 0) : TensorData<DType, Byte> , Q4MemorySegmentMarker(source)

Q4_0 quantized tensor data backed by a MemorySegment.

Q4_0 block layout (18 bytes per 32 elements):

  • 2 bytes: f16 scale (little-endian)

  • 16 bytes: packed 4-bit codes (32 values, 2 per byte)

Dequantization: outputi = (nibblei - 8) * scale

The segment is arena-managed and 64-byte aligned for SIMD access.

Constructors

Link copied to clipboard
constructor(initialShape: Shape, segment: MemorySegment, segmentByteOffset: Long = 0)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val blockCount: Int

Number of Q4_0 blocks in the tensor.

Link copied to clipboard
open override val blockSize: Int = 32

Elements per block.

Link copied to clipboard
open override val bytesPerBlock: Int = 18

Bytes per block.

Link copied to clipboard
open override val segment: MemorySegment

The underlying off-heap memory segment.

Link copied to clipboard
open override val segmentByteOffset: Long

Byte offset into segment where this tensor's data starts.

Link copied to clipboard
open override val shape: Shape

The shape descriptor that defines the dimensionality and size of this tensor data.

Functions

Link copied to clipboard
open override fun copyToFloatArray(): FloatArray

Copies all tensor data to a FloatArray.

Link copied to clipboard
open operator override fun get(vararg indices: Int): Byte

Retrieves an element at the specified multidimensional indices.

Link copied to clipboard
open operator override fun set(vararg indices: Int, value: Byte)

Setter