GpuLinear class final

Products of quantized matrices on the GPU for work outside the language forward pass, such as the vision encoder's linear layers: each apply copies the inputs in, runs one matrix product over all n rows in its own command buffer and copies the outputs back. The GPU computes the same products as the CPU kernels with float inputs, its sums in another order, so the outputs differ from theirs in the last bits.

The GPU layer encodes one command buffer at a time per process: do not call apply while another isolate runs a GpuForward.

Properties

hashCode → int
The hash code for this object.
no setterinherited
names → Iterable<String>
The names of the matrices upload copied in.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

apply(String name, Float32List xs, Float32List ys, int n) → void
yst * rows + r = (W xst)r for t < n, W the matrix uploaded as name and xs n, cols.
dispose() → void
Releases every GPU buffer. Using this afterwards throws.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
upload(String name, CachedMatrix matrix) → void
Copies matrix (Q4 or Q8) into a GPU buffer of its own, under name.

Operators

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

Static Methods

start() → GpuLinear?
Starts the GPU of the kernels asset, or returns null where it does not start (no GPU, or none the kernels support).