fluttorch_test library
The parity gate.
Replays the goldens captured at export time against a loaded model, measures how far the on-device numbers moved, and fails the build when they moved too far. This is where the tolerance semantics and the drift metrics live: nothing on the inference path needs them, so an app shipping a model does not carry them.
Everything here is platform-neutral. The bundle that reads goldens from a
directory lives in package:fluttorch_test/io.dart, so that importing the
gate does not drag dart:io into a suite that runs on the web.
Classes
- BytesGoldenBundle
- A bundle that resolves a key to the raw bytes stored under it.
- DriftReport
- The result of replaying one golden case on one backend.
- GoldenBundle
- The reference inputs and outputs captured at export time.
- MatrixEntry
- One export measured on one backend, as the matrix takes it.
- MemoryGoldenBundle
- Goldens held in memory, keyed exactly as the manifest names them.
- ModelArtifact
- A model artifact together with the manifest it was exported with.
- ParityMatrix
- The same goldens measured across every backend a machine offers.
- TensorDrift
- Measured divergence of one output tensor from its reference.
- Tolerance
- How far an on-device output may stray from its reference before the parity gate fails.
Functions
-
expectParity(
LoadedModel model, {required GoldenBundle goldens, Tolerance? tolerance}) → Future< void> - Asserts that every golden passes, failing with a report that names the tensor, the drift, the tolerance and the backend that produced it.
-
measureDrift(
{required Tensor actual, required Tensor reference, required Tolerance tolerance}) → TensorDrift -
Measures how far
actualstrayed fromreference. -
measureMatrix(
Iterable< MatrixEntry> entries, {Tolerance? tolerance}) → Future<ParityMatrix> - Replays one set of goldens across several backends and reports all of them.
-
measureParity(
LoadedModel model, {required GoldenBundle goldens, Tolerance? tolerance}) → Future< List< DriftReport> > -
Replays every golden against
modeland returns one report per case. -
parityMatrix(
FluttorchRuntime runtime, {required ModelArtifact artifact, required GoldenBundle goldens, Tolerance? tolerance}) → Future< Map< String, List< >DriftReport> > - Runs the same goldens across every backend the device offers.