burn
burn copied to clipboard
Sequential Macro
Checklist
- [x] Confirmed that
run-checks allscript has been executed. - [ ] Made sure the book is up to date with changes in this PR.
Changes
Burn currently lacks an analog to nn.Sequential in PyTorch, so I created a sequential macro to generate a similar structure. I used a macro since there is no unifying trait amongst all modules, specifically with regards to how they are initialized. I created a relatively lenient system that classes modules into different bins depending on how they're initialized, then generate a structure with that information. This structure can be initialized like normal (using SequentialConfig, a struct containing an enum that allows for individual customization of each step) then executed with Sequential::forward.
Testing
I have tested various combinations of modules with the macro and it performs as expected. I also added a unit test to ensure that the macro properly generates on each new build.
Codecov Report
Attention: Patch coverage is 40.32258% with 37 lines in your changes missing coverage. Please review.
Project coverage is 82.35%. Comparing base (
6f494e5) to head (0c019b2). Report is 415 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| crates/burn-core/src/nn/sequential.rs | 17.77% | 37 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #2565 +/- ##
==========================================
- Coverage 82.37% 82.35% -0.02%
==========================================
Files 825 828 +3
Lines 105643 105773 +130
==========================================
+ Hits 87026 87112 +86
- Misses 18617 18661 +44
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
That would be a good addition.
I saw @wingertge implementation (https://github.com/wingertge/craft-burn/blob/5f02609dadfe206aeb4c16db873446fd80101bd2/src/lib.rs). Maybe @wingertge can also give a feedback on this.
This is how it was used: https://github.com/wingertge/craft-burn/blob/5f02609dadfe206aeb4c16db873446fd80101bd2/src/refine.rs#L27
This PR has been marked as stale because it has not been updated for over a month
Closing this for now. The design needs to be flushed out.