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

ONNX import generates integer for Interpolate2DConfig when it should be f32 #2702

Closed
torsteingrindvik opened this issue Jan 15, 2025 · 1 comment · Fixed by #2708
Closed
Assignees
Labels
bug Something isn't working onnx

Comments

@torsteingrindvik
Copy link

torsteingrindvik commented Jan 15, 2025

Describe the bug

The generated code for this onnx model: https://github.com/opencv/opencv_zoo/blob/main/models/face_detection_yunet/face_detection_yunet_2023mar.onnx

contains this code:

        let resize2 = Interpolate2dConfig::new()
            .with_output_size(None)
            .with_scale_factor(Some([2, 2]))
            .with_mode(InterpolateMode::Nearest)
            .init();

This doesn't compile since scale factor should be f32.

@laggui states:

Ahhh the conversion to a token stream uses f32.to_string(), but if the value doesn't have a decimal point the compiler complains that it's not f32.

https://github.com/tracel-ai/burn/blob/main/crates/burn-import/src/burn/codegen.rs#L9

Expected behavior

The code should compile.

Desktop (please complete the following information):

  • OS: Arch
  • Version: Burn 93cafc4 0.17.0

Additional context

Discord chat context: https://discordapp.com/channels/1038839012602941528/1059209073784008835/1329098432580816936

@laggui laggui added bug Something isn't working onnx labels Jan 15, 2025
@antimora antimora self-assigned this Jan 16, 2025
antimora added a commit to antimora/burn that referenced this issue Jan 16, 2025
@antimora
Copy link
Collaborator

#2708 should fix it. Currently in the review status. With this fix, you should be able to compile the code.

I checked code generation and it appears the values are rendered correctly. I encourage you to check again with the build. I only converted the onnx file to rs code:

        let conv2d25 = Conv2dConfig::new([64, 64], [3, 3])
            .with_stride([1, 1])
            .with_padding(PaddingConfig2d::Explicit(1, 1))
            .with_dilation([1, 1])
            .with_groups(64)
            .with_bias(true)
            .init(device);
        let resize1 = Interpolate2dConfig::new()
            .with_output_size(None)
            .with_scale_factor(Some([2.0, 2.0]))
            .with_mode(InterpolateMode::Nearest)
            .init();
        let conv2d26 = Conv2dConfig::new([64, 64], [1, 1])
            .with_stride([1, 1])
            .with_padding(PaddingConfig2d::Valid)
            .with_dilation([1, 1])
            .with_groups(1)
            .with_bias(true)
            .init(device);
        let conv2d27 = Conv2dConfig::new([64, 64], [3, 3])
            .with_stride([1, 1])
            .with_padding(PaddingConfig2d::Explicit(1, 1))
            .with_dilation([1, 1])
            .with_groups(64)
            .with_bias(true)
            .init(device);
        let resize2 = Interpolate2dConfig::new()
            .with_output_size(None)
            .with_scale_factor(Some([2.0, 2.0]))
            .with_mode(InterpolateMode::Nearest)
            .init();
        let conv2d28 = Conv2dConfig::new([64, 64], [1, 1])
            .with_stride([1, 1])
            .with_padding(PaddingConfig2d::Valid)
            .with_dilation([1, 1])
            .with_groups(1)
            .with_bias(true)
            .init(device);

@antimora antimora pinned this issue Jan 16, 2025
@antimora antimora unpinned this issue Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working onnx
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants