Skip to content

Fix ONNX node name sanitization and add ai.onnx.ml domain support #3371

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 7 commits into from
Jul 16, 2025

Conversation

antimora
Copy link
Collaborator

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

Changes

Fixed ONNX import issues:

  1. Node name sanitization: Enhanced format_name function to sanitize node names with invalid identifier characters (:, /, etc.) by replacing them with underscores
  2. ONNX domain support: Added support for ai.onnx.ml domain in addition to standard ONNX domain

This allows importing ONNX models generated by tf2onnx that contain special characters in node names.

Testing

  • Added unit tests covering the problematic node name from the issue and various edge cases
  • Verified the original failing ONNX file now imports successfully
  • All existing tests pass

antimora added 3 commits July 11, 2025 13:50
Sanitizes node names containing invalid identifier characters like ':' and '/' by replacing them with underscores, preventing panic during ONNX import.
The check_opset_version function now supports both the standard ONNX ('') and ML ('ai.onnx.ml') domains, panicking for unsupported domains. This improves compatibility with models using ML operators.
@antimora antimora mentioned this pull request Jul 11, 2025
1 task
@antimora
Copy link
Collaborator Author

The name sanitization is happening in burn-import instead of onnx-ir. This is simpler for now and updates existing sanitization in place related. Added a todo to come back. #3208 PR attempted to fix in onnx-ir but added up introducing new issues because some names relied on old unsanitized names thus breaking code.

@antimora antimora requested a review from laggui July 11, 2025 19:14
Copy link

codecov bot commented Jul 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 30.90%. Comparing base (fb3843e) to head (00e743d).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3371      +/-   ##
==========================================
- Coverage   35.19%   30.90%   -4.29%     
==========================================
  Files         342      413      +71     
  Lines       53164    60529    +7365     
==========================================
- Hits        18712    18709       -3     
- Misses      34452    41820    +7368     

☔ 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.

Copy link
Member

@laggui laggui left a comment

Choose a reason for hiding this comment

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

Fix looks good, just a minor comment for the implementation 🙂

What's the motivation behind extending support for ai.onnx.ml domain? We would need a separate list for these ops, which I'm not sure is desirable.

@antimora
Copy link
Collaborator Author

Fix looks good, just a minor comment for the implementation 🙂

What's the motivation behind extending support for ai.onnx.ml domain? We would need a separate list for these ops, which I'm not sure is desirable.

Sorry I should have explained. TensorFlow adds this when exporting even though no ops are used. I have discovered this when testing an onnx file in #2878

antimora added 3 commits July 14, 2025 11:52
Simplifies and improves the logic for sanitizing names to valid Rust identifiers. The new implementation replaces invalid characters with underscores and ensures the name starts with a valid character, removing special handling for numeric names.
Added a section listing ONNX ML domain operators that are currently not supported for import or Burn support, along with reference links for each operator.
Copy link
Member

@laggui laggui left a comment

Choose a reason for hiding this comment

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

Sorry I should have explained. TensorFlow adds this when exporting even though no ops are used.

Ahh ok I see, LGTM then!

But I think we should just accept the domain without listing the ops.

@antimora antimora requested a review from laggui July 15, 2025 21:05
Copy link
Member

@laggui laggui left a comment

Choose a reason for hiding this comment

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

Thank you!

@laggui laggui merged commit 800e224 into tracel-ai:main Jul 16, 2025
10 of 14 checks passed
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.

bug(onnx): model created using tf2onnx panics with non-valid Ident
2 participants