TernaryTensorData

Marker interface for tensor data containing ternary values {-1, 0, +1}.

This interface enables specialized ternary-aware operations in TensorOps, such as addition-only matrix multiplication that avoids FP multiplies.

Implementations may store data in various compact formats (2-bit, base-3, etc.) but must provide element access returning Byte values of -1, 0, or +1.

Inheritors

Properties

Link copied to clipboard
abstract val packedData: ByteArray

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

Link copied to clipboard
abstract val scale: Float

Scale factor for dequantization to FP32. outputi = ternaryValuei * scale

Functions

Link copied to clipboard

Convert a ternary tensor to FP32 by applying the scale factor. outputi = ternaryValuei * scale