Enable ScatterElements in-place reuse when planner shape map is missing - #32093
Draft
Hariharan Seshadri (hariharans29) with Copilot wants to merge 3 commits into
Draft
Enable ScatterElements in-place reuse when planner shape map is missing#32093Hariharan Seshadri (hariharans29) with Copilot wants to merge 3 commits into
Hariharan Seshadri (hariharans29) with Copilot wants to merge 3 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Copilot started work on behalf of
Hariharan Seshadri (hariharans29)
August 14, 2026 19:14
View session
Co-authored-by: hariharans29 <9969784+hariharans29@users.noreply.github.com>
Co-authored-by: hariharans29 <9969784+hariharans29@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix CPU ScatterElements to avoid unnecessary data copying
Enable ScatterElements in-place reuse when planner shape map is missing
Aug 14, 2026
Copilot started reviewing on behalf of
Hariharan Seshadri (hariharans29)
August 15, 2026 04:39
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Attempts to enable in-place buffer reuse when planner shapes are unavailable.
Changes:
- Adds a
TypeProtoshape fallback. - Adds symbolic-shape planner coverage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
allocation_planner.cc |
Adds shape fallback logic. |
allocation_planner_test.cc |
Adds fallback reuse test. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+559
to
+560
| // Fall back to NodeArg type metadata when the planning context doesn't have shape entries. | ||
| // This allows may-inplace reuse for symbolically-shaped tensors when both type-proto shapes match. |
Comment on lines
+524
to
+527
| // Do not populate planner context shapes. Instead provide equivalent shape metadata via NodeArg type protos. | ||
| Type symbolic_type{"M", "N"}; | ||
| Arg(X2)->SetType(symbolic_type.value); | ||
| Arg(X3)->SetType(symbolic_type.value); |
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.
Description
ScatterElementson CPU always paid a fulldata -> outputcopy unless buffers were already aliased; in practice, planner-sideMayInplace(0,0)reuse was often blocked when context shapes were unavailable (common with symbolic shapes). This change makes the reuse decision use existingNodeArgtype-proto shape metadata when planner shape entries are absent.Planner reuse eligibility
allocation_planner.cc::SameSize(const NodeArg&, const NodeArg&):TypeAsProto()metadata.Regression coverage
PlannerTest.InPlaceTestWithTypeProtoShapeFallbackinallocation_planner_test.cc.MayInplacereuse (kReuse) with symbolic type-proto shapes and no planner context shape entries.Motivation and Context
ScatterDatais designed to skip the copy when input/output buffers alias, but planner constraints around shape availability made that path hard to reach, especially for symbolic-shape graphs (e.g.,ConstantOfShape(Shape(x)) -> ScatterElements). This change removes a planner blind spot so valid in-place reuse can be selected more often without relaxing safety checks.