Ternary2BitTensorData

class Ternary2BitTensorData(initialShape: Shape, data: ByteArray, val scale: Float = 1.0f) : TernaryTensorData(source)

Ternary tensor data using 2-bit encoding compatible with TQ2_0 format.

Encoding scheme (matches GGUF TQ2_0):

  • 0 → -1

  • 1 → 0

  • 2 → +1

  • 3 → (reserved, treated as +1 for safety)

This is the simpler ternary format with 4 values per byte.

Parameters

initialShape

the shape of the tensor

data

the packed byte array (4 ternary values per byte)

scale

the scale factor for FP32 dequantization

Constructors

Link copied to clipboard
constructor(initialShape: Shape, data: ByteArray, scale: Float = 1.0f)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val packedData: ByteArray

Access to the underlying packed byte array for efficient kernel operations. The packing format is implementation-defined.

Link copied to clipboard
open override val scale: Float
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 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