Skip to content

Commit bd77675

Browse files
authored
Merge pull request #1780 from AdaWorldAPI/docs/d-nam-2-onnx-tflite-dto-20261025
spec(D-NAM-2): ONNX/TFLite leaf DTO adapters, BOOL and quantization contracts
2 parents 538bc17 + 9c5eef0 commit bd77675

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# D-NAM-2 — ONNX and TFLite thin DTO compatibility leaves
2+
3+
**2026-10-25 • PROPOSED ENGINEERING SPEC / DOCS ONLY.** Parent [D-NAM capstone](d-nam-native-algebra-dto-capstone-v1.md), [EXO-152](https://linear.app/exo-red/issue/EXO-152). D-NFC #1753 is binding; no new graph IR or executor.
4+
5+
## Verified current baseline
6+
`crates/lance-graph-onnx` exists on main (PR #1754 and #1758 merged), depends normally only on ndarray, and has exact aliases, inline shape/overflow checks, bounded Tanh/Exp aliases. Its own docs explicitly forbid runtime dispatch and graph parsing. At the read, no `crates/lance-graph-tflite` was found on main; AdaWorldAPI/tflite2onnx is a conversion fork, **not** native TFLite facade evidence.
7+
8+
## Work split
9+
1. **ONNX compatibility**: do not rewrite or duplicate #1754. Build a cold, versioned **DTO mapping table/test layer** referencing existing native aliases. Verify against pinned official ONNX IR/opset schema (domain, since_version, attributes, functions, axes-as-input, shape and type). Map node patterns only when pattern recognition and every output are admissible; otherwise explicit refusal. Preserve symbolic shapes, external weights and control-flow effects as *unadmitted* until separately implemented.
10+
2. **TFLite compatibility**: a future, independently authorized `lance-graph-tflite` leaf may expose only verified native aliases/inline conversions to the *same* native methods. No FlatBuffer parser in hot path and no ONNX facade dependency. The schema must pin BuiltinOperator, BuiltinOptions, subgraph signatures, type, data layout and versions.
11+
3. **Boolean boundary**: TFLite/ONNX external `BOOL` serialized values are not literally `[u64]` packed DR/native mask words. Explicit cold/prologue packing/unpacking or a compatible external buffer view; test tail bits, scalar flags, shape and output. Include conversion cost.
12+
4. **Quantization**: TFLite affine `real=scale*(q-zero_point)` is not Palette256/Fisher-Z; preserve zero points, per-channel scales, accumulator width, rounding, bias, saturation, activation range. Exact quantized interpretation and calibrated approximation are separate arms; do not auto-enable palette.
13+
5. **Nonnumeric**: tensors, variable state, IF/WHILE, custom ops, dynamic reshape, gather/scatter or unsupported FLOAT formats typed-refuse under STRICT_NATIVE. External interpreter is differential oracle only, never hidden fallback.
14+
15+
## Positive fixtures (separate row keys, not blanket compatibility)
16+
- rank-1 signed i32 `GREATER`/ONNX `Greater` -> native `gt_i32_to_mask` with explicit internal mask conversion.
17+
- `SELECT_V2` / ONNX `Where` i32 -> native blend, shape and operand order explicit.
18+
- `SUM` / ONNX `ReduceSum`: guarded reductions; compare `Greater/Where/ReduceSum` against `GREATER/SELECT_V2/SUM` and same native fold only for bounded integer sums, axes/keepdims/shape identical.
19+
- `TANH` / ONNX `Tanh`: f32 ULP-bounded ndarray native alias where numeric contract admits; TFLite int8 TANH is **not** a free f32 alias.
20+
21+
## Required negatives and acceptance gates
22+
Wrong operator-version default, BOOL representation mismatch, broadcasting error, reduce overflow and empty axes, signed zero, NaN, Infinity, subnormal, uint8/i8 zero-point mismatch, per-channel scale mismatch, wrong control-flow effect, unrecognized custom op. Independent ONNX Runtime and TFLite interpreter fixture versions named, checked only in offline tests. At least two hostile mutations cause typed refusal. No cross-dependency from native crates to these leaves, no per-call routing, no new tensor AST. Implementation requires an owner-approved follow-up PR with actual code, CI and receipt; this document does not claim it.

0 commit comments

Comments
 (0)