NativeQ4Matrix class final

A row-major rows, cols matrix in Q4 (Q4_0) in native memory.

Implemented types

Constructors

NativeQ4Matrix.fromGgufBlocks(Uint8List blocks, int rows, int cols)
Copies GGUF Q4_0 blocks without dequantizing or requantizing them. Each block is a little-endian half scale followed by 16 nibble bytes.
factory
NativeQ4Matrix.fromPointers(int rows, int cols, Pointer<Uint8> qs, Pointer<Uint16> scales)
Wraps Q4 data in native memory: qs holds rows * cols / 2 bytes, scales rows * cols / 32 halves.
factory
NativeQ4Matrix.quantize(Float32List w, int rows, int cols)
Quantizes float weights with llama.cpp's Q4_0 rule.
factory

Properties

cols → int
final
format → String
q8 or q4.
no setteroverride
hashCode → int
The hash code for this object.
no setterinherited
qsBytes → Uint8List
The raw quantized values and scales, as written to the file.
no setteroverride
rows → int
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scaleBytes → Uint8List
no setteroverride

Methods

apply(Float32List xs, Float32List ys, int n, {bool? int8Inputs}) → void
yst * rows + r = (W xst)r for t < n, xs as n, cols. int8Inputs overrides the process-wide setting (for tests).
override
free() → void
Releases an owned allocation; mapped matrices must be closed via the cache.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
weightAt(int r, int c) → double
The weight the kernel uses at (r, c), for tests.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited