apply method

void apply(
  1. String name,
  2. Float32List xs,
  3. Float32List ys,
  4. int n,
)

yst * rows + r = (W xst)r for t < n, W the matrix uploaded as name and xs n, cols.

Implementation

void apply(String name, Float32List xs, Float32List ys, int n) {
  _checkOpen();
  final w =
      _matrices[name] ?? (throw ArgumentError('no GPU matrix named $name'));
  if (n < 1 || xs.length < n * w.cols || ys.length < n * w.rows) {
    throw ArgumentError('GPU product: bad shapes for n=$n');
  }
  final x = _x = _grow(_x, n * w.cols);
  final y = _y = _grow(_y, n * w.rows);
  x.view.setRange(0, n * w.cols, xs);
  _begin();
  w.encode(x.handle, y.handle, 0, n);
  if (_commit(1) != 1) throw StateError('GPU command buffer failed');
  ys.setRange(0, n * w.rows, y.view);
}