Skip to content

Add support onnx instance norm #3177

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

Merged
merged 3 commits into from
May 10, 2025
Merged

Conversation

tye-singwa
Copy link
Contributor

@tye-singwa tye-singwa commented May 9, 2025

Pull Request Template

Checklist

  • Confirmed that cargo run-checks command has been executed.
  • Made sure the book is up to date with changes in this PR.

Related Issues/PRs

#1714, #673

Changes

Adding InstanceNorm onnx support

Testing

Added tests for 1d, 2d and 3d

@tye-singwa tye-singwa marked this pull request as ready for review May 9, 2025 20:50
Copy link

codecov bot commented May 9, 2025

Codecov Report

Attention: Patch coverage is 99.71429% with 1 line in your changes missing coverage. Please review.

Project coverage is 82.19%. Comparing base (f18cb7f) to head (89bf199).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
crates/onnx-ir/src/node/instance_norm.rs 97.61% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3177      +/-   ##
==========================================
+ Coverage   82.14%   82.19%   +0.04%     
==========================================
  Files         956      962       +6     
  Lines      121842   122340     +498     
==========================================
+ Hits       100090   100559     +469     
- Misses      21752    21781      +29     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@antimora antimora requested review from Copilot and antimora May 10, 2025 14:30
Copy link

@Copilot 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

This PR adds support for ONNX InstanceNormalization by integrating it throughout the IR, conversion, codegen, and tests. Key changes include:

  • Adding a new InstanceNormalization branch in rank inference and node modules.
  • Implementing InstanceNorm configuration and code generation in onnx-ir and burn-import.
  • Integrating InstanceNormalization tests and updating documentation and build scripts.

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/onnx-ir/src/rank_inference.rs Added InstanceNormalization handling in rank inference
crates/onnx-ir/src/node/mod.rs Registered new instance_norm module
crates/onnx-ir/src/node/instance_norm.rs Introduced InstanceNormConfig and its tests
crates/onnx-ir/src/from_onnx.rs Added InstanceNormalization conversion logic
crates/burn-import/src/onnx/to_burn.rs Integrated InstanceNorm conversion into the Burn graph conversion
crates/burn-import/src/burn/node/mod.rs Registered InstanceNorm in the burn node enum
crates/burn-import/src/burn/node/instance_norm.rs Implemented InstanceNorm node codegen and serialization
crates/burn-import/onnx-tests Added InstanceNormalization onnx tests (1d, 2d, and 3d)
crates/burn-import/SUPPORTED-ONNX-OPS.md Updated InstanceNormalization support status

for (key, value) in node.attrs.iter() {
match key.as_str() {
"epsilon" => epsilon = value.clone().into_f32(),
_ => panic!("Unexpected attribute for InstanceNorm: {key}"),
Copy link
Preview

Copilot AI May 10, 2025

Choose a reason for hiding this comment

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

Consider handling unexpected attributes in InstanceNorm more gracefully, for example by logging a warning or returning an error instead of panicking, to improve robustness.

Copilot uses AI. Check for mistakes.

Copy link
Collaborator

@antimora antimora left a comment

Choose a reason for hiding this comment

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

LGTM and clean implementation.

Thank you again for your contribution!

@antimora antimora merged commit 93f367c into tracel-ai:main May 10, 2025
19 of 20 checks passed
@antimora antimora mentioned this pull request May 10, 2025
2 tasks
@tye-singwa tye-singwa deleted the onnx-instance-norm branch June 6, 2025 07:02
Helios113 pushed a commit to Helios113/burn that referenced this pull request Jul 1, 2025
* feat: support onnx instance norm

* fix: fix ci

* fix: fix typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants