Skip to content

fix(fuse_batchnorm): support convtranpose + bn fusion with group != 1#2879

Merged
gramalingam merged 1 commit intomicrosoft:mainfrom
AyoubMDL:convtranspose-bn-grouped
Apr 10, 2026
Merged

fix(fuse_batchnorm): support convtranpose + bn fusion with group != 1#2879
gramalingam merged 1 commit intomicrosoft:mainfrom
AyoubMDL:convtranspose-bn-grouped

Conversation

@AyoubMDL
Copy link
Copy Markdown
Contributor

@AyoubMDL AyoubMDL commented Apr 1, 2026

Fixes #2867

@justinchuby
Copy link
Copy Markdown
Collaborator

Thanks!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes BatchNormalization fusion for grouped ConvTranspose so that optimization no longer crashes (broadcast/reshape mismatch) when group != 1, addressing #2867.

Changes:

  • Implement group-aware weight scaling for ConvTranspose + BatchNormalization fusion.
  • Add a guard to skip fusion for semantically invalid grouped ConvTranspose (when in_channels % group != 0).
  • Expand tests to cover grouped Conv/ConvTranspose fusion and the invalid-model skip case.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
onnxscript/rewriter/rules/common/_fuse_batchnorm.py Refactors weight scaling and adds correct grouped ConvTranspose handling + validation to avoid reshape/broadcast failures.
onnxscript/rewriter/rules/common/_fuse_batchnorm_test.py Extends unit tests for grouped fusion behavior and adds a regression test for invalid grouped ConvTranspose.

Comment thread onnxscript/rewriter/rules/common/_fuse_batchnorm.py
Comment thread onnxscript/rewriter/rules/common/_fuse_batchnorm_test.py
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 2, 2026

Codecov Report

❌ Patch coverage is 91.89189% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.97%. Comparing base (1077da7) to head (3c55666).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
...nnxscript/rewriter/rules/common/_fuse_batchnorm.py 87.50% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2879   +/-   ##
=======================================
  Coverage   71.96%   71.97%           
=======================================
  Files         239      239           
  Lines       29224    29251   +27     
  Branches     2878     2880    +2     
=======================================
+ Hits        21031    21053   +22     
- Misses       7216     7219    +3     
- Partials      977      979    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gramalingam gramalingam merged commit 13f265c into microsoft:main Apr 10, 2026
31 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

fusion of grouped ConvTranspose and BatchNormalization results in exception

4 participants