Skip to content

Add onnx SpaceToDepth / DepthToSpace #3277

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
Jun 12, 2025

Conversation

tye-singwa
Copy link
Contributor

@tye-singwa tye-singwa commented Jun 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, #2930

Changes

Adding support for SpaceToDepth / DepthToSpace onnx nodes

Testing

Added a bunch of tests

@tye-singwa tye-singwa force-pushed the onnx-depth-space branch 2 times, most recently from b654cfa to 51073ee Compare June 9, 2025 22:48
@tye-singwa tye-singwa marked this pull request as ready for review June 9, 2025 22:59
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

Attention: Patch coverage is 97.92060% with 11 lines in your changes missing coverage. Please review.

Project coverage is 82.36%. Comparing base (c9dce9b) to head (e8edeb8).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
crates/onnx-ir/src/node/depth_to_space.rs 94.28% 6 Missing ⚠️
crates/onnx-ir/src/node/space_to_depth.rs 92.95% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3277      +/-   ##
==========================================
+ Coverage   82.33%   82.36%   +0.03%     
==========================================
  Files         978      984       +6     
  Lines      124869   125445     +576     
==========================================
+ Hits       102808   103329     +521     
- Misses      22061    22116      +55     

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

@laggui laggui self-requested a review June 10, 2025 19:43
@tye-singwa
Copy link
Contributor Author

Just noticed #2464, maybe it make sense to implement it as separate module in burn-core?

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.

Just a minor comment, otherwise LGTM!

Thanks for the addition 🙏

Comment on lines +31 to +42
// Infer static shape based on rank and block size
let static_shape = tensor.static_shape.clone().map(|shape| {
let [b, c, h, w] = shape
.try_into()
.expect("DepthToSpace: input tensor rank is not 4");
vec![
b,
c / (block_size * block_size),
h * block_size,
w * block_size,
]
});
Copy link
Member

Choose a reason for hiding this comment

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

Not required, but since this will only be applied if the static shape is available we can keep it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As i see across code, some operators require static shape, this is reason why i added it

@tye-singwa tye-singwa requested a review from laggui June 11, 2025 23:02
@laggui laggui merged commit df91c9f into tracel-ai:main Jun 12, 2025
11 checks passed
@tye-singwa tye-singwa deleted the onnx-depth-space branch June 12, 2025 12:44
Helios113 pushed a commit to Helios113/burn that referenced this pull request Jul 1, 2025
* feat: add support for DepthToSpace onnx node

* feat: add support for SpaceToDepth onnx node

* fix: ci

* fix: add missing SpaceToDepth rank_inference

* fix: mark supported onnx nodes

* test: fix tests

* fix: set opset version to 16
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