Skip to content
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

Optimize connected components #2810

Merged
merged 19 commits into from
Feb 17, 2025
Merged

Conversation

wingertge
Copy link
Contributor

@wingertge wingertge commented Feb 13, 2025

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.

Changes

Uses NdArray's inner Vec where possible in into_data.
Changes bool_into_data to not force the data to bool, and instead use Backend::BoolElem. Manually converting to bool no longer makes sense when we have an explicit type for boolean elements.
Uses raw pointers for generated code, since bounds checks are proven by nature of the generation algorithm and it's a free speedup.
Removes batch support for connected components since it didn't really make sense, especially for the with_stats version. This matches opencv.

Testing

Passes all tests

Copy link

codecov bot commented Feb 14, 2025

Codecov Report

Attention: Patch coverage is 56.21939% with 447 lines in your changes missing coverage. Please review.

Project coverage is 81.73%. Comparing base (2c4c039) to head (5052bc6).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...nents/spaghetti/Spaghetti_last_line_forest_code.rs 5.98% 267 Missing ⚠️
.../cube/connected_components/hardware_accelerated.rs 0.00% 47 Missing ⚠️
...ents/spaghetti/Spaghetti_first_line_forest_code.rs 30.30% 46 Missing ⚠️
...backends/cpu/connected_components/spaghetti/mod.rs 76.85% 25 Missing ⚠️
...nts/spaghetti/Spaghetti_single_line_forest_code.rs 0.00% 24 Missing ⚠️
crates/burn-tensor/src/tensor/element/cast.rs 25.00% 18 Missing ⚠️
crates/burn-vision/src/ops/base.rs 0.00% 10 Missing ⚠️
...sion/src/backends/cube/connected_components/mod.rs 0.00% 4 Missing ⚠️
crates/burn-fusion/src/ops/boolean.rs 91.66% 3 Missing ⚠️
crates/burn-tensor/src/tests/ops/nan.rs 0.00% 2 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2810      +/-   ##
==========================================
+ Coverage   81.69%   81.73%   +0.03%     
==========================================
  Files         851      851              
  Lines      113982   114053      +71     
==========================================
+ Hits        93122    93218      +96     
+ Misses      20860    20835      -25     

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

@wingertge wingertge marked this pull request as ready for review February 14, 2025 15:59
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.

Thanks for making the changes for the bool elem! Pretty much in line with other element types now since it can be backend-specific.

@laggui laggui merged commit 163a206 into tracel-ai:main Feb 17, 2025
11 checks passed
@wingertge wingertge deleted the opt/connected-components branch February 17, 2025 20:25
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