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

Added tuple modules #1186

Merged
merged 2 commits into from
Jan 29, 2024
Merged

Added tuple modules #1186

merged 2 commits into from
Jan 29, 2024

Conversation

varonroy
Copy link
Contributor

Checklist

  • Confirmed that run-checks all script has been executed.
  • Made sure the book is up to date with changes in this PR.
    • This change is not significant enough to warrant an addition to the book.

Related Issues/PRs

Related to issue: #1046.

Changes

This PR provides an implementation for tuple modules which reduce the amount of code that needs to written in some cases. Tuple modules also allow another way to group modules besides structs.

#[derive(Module, Debug)]
pub struct MyModule<B: Backend> {
    linear: Linear<B>,
    block: (
        Linear<B>,
        ReLU,
        Linear<B>,
        ReLU,
    ),
}

Previously, creating a structure similar to the block field above would require creating a separate struct.

#[derive(Module, Debug)]
pub struct Block<B: Backend> {
    l1: Linear<B>,
    act1: ReLU,
    l2: Linear<B>,
    act2: ReLU,
}

Testing

ModuleComposed in burn-core/tests/derive-module.rs has been modified with an additional tuple field and all tests have passed.

Copy link

codecov bot commented Jan 28, 2024

Codecov Report

Attention: 22 lines in your changes are missing coverage. Please review.

Comparison is base (8686082) 84.45% compared to head (d7768b5) 84.44%.
Report is 1 commits behind head on main.

Files Patch % Lines
burn-core/src/module/param/primitive.rs 36.00% 16 Missing ⚠️
burn-core/src/record/primitive.rs 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1186      +/-   ##
==========================================
- Coverage   84.45%   84.44%   -0.02%     
==========================================
  Files         546      546              
  Lines       61507    61596      +89     
==========================================
+ Hits        51946    52014      +68     
- Misses       9561     9582      +21     

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

Copy link
Member

@nathanielsimard nathanielsimard left a comment

Choose a reason for hiding this comment

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

Only a single minor comment, thanks a lot for the contribution!

burn-core/src/module/param/primitive.rs Show resolved Hide resolved
@nathanielsimard nathanielsimard merged commit f5ac5d8 into tracel-ai:main Jan 29, 2024
13 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.

2 participants