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

Panic when parsing the ONNX Split operator #2822

Open
Luni-4 opened this issue Feb 17, 2025 · 1 comment
Open

Panic when parsing the ONNX Split operator #2822

Luni-4 opened this issue Feb 17, 2025 · 1 comment
Assignees
Labels
bug Something isn't working onnx

Comments

@Luni-4
Copy link
Collaborator

Luni-4 commented Feb 17, 2025

Describe the bug

Running the ONNX model from issue #675, an error parsing the Split operator occurs:

ERROR burn_import::logger: PANIC => panicked at crates/onnx-ir/src/dim_inference.rs:914:17:
Split: Input tensor shape is not defined
thread 'main' panicked at crates/onnx-ir/src/dim_inference.rs:914:17:
Split: Input tensor shape is not defined

To Reproduce

Run the procedure to read the yolov8n.onnx file described in burn-import crate leads to the following log:

Error log
 INFO burn_import::onnx::to_burn: Starting to convert ONNX to Burn
DEBUG burn_import::onnx::to_burn: Output directory: "./out"
 INFO burn_import::onnx::to_burn: Converting "../../../Downloads/yolov8n.onnx"
DEBUG burn_import::onnx::to_burn: Input file name: "yolov8n"
DEBUG burn_import::onnx::to_burn: Output file: "./out/yolov8n"
 INFO burn_import::onnx::to_burn: Generating model from "../../../Downloads/yolov8n.onnx"
DEBUG burn_import::onnx::to_burn: Development mode: true
DEBUG burn_import::onnx::to_burn: Output file: "./out/yolov8n"
 INFO onnx_ir::from_onnx: Parsing ONNX file: ../../../Downloads/yolov8n.onnx
DEBUG onnx_ir::from_onnx: Number of nodes: 259
DEBUG onnx_ir::from_onnx: Number of inputs: 1
DEBUG onnx_ir::from_onnx: Number of initializers: 127
DEBUG onnx_ir::from_onnx: Number of outputs: 1
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Conv"
DEBUG onnx_ir::from_onnx: renaming node "/model.0/conv/Conv"
DEBUG onnx_ir::from_onnx: checking node conv2d1 for constants
DEBUG onnx_ir::from_onnx: checking input Argument { name: "model.0.conv.weight", ty: Tensor(TensorType { elem_type: Float32, dim: 4, shape: Some([16, 3, 3, 3]) }), value: Some(Float32s([-2.0546875, -0.18859863, 1.90625, -6.5625, 0.5961914, 6.90625, -6.0117188, ...])), passed: false } for const
DEBUG onnx_ir::from_onnx: checking input Argument { name: "model.0.conv.bias", ty: Tensor(TensorType { elem_type: Float32, dim: 1, shape: Some([16]) }), value: Some(Float32s([1.3603516, 2.875, 1.5947266, 1.5214844, 6.7148438, 1.3818359, 4.3203125, ...])), passed: false } for const
DEBUG onnx_ir::from_onnx: adding node "conv2d1"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Sigmoid"
DEBUG onnx_ir::from_onnx: renaming node "/model.0/act/Sigmoid"
DEBUG onnx_ir::from_onnx: adding node "sigmoid1"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Mul"
DEBUG onnx_ir::from_onnx: renaming node "/model.0/act/Mul"
DEBUG onnx_ir::from_onnx: adding node "mul1"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Conv"
DEBUG onnx_ir::from_onnx: renaming node "/model.1/conv/Conv"
DEBUG onnx_ir::from_onnx: checking node conv2d2 for constants
DEBUG onnx_ir::from_onnx: checking input Argument { name: "model.1.conv.weight", ty: Tensor(TensorType { elem_type: Float32, dim: 4, shape: Some([32, 16, 3, 3]) }), value: Some(Float32s([-0.06317139, -0.25390625, -0.54833984, 0.066101074, 0.08123779, 0.72509766, 0.03213501, ...])), passed: false } for const
DEBUG onnx_ir::from_onnx: checking input Argument { name: "model.1.conv.bias", ty: Tensor(TensorType { elem_type: Float32, dim: 1, shape: Some([32]) }), value: Some(Float32s([0.83496094, 0.13500977, 4.2421875, 0.1315918, -0.58154297, 1.4902344, 2.6269531, ...])), passed: false } for const
DEBUG onnx_ir::from_onnx: adding node "conv2d2"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Sigmoid"
DEBUG onnx_ir::from_onnx: renaming node "/model.1/act/Sigmoid"
DEBUG onnx_ir::from_onnx: adding node "sigmoid2"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Mul"
DEBUG onnx_ir::from_onnx: renaming node "/model.1/act/Mul"
DEBUG onnx_ir::from_onnx: adding node "mul2"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Conv"
DEBUG onnx_ir::from_onnx: renaming node "/model.2/cv1/conv/Conv"
DEBUG onnx_ir::from_onnx: checking node conv2d3 for constants
DEBUG onnx_ir::from_onnx: checking input Argument { name: "model.2.cv1.conv.weight", ty: Tensor(TensorType { elem_type: Float32, dim: 4, shape: Some([32, 32, 1, 1]) }), value: Some(Float32s([0.020202637, 0.053497314, -0.023925781, -0.07409668, -0.045410156, 0.023269653, 0.069885254, ...])), passed: false } for const
DEBUG onnx_ir::from_onnx: checking input Argument { name: "model.2.cv1.conv.bias", ty: Tensor(TensorType { elem_type: Float32, dim: 1, shape: Some([32]) }), value: Some(Float32s([2.8769531, 1.6123047, 1.3994141, 2.9140625, 1.5839844, 3.7949219, -0.51464844, ...])), passed: false } for const
DEBUG onnx_ir::from_onnx: adding node "conv2d3"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Sigmoid"
DEBUG onnx_ir::from_onnx: renaming node "/model.2/cv1/act/Sigmoid"
DEBUG onnx_ir::from_onnx: adding node "sigmoid3"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Mul"
DEBUG onnx_ir::from_onnx: renaming node "/model.2/cv1/act/Mul"
DEBUG onnx_ir::from_onnx: adding node "mul3"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Split"
DEBUG onnx_ir::from_onnx: renaming node "/model.2/Split"
DEBUG onnx_ir::from_onnx: adding node "split1"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Conv"
DEBUG onnx_ir::from_onnx: renaming node "/model.2/m.0/cv1/conv/Conv"
DEBUG onnx_ir::from_onnx: checking node conv2d4 for constants
DEBUG onnx_ir::from_onnx: checking input Argument { name: "model.2.m.0.cv1.conv.weight", ty: Tensor(TensorType { elem_type: Float32, dim: 4, shape: Some([16, 16, 3, 3]) }), value: Some(Float32s([-0.0692749, 0.009162903, 0.041137695, -0.13903809, -0.25756836, -0.060638428, -0.08898926, ...])), passed: false } for const
DEBUG onnx_ir::from_onnx: checking input Argument { name: "model.2.m.0.cv1.conv.bias", ty: Tensor(TensorType { elem_type: Float32, dim: 1, shape: Some([16]) }), value: Some(Float32s([1.8271484, 3.9492188, 2.0332031, 3.1132813, 3.2929688, 2.8730469, -5.1289063, ...])), passed: false } for const
DEBUG onnx_ir::from_onnx: adding node "conv2d4"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Sigmoid"
DEBUG onnx_ir::from_onnx: renaming node "/model.2/m.0/cv1/act/Sigmoid"
DEBUG onnx_ir::from_onnx: adding node "sigmoid4"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Mul"
DEBUG onnx_ir::from_onnx: renaming node "/model.2/m.0/cv1/act/Mul"
DEBUG onnx_ir::from_onnx: adding node "mul4"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Conv"
DEBUG onnx_ir::from_onnx: renaming node "/model.2/m.0/cv2/conv/Conv"
DEBUG onnx_ir::from_onnx: checking node conv2d5 for constants
DEBUG onnx_ir::from_onnx: checking input Argument { name: "model.2.m.0.cv2.conv.weight", ty: Tensor(TensorType { elem_type: Float32, dim: 4, shape: Some([16, 16, 3, 3]) }), value: Some(Float32s([-0.010246277, -0.09918213, -0.04260254, 0.022415161, 0.26660156, 0.059295654, -0.026519775, ...])), passed: false } for const
DEBUG onnx_ir::from_onnx: checking input Argument { name: "model.2.m.0.cv2.conv.bias", ty: Tensor(TensorType { elem_type: Float32, dim: 1, shape: Some([16]) }), value: Some(Float32s([1.5976563, 1.5966797, 3.5332031, -1.4785156, 1.7324219, -1.6542969, 5.2734375, ...])), passed: false } for const
DEBUG onnx_ir::from_onnx: adding node "conv2d5"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Sigmoid"
DEBUG onnx_ir::from_onnx: renaming node "/model.2/m.0/cv2/act/Sigmoid"
DEBUG onnx_ir::from_onnx: adding node "sigmoid5"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Mul"
DEBUG onnx_ir::from_onnx: renaming node "/model.2/m.0/cv2/act/Mul"
DEBUG onnx_ir::from_onnx: adding node "mul5"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Add"
DEBUG onnx_ir::from_onnx: renaming node "/model.2/m.0/Add"
DEBUG onnx_ir::dim_inference: Input 0 has no known shape, cannot predict broadcast result shape
DEBUG onnx_ir::from_onnx: adding node "add1"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Concat"
DEBUG onnx_ir::from_onnx: renaming node "/model.2/Concat"
DEBUG onnx_ir::from_onnx: adding node "concat1"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Conv"
DEBUG onnx_ir::from_onnx: renaming node "/model.2/cv2/conv/Conv"
DEBUG onnx_ir::from_onnx: checking node conv2d6 for constants
DEBUG onnx_ir::from_onnx: checking input Argument { name: "model.2.cv2.conv.weight", ty: Tensor(TensorType { elem_type: Float32, dim: 4, shape: Some([32, 48, 1, 1]) }), value: Some(Float32s([-0.028778076, 0.0006098747, -0.08135986, -0.0025787354, 0.027069092, 0.016616821, 0.031677246, ...])), passed: false } for const
DEBUG onnx_ir::from_onnx: checking input Argument { name: "model.2.cv2.conv.bias", ty: Tensor(TensorType { elem_type: Float32, dim: 1, shape: Some([32]) }), value: Some(Float32s([1.0126953, 2.5234375, 3.3945313, 0.36401367, 3.5859375, 2.5644531, 3.1894531, ...])), passed: false } for const
DEBUG onnx_ir::from_onnx: adding node "conv2d6"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Sigmoid"
DEBUG onnx_ir::from_onnx: renaming node "/model.2/cv2/act/Sigmoid"
DEBUG onnx_ir::from_onnx: adding node "sigmoid6"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Mul"
DEBUG onnx_ir::from_onnx: renaming node "/model.2/cv2/act/Mul"
DEBUG onnx_ir::from_onnx: adding node "mul6"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Conv"
DEBUG onnx_ir::from_onnx: renaming node "/model.3/conv/Conv"
DEBUG onnx_ir::from_onnx: checking node conv2d7 for constants
DEBUG onnx_ir::from_onnx: checking input Argument { name: "model.3.conv.weight", ty: Tensor(TensorType { elem_type: Float32, dim: 4, shape: Some([64, 32, 3, 3]) }), value: Some(Float32s([0.008285522, 0.00031018257, -0.009002686, -0.023864746, -0.06591797, -0.04006958, -0.013717651, ...])), passed: false } for const
DEBUG onnx_ir::from_onnx: checking input Argument { name: "model.3.conv.bias", ty: Tensor(TensorType { elem_type: Float32, dim: 1, shape: Some([64]) }), value: Some(Float32s([0.7006836, 0.6904297, 3.4414063, 1.2470703, -0.92529297, 1.2861328, -0.15722656, ...])), passed: false } for const
DEBUG onnx_ir::from_onnx: adding node "conv2d7"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Sigmoid"
DEBUG onnx_ir::from_onnx: renaming node "/model.3/act/Sigmoid"
DEBUG onnx_ir::from_onnx: adding node "sigmoid7"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Mul"
DEBUG onnx_ir::from_onnx: renaming node "/model.3/act/Mul"
DEBUG onnx_ir::from_onnx: adding node "mul7"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Conv"
DEBUG onnx_ir::from_onnx: renaming node "/model.4/cv1/conv/Conv"
DEBUG onnx_ir::from_onnx: checking node conv2d8 for constants
DEBUG onnx_ir::from_onnx: checking input Argument { name: "model.4.cv1.conv.weight", ty: Tensor(TensorType { elem_type: Float32, dim: 4, shape: Some([64, 64, 1, 1]) }), value: Some(Float32s([-0.12878418, 0.31835938, 0.04083252, 0.01209259, -0.546875, -0.15966797, -0.20336914, ...])), passed: false } for const
DEBUG onnx_ir::from_onnx: checking input Argument { name: "model.4.cv1.conv.bias", ty: Tensor(TensorType { elem_type: Float32, dim: 1, shape: Some([64]) }), value: Some(Float32s([0.64941406, 1.1298828, 3.0371094, -0.3557129, 2.453125, -3.0019531, 0.03189087, ...])), passed: false } for const
DEBUG onnx_ir::from_onnx: adding node "conv2d8"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Sigmoid"
DEBUG onnx_ir::from_onnx: renaming node "/model.4/cv1/act/Sigmoid"
DEBUG onnx_ir::from_onnx: adding node "sigmoid8"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Mul"
DEBUG onnx_ir::from_onnx: renaming node "/model.4/cv1/act/Mul"
DEBUG onnx_ir::from_onnx: adding node "mul8"
DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Split"
DEBUG onnx_ir::from_onnx: renaming node "/model.4/Split"
ERROR burn_import::logger: PANIC => panicked at crates/onnx-ir/src/dim_inference.rs:914:17:
Split: Input tensor shape is not defined
thread 'main' panicked at crates/onnx-ir/src/dim_inference.rs:914:17:
Split: Input tensor shape is not defined

Expected behavior

The above procedure should terminate without any panic.

@Luni-4 Luni-4 added bug Something isn't working onnx labels Feb 17, 2025
@Luni-4 Luni-4 changed the title Panic in parsing the Split operator in ONNX operator Panic when parsing the ONNX Split operator Feb 17, 2025
@laggui
Copy link
Member

laggui commented Feb 17, 2025

The split implementation added in #2568 relies on the input shape

let input_dims = match &input_tensor.shape {
Some(shape) => shape.to_vec(),
None => panic!("Split: Input tensor shape is not defined"),
};

Now that I think about it, I don't think that's required to get the output rank. The input is split along a dimension but all the outputs will have the same rank, just different lengths. So we can remove probably remove these checks.

Might have a look at this if I get some time.

CC @agelas for visibility.

@antimora antimora self-assigned this Feb 26, 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

No branches or pull requests

3 participants