burn icon indicating copy to clipboard operation
burn copied to clipboard

ONNX burn-import: Can't transform Shape(4) to tensor

Open ungerpeter opened this issue 8 months ago • 4 comments

I tried to transform an onnx model to burn code using burn-import crate, but the build script fails with the following error:

ERROR burn_import::logger: PANIC => panicked at /Users/axpun/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/burn-import-0.16.0/src/onnx/to_burn.rs:1334:18: Can't transform Shape(4) to tensor.

This is the onnx model I tried to import: https://huggingface.co/Soykaf/RTMW3D-x/tree/main/onnx

According to the supported onnx operations table, shape should be supported: https://github.com/tracel-ai/burn/blob/main/crates/burn-import/SUPPORTED-ONNX-OPS.md

To Reproduce

  1. Download onnx model from HF via link above
  2. Follow the burn guide for onnx model import (https://burn.dev/burn-book/import/onnx-model.html)
  3. run cargo build

ungerpeter avatar Mar 20 '25 12:03 ungerpeter

Good news : I just put in a PR to fix this issue specifically. Shape should not successfully be processed.

Bad news : The model you are referencing has a few unsupported Onnx Ops : Unsupported ops: [Abs, DepthToSpace, Abs, Abs, Split, Split]

Knight-Ops avatar Mar 21 '25 01:03 Knight-Ops

Good news : I just put in a PR to fix this issue specifically. Shape should not successfully be processed.

Bad news : The model you are referencing has a few unsupported Onnx Ops : Unsupported ops: [Abs, DepthToSpace, Abs, Abs, Split, Split]

Thank you!

ungerpeter avatar Mar 21 '25 06:03 ungerpeter

I have the same issue with a different model, and looks like that PR was closed. I think this issue should be opened again? I'm trying this model: https://huggingface.co/TheEeeeLin/HivisionIDPhotos_matting/blob/main/retinaface-resnet50.onnx

AdrianEddy avatar Apr 24 '25 00:04 AdrianEddy

Reopening it per AdrianEddy request.

antimora avatar Apr 24 '25 04:04 antimora

Reproduction

For reference, using the current git version of Burn (has some improvements since the latest release tag v0.17.1).

Reproduction uses this compose.yaml.

rtmw3d-x_8xb64_cocktail14-384x288-b0a0eab7_20240626.onnx

ONNX_MODEL_URL='https://huggingface.co/Soykaf/RTMW3D-x/resolve/main/onnx/rtmw3d-x_8xb64_cocktail14-384x288-b0a0eab7_20240626.onnx' \
docker compose run --rm -it burn-onnx-import cargo build
  DEBUG onnx_ir::rank_inference: Inferring rank for node: reducesum1
  DEBUG onnx_ir::node::reduce_sum: ReduceSum rank inference for node reducesum1
  ERROR burn_import::logger: PANIC => panicked at /root/.cargo/git/checkouts/burn-6c277d792b0d5d7a/1f5ccd4/crates/onnx-ir/src/node/reduce_sum.rs:64:14:
  Only tensor input is valid

retinaface-resnet50.onnx

ONNX_MODEL_URL='https://huggingface.co/TheEeeeLin/HivisionIDPhotos_matting/resolve/main/retinaface-resnet50.onnx' \
docker compose run --rm -it burn-onnx-import cargo build
   INFO onnx_ir::from_onnx: Parsing ONNX file: src/model/example.onnx
  ERROR burn_import::logger: PANIC => panicked at /root/.cargo/git/checkouts/burn-6c277d792b0d5d7a/1f5ccd4/crates/onnx-ir/src/from_onnx.rs:381:5:
  Nodes are not topologically sorted

polarathene avatar Jun 07 '25 11:06 polarathene

RTMW3D-x is buildable with https://github.com/tracel-ai/burn/pull/3564 (still under review)

antimora avatar Aug 17 '25 13:08 antimora