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

Implement ONNX Pad Operator #2007

Merged
merged 4 commits into from
Jul 23, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/burn-import/src/onnx/op_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,8 @@ pub fn layer_norm_config(node: &Node) -> (LayerNormConfig, bool) {
/// Create a PadConfig from the attributes of the node
pub fn pad_config(node: &Node) -> PadConfig {
fn get_pads(node: &Node) -> Vec<usize> {
if node.inputs.len() != 3 {
panic!("Pad: must provide three inputs")
if node.inputs.len() < 2 {
panic!("Pad: must provide two inputs")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would add "at least".

"must provide two inputs" => "must provide at least two inputs"

}

let input_dim = match &node.inputs.first().unwrap().ty {
Expand Down Expand Up @@ -801,7 +801,7 @@ pub fn pad_config(node: &Node) -> PadConfig {
// TODO: support int, boolean
match &node.inputs[2].value {
Some(Data::Float32s(shape)) => shape.first().unwrap().to_owned(),
_ => panic!("Pad: should provide a constant value input to pad with, for example 0.0"),
_ => 0.0,
}
}

Expand Down
Loading