Skip to content

fix(rewriter): preserve PRelu data-input expansion - #3147

Open
DiadkoShmek wants to merge 1 commit into
microsoft:mainfrom
DiadkoShmek:lezo2-fix-prelu-data-expand
Open

DiadkoShmek wants to merge 1 commit into
microsoft:mainfrom
DiadkoShmek:lezo2-fix-prelu-data-expand

Conversation

@DiadkoShmek

Copy link
Copy Markdown

Removing an Expand from PRelu's data input can turn a valid model into one rejected by full ONNX checking and strict shape inference. PRelu broadcasts the slope to the data shape; its other input cannot supply bidirectional broadcasting to justify that rewrite.

For example, x: float[3] expanded to [2,3] with a float[2,3] slope is valid. The current rewrite removes Expand, after which shape inference reports rank 1 against the declared rank 2 output. Omit only the first/data-input PRelu rule, retaining slope-side removal and every other operator's registrations.

Six regressions fail full validation on the original rule, and the safe slope-side control passes. After the change all 21 tests in the rule module pass. An independently generated 124-case check covers rank/singleton growth, symbolic and unknown dimensions, runtime targets, shared graph outputs and Add/Mul controls; all fixed graphs pass both validators. lintrunner -a and git diff --check pass.

This concerns the exported opt-in expand_before_binary_op_rules, not the default optimizer rule list. ONNX Runtime permissively computes the same values for the invalid original rewrite; no numerical runtime failure is claimed. Conservatively retaining a redundant data-side Expand is intentional.

AI assistance: OpenAI Codex investigated, implemented and independently checked this change with pinned local Python/ONNX/ORT dependencies. No human code review, full-suite validation or upstream acceptance is claimed.

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