Failed to compile onnx.Resize with dynamic shapes
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 736
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 15
Description
Got the following error when lowering onnx.Resize with dynamic shapes.
> error: failed to legalize operation 'arith.sitofp' that was explicitly marked illegal
Reproducer:
```
func.func @repro(%arg0: !torch.vtensor<[?,1280,?,?],f32>, %arg1: !torch.vtensor<[4],f32>) -> !torch.vtensor<[?,1280,?,?],f32> attributes {torch.onnx_meta.ir_version = 9 : si64, torch.onnx_meta.opset_version = 19 : si64, torch.onnx_meta.producer_name = "backend-test", torch.onnx_meta.producer_version = ""} {
%none = torch.constant.none
%0 = torch.operator "onnx.Resize"(%arg0, %none, %arg1) {torch.onnx.coordinate_transformation_mode = "asymmetric", torch.onnx.mode = "nearest", torch.onnx.nearest_mode = "floor"} : (!torch.vtensor<[?,1280,?,?],f32>, !torch.none, !torch.vtensor<[4],f32>) -> !torch.vtensor<[?,1280,?,?],f32>
return %0 : !torch.vtensor<[?,1280,?,?],f32>
}
```
Commands:
```
torch-mlir-opt --torch-onnx-to-torch-backend-pipeline --convert-torch-to-linalg repro.mlir -o repro_linalg.mlir
iree-compile --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=host repro_linalg.mlir -o test.vmfb
```
It's failing at https://github.com/llvm/torch-mlir/blob/main/lib/Conversion/TorchToLinalg/Uncategorized.cpp#L3187 when trying to convert the dynamic input shape to float for multiplying with scales.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/Conversion/TorchToLinalg/Uncategorized.cpp at the reported line around 3187, then reproduce the failure with the provided torch-mlir-opt and iree-compile commands and MLIR input. Trace the onnx.Resize lowering where the dynamic input shape is converted to float for scale multiplication. Done means the reproducer no longer fails on the explicitly illegal arith.sitofp operation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100