Skip to content

burn-import: add some tests for ConstantNode #2623

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 24 commits into from
Apr 7, 2025

Conversation

jameshiew
Copy link
Contributor

@jameshiew jameshiew commented Dec 17, 2024

Pull Request Template

Checklist

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

Related Issues/PRs

I've been trying to implement OneHot ONNX op (#1714) in a WIP draft branch. The ONNX model ends up containing a constant integer vector values=[0, 1] used by the OneHot op, this vector was causing issues when trying to test the model. I looked at ConstantNode and these are the tests so far I could get working while investigating.

Issues for ConstantNode
#2624 - constant tensors aren't populated with values
#2625 - generated code for const int tensors doesn't compile

Changes

  • added a helper method ConstantNode::tensor_ty_tokens for tests, but this PR otherwise shouldn't be changing how ConstantNode currently works
  • add codegen tests for ConstantNode (i32/64 + f32/64 scalar, tensors)
  • add ONNX model tests for i32/64 + f32/64 scalars - implicitly testing by adding the constant

Testing

Ran added tests

cargo xtask check all
cargo nextest run --manifest-path crates/burn-import/Cargo.toml
cargo nextest run --manifest-path crates/burn-import/onnx-tests/Cargo.toml

I checked the .onnx models contain the expected scalar constants using Netron

Screenshots f32 f64 i32 i64

@jameshiew jameshiew marked this pull request as ready for review December 17, 2024 19:16
Copy link

codecov bot commented Jan 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.91%. Comparing base (5d16339) to head (83458c6).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2623      +/-   ##
==========================================
+ Coverage   80.84%   80.91%   +0.06%     
==========================================
  Files         872      872              
  Lines      120725   121039     +314     
==========================================
+ Hits        97605    97938     +333     
+ Misses      23120    23101      -19     

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

github-actions bot commented Feb 2, 2025

This PR has been marked as stale because it has not been updated for over a month

@github-actions github-actions bot added the stale The issue or pr has been open for too long label Feb 2, 2025
@jameshiew jameshiew force-pushed the onnx-constant-tests branch from 756fd3c to a1f87b8 Compare February 9, 2025 11:10
@jameshiew jameshiew force-pushed the onnx-constant-tests branch from a1f87b8 to 7291b0a Compare February 9, 2025 11:17
@github-actions github-actions bot removed the stale The issue or pr has been open for too long label Feb 9, 2025
@antimora antimora requested a review from laggui March 10, 2025 17:35
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.

Was going through pending PRs, figured I'd apply the suggested changes myself 😅 so we can finally close this

@laggui laggui merged commit 1965796 into tracel-ai:main Apr 7, 2025
11 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.

2 participants