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

pad-input-fix: adding support for pads as attributes #2195

Merged
merged 4 commits into from
Aug 23, 2024
Merged

Conversation

mepatrick73
Copy link
Contributor

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

#2151

Changes

Added support to pad being passed as an attribute. Also adding a check for the mode

Testing

Ran user model mentionned in #2151

@mepatrick73 mepatrick73 self-assigned this Aug 22, 2024
Copy link

codecov bot commented Aug 22, 2024

Codecov Report

Attention: Patch coverage is 84.21053% with 9 lines in your changes missing coverage. Please review.

Project coverage is 86.08%. Comparing base (4999421) to head (848b7e1).
Report is 3 commits behind head on main.

Files Patch % Lines
crates/burn-import/src/onnx/op_configuration.rs 84.21% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2195      +/-   ##
==========================================
- Coverage   86.08%   86.08%   -0.01%     
==========================================
  Files         695      695              
  Lines       88995    89036      +41     
==========================================
+ Hits        76612    76644      +32     
- Misses      12383    12392       +9     

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

@mepatrick73 mepatrick73 mentioned this pull request Aug 22, 2024
2 tasks
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.

Some small changes required to correctly support opset 2 of the Pad operator.

Should be good to go after this 👍

if node.inputs.len() < 2 {
panic!("Pad: must provide at least two inputs")
if node.inputs.is_empty() {
panic!("Pad: must be provide data as input")
Copy link
Member

Choose a reason for hiding this comment

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

Weird formulation. Makes more sense when you remove the "be": "Pad: must provide data as input"

@@ -768,9 +768,20 @@ pub fn tile_config(node: &Node) -> TileConfig {

/// Create a PadConfig from the attributes of the node
pub fn pad_config(node: &Node) -> PadConfig {
fn get_input_values(node: &Node, index: usize) -> Vec<i64> {
Copy link
Member

Choose a reason for hiding this comment

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

Since this is only used to retrieve the pads input values, I would rename to get_pads_input (and the index can be hardcoded).

Comment on lines +803 to +814
"pads" => {
pads = value
.clone()
.into_i64s()
.iter()
.map(|&x| {
if x < 0 {
panic!("Pad: Negative pad is not supported");
}
x as usize
})
.collect()
Copy link
Member

Choose a reason for hiding this comment

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

If we are supporting the pads as attribute, which corresponds to version 2 of the operator, then we should also parse the value attribute to make sure we are correctly capturing all parameters of the node.

Make sure it doesn't come in conflict with the constant_value input parsing for later versions of the operator 🙂

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.

Whoops, last comment didn't catch your latest commit for the clippy fix.

LGTM with the changes, thanks!

@mepatrick73 mepatrick73 merged commit 2c12d58 into main Aug 23, 2024
15 checks passed
@mepatrick73 mepatrick73 deleted the pad-input-fix branch August 23, 2024 16:46
@SimonBrandner
Copy link

@mepatrick73, was this supposed to fix #2151? I am still seeing the same issue...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants