Skip to content

Optimizer Suggestions for Common Graph Fusions #2301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AyoubMDL opened this issue May 13, 2025 · 1 comment
Open

Optimizer Suggestions for Common Graph Fusions #2301

AyoubMDL opened this issue May 13, 2025 · 1 comment
Assignees
Labels
contribution welcome We welcome code contributions for this good first issue Good for newcomers module: rewriter

Comments

@AyoubMDL
Copy link
Contributor

AyoubMDL commented May 13, 2025

I've been using ONNXScript extensively lately and really appreciate how powerful and flexible it is. As part of that experience, I and @Johansmm would like to suggest a few optimization patterns that could improve performance and simplify common model graphs. These are generally applicable across many models:

  1. Fold BatchNormalization into preceding nodes (Conv, ConvTranspose, Gemm) Rewriter: Fold Batchnorm nodes #2312
  2. Fuse MatMul + Add into Gemm
  3. Fuse Min + Max into Clip
  4. Eliminate redundant Reshape / Flatten nodes
  5. Fold Pad into Conv / ConvTranspose
  6. Fuse successive Clip / ReLU nodes

We're happy to contribute if any of these are a good fit. Feel free to add other suggestions or let us know if some of these are out of scope.

@justinchuby justinchuby added module: rewriter good first issue Good for newcomers contribution welcome We welcome code contributions for this labels May 13, 2025
@justinchuby
Copy link
Collaborator

Thanks! All of the above sounds good. PRs welcomed. For (2) we want it to be optional because some runtimes prefer one way over another. You may add the rules in https://github.com/microsoft/onnxscript/tree/main/onnxscript/rewriter and use the existing ones as reference.

Johansmm added a commit to Johansmm/onnxscript that referenced this issue May 22, 2025
Johansmm added a commit to Johansmm/onnxscript that referenced this issue May 26, 2025
Johansmm added a commit to Johansmm/onnxscript that referenced this issue May 26, 2025
justinchuby pushed a commit that referenced this issue May 27, 2025
Fuses `BatchNormalization` nodes into the following nodes (`Conv`,
`ConvTranspose`, `Gemm`)
(#2301)
Johansmm added a commit to Johansmm/onnxscript that referenced this issue May 30, 2025
Johansmm added a commit to Johansmm/onnxscript that referenced this issue May 30, 2025
Johansmm added a commit to Johansmm/onnxscript that referenced this issue May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome We welcome code contributions for this good first issue Good for newcomers module: rewriter
Projects
None yet
Development

No branches or pull requests

2 participants