Fix SplitToSequence with scalar uneven split producing incorrect equal-split output#2858
Draft
Fix SplitToSequence with scalar uneven split producing incorrect equal-split output#2858
Conversation
…lit node When split is a scalar that doesn't evenly divide the axis dimension, create an explicit split sizes tensor and pass it to Split, instead of using num_outputs alone (which would produce an equal split). Example: input [1,8400,80] with scalar split=5000 on axis=1 now correctly produces [1,5000,80] and [1,3400,80] instead of [1,4200,80] and [1,4200,80]. Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [ISSUE-123] Fix SplitToSequence layer with unequal split in ONNX model
Fix SplitToSequence with scalar uneven split producing incorrect equal-split output
Mar 18, 2026
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.
When optimizing
SplitToSequencewith a scalarsplitthat doesn't evenly divide the axis dimension, the optimizer was emitting aSplitnode with onlynum_outputs, which produces an equal split — silently corrupting the model semantics.Example: Input
[1, 8400, 80]withsplit=5000onaxis=-2should produce[1, 5000, 80]+[1, 3400, 80], but was producing[1, 4200, 80]+[1, 4200, 80].Changes
optimizer/_constant_folding.py— Insplit_to_sequence, when the scalar split doesn't evenly divide the axis dimension (split_dimension_size % split_size != 0), construct an explicit 1-D constant tensor[split_size, ..., remainder]and pass it as thesplitinput toSplit. Even splits retain the existingnum_outputs-only path.optimizer/_constant_folding_test.py— Adds a regression test asserting the generatedSplitnode carries explicit split sizes[5000, 3400]rather than performing an equal split.Original prompt
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.