[tmva][sofie] Do not mutate the indices tensor in Gather codegen - #23231
Merged
guitargeek merged 1 commit intoSep 3, 2026
Merged
Conversation
When the gather indices are not a known constant, the generated code
corrected possible negative indices by writing them back into the
indices tensor:
if (tensor_receivers[i] < 0)
tensor_receivers[i] += 5;
If the indices tensor is a model input, the generated pointer is
"int64_t const*" and the emitted code does not compile. Runtime gather
indices that are graph inputs are the norm for graph neural networks,
where the edge sender/receiver lists are fed at inference time.
Emit the correction at the read site instead, leaving the input tensor
untouched.
Covered by the new GatherRuntimeNegativeIndices test model, whose gather
indices are a graph input instead of an initializer. The existing
Gather tests all pass the indices as initializers, so the generated code
took the constant-index branch and never exercised the correction.
🤖 Done with the help of AI
Test Results 22 files 22 suites 3d 9h 43m 50s ⏱️ For more details on these failures, see this check. Results for commit e4b49be. |
lmoneta
approved these changes
Sep 3, 2026
lmoneta
left a comment
Member
There was a problem hiding this comment.
LGTM!
Thank you Jonas for the fix!
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 the gather indices are not a known constant, the generated code corrected possible negative indices by writing them back into the indices tensor:
if (tensor_receivers[i] < 0)
tensor_receivers[i] += 5;
If the indices tensor is a model input, the generated pointer is "int64_t const*" and the emitted code does not compile. Runtime gather indices that are graph inputs are the norm for graph neural networks, where the edge sender/receiver lists are fed at inference time.
Emit the correction at the read site instead, leaving the input tensor untouched.
Covered by the new GatherRuntimeNegativeIndices test model, whose gather indices are a graph input instead of an initializer. The existing Gather tests all pass the indices as initializers, so the generated code took the constant-index branch and never exercised the correction.
🤖 Done with the help of AI