Repository navigation
[Rewriter] Support default attribute matching and validate attribute safety in ScatterAllDynamic - #3193
Conversation
Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…ynamic check Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…namic check Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
|
Hi maintainers, Justin Chu (@justinchuby) and Ti-Tai Wang (@titaiwangms) I've opened this PR to improve It now handles omitted default attributes for Thanks for taking a look. I'd appreciate your feedback! |
| """Shape with non-zero start attribute should be safely rejected.""" | ||
| model_text = """ | ||
| <ir_version: 8, opset_import: ["" : 17]> | ||
| test (float[4, 8] data, float[8, 4] transposed_data, float[8, 4] updates) => (float[8, 4] out) |
There was a problem hiding this comment.
Fixed in commit 9eb5bfe6 — updated the fixture to data: float[8, 4], transposed_data: float[8, 4], updates: float[4, 4] with axis = 0 (and added onnx_check(model)), so the existing dimension check passes and Shape.start = 1 is what blocks the rewrite.
| test (float[4, 8] data, float[8, 4] transposed_data, float[8, 4] updates) => (float[8, 4] out) | ||
| < | ||
| int64 axis = {0}, |
There was a problem hiding this comment.
Fixed in commit 9eb5bfe6 — updated the fixture to data: float[4, 8], transposed_data: float[8, 4], updates: float[4, 4] with axis = -1 (and added onnx_check(model)), so the dimension check passes and the Shape.end guard is directly exercised.
… in ScatterAllDynamic Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
|
Hi Ti-Tai Wang (@titaiwangms), I updated the |
|
You missed the same default-attribute case on the Gather: the pattern still has Minor: |
…k Shape start in ScatterAllDynamic Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…Shape start=-rank Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
|
Good catch, dfedoryshchev — thanks for spotting both! I updated the PR (commits
|

Description
This PR improves the
ScatterAllDynamicrewrite rule by handling omitted default attributes correctly and validating attribute values before applying the rewrite.Previously, the pattern explicitly specified
Shape(start=0)andScatterND(reduction="none"), which prevented matching equivalent ONNX nodes where these default attributes were omitted.The rewrite also needed additional safeguards to ensure that
Shapecomputes the full input dimensions and thatScatterNDperforms assignment rather than a reduction. Without these checks, applying the rewrite could change model semantics.Changes
ShapeandScatterNDwithout explicitly specifying their default attributes.Shape.startis zero andShape.endis not specified. Attribute references and unsupported values are safely rejected.reductionattribute is either omitted or explicitly set to"none". Attribute references and other reduction modes are rejected.Shape.start, the presence ofShape.end, and unsupportedScatterNDreduction modes.These changes make the rewrite more robust while preventing transformations when the required semantic conditions are not satisfied.