Skip to content

Optimizer: don't crash folding SplitToSequence with a dynamic scalar split - #3101

Open
Kayvan Zahiri (Kayvan-Zahiri) wants to merge 1 commit into
microsoft:mainfrom
Kayvan-Zahiri:fix-split-to-sequence-dynamic-scalar
Open

Kayvan Zahiri (Kayvan-Zahiri) wants to merge 1 commit into
microsoft:mainfrom
Kayvan-Zahiri:fix-split-to-sequence-dynamic-scalar

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown
Contributor

optimizer.optimize() raises on the ONNX backend test test_split_to_sequence_1, where split is a scalar graph input:

SplitToSequence <axis: int = 1> (data: float[3,6], split: int64)

split_to_sequence in constant folding finds split_shape == (), so it skips the 1-D branch, then reads split_value.ndim while split_value is None:

AttributeError: 'NoneType' object has no attribute 'ndim'
RuntimeError: Error during constant folding for node '' (::SplitToSequence)

With a scalar split, the number of chunks depends on the split's value, so the folder can't rewrite the node without it. It now returns None in that case, and the node is left as it is.

The new test fails on main with the error above. onnxscript/optimizer tests: 76 passed.

Found by running all ONNX 1.20 backend node test models through optimizer.optimize() and rewriter.rewrite() and comparing onnxruntime outputs before and after, with Claude Code's help. Nothing else in that sweep came from onnxscript: the remaining differences were onnxruntime's own known failures (Resize align_corners, MaxUnpool with output_shape), where the folded result matches the expected outputs.

…split

Signed-off-by: Kayvan Zahiri <kayvanandre@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant