Expand description
ONNX inference for IMF v1 artifacts: the greedy single-row decode
loop (the artifact contract per CONFORMANCE.md) over a mockable
InferenceEngine trait, plus the ort-backed implementation.
Byte-exactness contract (mirror of
pipeline.conformance.ort_single_row_decoder, the reference the
fixtures were generated with):
- encode: ids = UTF-8 byte + 3, one trailing EOS; int64, one row;
- encoder: one row per call, no padding, no attention mask;
- decoder: greedy argmax until EOS, 512-step cap, prefix
[PAD]then growing; - output:
max(0, t - 3)per id, lossy UTF-8.
Structs§
- OrtEngine
- An
ort-loaded IMF artifact: encoder + decoder sessions plus the ONNX Runtime environment they share.
Constants§
- MAX_
DECODE_ STEPS - Decode-step step cap. CONFORMANCE.md: “greedy argmax until EOS, 512-step cap”.
Traits§
- Inference
Engine - The engine abstraction: one encoder pass + one decoder step at a
time.
ortsessions implement it; tests drive the loop with a deterministic mock.
Functions§
- greedy_
generate - The greedy single-row decode loop (model.generate + tokens.decode parity). Empty input (only the trailing EOS) short-circuits to no tokens, exactly like the reference loader.
- ids_
to_ fixture_ bytes - The fixture-generation byte rule:
max(0, t - 3)per id (no pad/unk skipping — a PAD argmax yields byte 0x00 there), then lossy UTF-8. Used by the conformance harness so frozen vectors are compared byte-exactly under the rule that produced them. - ids_
to_ fixture_ string - translate
translate(text): greedy ids -> text. Conformance fixtures were generated with themax(0, t - 3)byte rule (seeids_to_fixture_bytes);tokens::decodeimplements the SPEC §4 table (skip pad/unk, mod 256). This function uses the SPEC table.