stateBlocks method

List<Float32List> stateBlocks(
  1. int position
)

Views of the state the first position tokens left behind, in the order of LayerShard.stateBlocks: conv histories, then each attention layer's key and value rows before position.

Implementation

List<Float32List> stateBlocks(int position) {
  final rows = position * config.kvDim;
  Float32List view(int handle) =>
      _contents(handle).cast<Float>().asTypedList(rows);
  return [
    for (final layer in _layers)
      if (layer.history >= 0) _history(layer),
    for (final layer in _layers)
      if (layer.keys >= 0) ...[view(layer.keys), view(layer.values)],
  ];
}