Repository navigation
D-TRACT-SHAPE-1 follow-up: int64 compares/Where, ConstantOfShape, Expand; optional-output producer test - #1854
Conversation
…and; optional-output producer test Registry v3 registers int64 Equal and LessOrEqual through ndarray #400's eq/le_i64 pair and scalar mask kernels, int64 Where through blend_i64 / blend_i64_scalar, ConstantOfShape through ArrayD::from_elem and Expand (int64, f32) through ndarray broadcast. A comparison admits a same-shape or one-element right side; other broadcasts are not admitted. New fixtures (ORT ORT_DISABLE_ALL): shape_i64 (every int64 node folds, Expand(F) runs, all outputs match ORT exactly) and lstm_skip/lstm_full, which pin source_producers on a node with an omitted optional output: Tract numbers outlets after dropping empty names, and the fact admitted for Y_h is Y_h's (ORT [1,1,2]), not the omitted Y's. Jina [1,10] coverage 6,404/56/1,160 -> 6,581/114/925; the 58 newly not-true nodes are UNKNOWN (an Expand target computed by unregistered int64 arithmetic) or not admitted (one general-broadcast LessOrEqual). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMjKnig6MXTd41Lf2v
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMjKnig6MXTd41Lf2v
int64 Div (on negatives), Mul, Add, Sub and Range over Shape(F), with ORT's outputs frozen; the test pins that they stay refused (unregistered) until ndarray supplies checked words. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMjKnig6MXTd41Lf2v
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMjKnig6MXTd41Lf2v
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
…oducer, binding and mask-tail tests source_producers enumerates each node's ONNX output positions first and maps a position to Tract's outlet slot with tract_slot (the number of named outputs before it, as onnx/src/model.rs:150 numbers outlets). FactSources records the source it was read from; merged_for refuses facts of another model. Tests: ['', 'Y'] and multi-output slot mapping; producer collisions (two producers, a value that is also an input or initializer, duplicate node names, an unnamed node without a first output); a fact from a renamed producer; facts of another model; int64 compares and Where over a 70-element mask (tail bits clear, scalar and pair); ConstantOfShape (default value, scalar output for an empty shape, zero dims, bool fill, K3 refusals; the shape input must be 1-D) and Expand (multidirectional broadcast) semantics. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMjKnig6MXTd41Lf2v
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMjKnig6MXTd41Lf2v
…e vs shape-only nodes; plan, board Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XAqKMMjKnig6MXTd41Lf2v
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 76374275b2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if let (1, Some(&yv)) = (y.len(), y.iter().next()) { | ||
| ndarray::simd::blend_i64_scalar(words, &xs, yv, &mut out); |
There was a problem hiding this comment.
Reject scalar Y tensors that increase the Where output rank
When C and X have shape [3] and the one-element Y has shape [1, 1], the reused guard_where returns TRUE, but ONNX multidirectional broadcasting requires an output of shape [1, 3]. This scalar branch instead returns a tensor with X's shape [3]. Both cold folding and runtime execution can therefore silently produce the wrong output shape for an admitted int64 Where. Require Y's rank to be no greater than X's in both the guard and runtime scalar path, or construct the full broadcast output shape.
Useful? React with 👍 / 👎.
Follow-up to #1853 and ndarray #400, applying the owner decisions recorded after both merged. This is lab probe work only (
crates/tract-harvest-probe): no production ClassId is minted and no full Jina runtime is started. Plan:.claude/plans/d-tract-harvest-0-native-algebra-bridge-v1.md§0.3.Optional empty output slots, producer identity, stale bindings
source_producersnow enumerates each node's ONNX output positions first, then converts each position to Tract's outlet slot withdr3::tract_slot. That slot is the number of named outputs before the position, which is how Tract numbers outlets (onnx/src/model.rs:150filters empty names before enumerating). Using the raw ONNX position as the slot would point at the wrong outlet whenever an omitted output comes first. Measured onLSTM ["", "Y_h"], that would rejectY_h's correct fact.FactSourcesnow records the source it was read from, andmerged_forrefuses facts read from another model.Each case below has its own test:
["", "Y"]and multiple outputs with a gapgen2applied tobase)lstm_skip/lstm_fullagainst Tract and ORT: the fact admitted forY_hisY_h's[1,1,2], not the omittedY's[5,1,1,2]Registry v3 (ndarray #400 and existing ndarray functionality)
Equaleq_i64_pair_to_mask/eq_i64_to_maskLessOrEqualle_i64_pair_to_mask/le_i64_to_maskWhereblend_i64/blend_i64_scalarConstantOfShapeArrayD::from_elemExpand(int64, f32)broadcastint64 compares and
Where. The right side must have the same shape or one element; any other broadcast is WHEN FALSE, and the same case is refused at run time too. Tested on 70 elements, across a mask word: the pair and scalar forms set the right bits and leave every bit past the last element clear.Whereis tested with a scalar and with a tensorY.ConstantOfShape, ONNX semantics:Expanduses the multidirectional broadcast: a target dimension of 1 keeps the input's dimension, and a shorter target is padded on the left.On fixture
shape_i64(ORTORT_DISABLE_ALL), every int64 node overShape(F)folds,Expand(F)runs at run time, and every output equals ORT exactly.Jina census (inputs pinned to [1,10])
Coverage, as [WHEN-true, WHEN-not-true, unregistered]:
ConstantOfShape)The 56 Reshapes that were blocked do not resolve yet. For every one of them, the first unregistered op their target depends on is int64
Mul.The 114 not-true nodes:
Reshape56 andExpand57 are UNKNOWN: their target is computed through int64Mul/Div.LessOrEqual1 compares[S,1]against[1,S], a broadcast that is not admitted.Nodes that are not folded, 3,121 in total:
int64 arithmetic: the ndarray ask
int64
Add/Sub/Mul/Div/Rangestay refused and are not implemented locally. Plan §0.3 lists:The failing fixture is
fixtures/tiny/i64_arith.onnx, with its ORT outputs frozen;int64_arithmetic_is_refused_until_checked_words_existpins the current refusal. The int64 compares, blends, Gather and MatMul from #400 are not re-requested.Integration acceptance — a whole shape-arithmetic chain that folds or executes through admitted methods and matches ORT exactly — waits on those words, with
i64_arithas its fixture.Tests and disable runs
55 tests pass with
--include-ignored; clippy (-D warnings) and fmt are clean. Each disable run turned its named test red:Equalkernel replaced byleConstantOfShapeignoring its valueConstantOfShapeaccepting a shape input of any rank🤖 Generated with Claude Code
https://claude.ai/code/session_01XAqKMMjKnig6MXTd41Lf2v