onnx: re-land #89 — Pad (4 modes), Cast, Shrink, OneHot (merge-order casualty) - #90
Merged
Conversation
…rdware wall Pad lowers each padded axis to concats: const border blocks (constant), repeated edge slices (edge), reversed interior slices (reflect), or the opposite end (wrap); constants fold via np.pad. Probing on-device found an Espresso quirk: a 3-part concat with two const borders fails to lower once a second padded axis stacks on top, while nested 2-part concats compile and are bit-exact - constant mode builds pairwise concats for that reason. Cast folds constants, treats float->float on an activation as identity (the engine computes fp16 regardless), and lowers float->int as sign(x)*floor(|x|) (toward-zero, exact in fp16 integer range). Shrink is a nested select against baked thresholds. OneHot compares the index tensor against a baked arange along the inserted axis and selects on/off values; the constant path implements full ONNX wrap/out-of-range semantics. And/Or/Xor and IsNaN are deliberately NOT added, with evidence: the MIL vocabulary sweep shows logical_and/or/xor and general cast are not implemented on the ANE backend (probed again today - the type system rejects arithmetic on bool and select requires same-dtype branches), and an fp16 NaN fed on-device reads x != x as false, so IsNaN would be silently wrong. docs/onnx.md now records this boundary. 154 tests pass on-device (M5); Pad checks all four modes against onnxruntime, Cast/Shrink/OneHot likewise (OneHot feeds int64 to ORT, fp16-encoded indices to the engine).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#89 shows as merged but its diff never reached
main: it was merged into theonnx/tier1-coveragebranch 42 seconds after #88 had already squash-merged that branch to main, and the branch was then deleted — the classic stacked-PR ordering trap (the stack needed #88's branch deletion to retarget #89 before merging it). This PR re-lands the identical commit, rebased onto current main.Content is exactly #89's (see its description for the full write-up): Pad (constant/edge/reflect/wrap, with the nested-2-part-concat workaround for the Espresso lowering quirk), import-level Cast, Shrink, OneHot, and the documented boolean/IsNaN hardware boundary in docs/onnx.md. Registered op names 100 → 104.
Re-verified after rebase, on-device (M5):
pytest tests/test_onnx.py— 154 passed.