Linear.from constructor

Linear.from(
  1. Float32List w,
  2. int rows,
  3. int cols,
  4. WeightFormat format,
)

Wraps a row-major rows, cols matrix, quantized to format unless that is f32.

Implementation

factory Linear.from(Float32List w, int rows, int cols, WeightFormat format) =>
    Linear._(rows, cols, switch (format) {
      _ when rows == 0 => w,
      WeightFormat.f32 => w,
      WeightFormat.q8 => NativeQ8Matrix.quantize(w, rows, cols),
      WeightFormat.q4 => NativeQ4Matrix.quantize(w, rows, cols),
      _ => QuantizedMatrix.quantize(w, rows, cols, format),
    });