iree-org / iree

A retargetable MLIR-based machine learning compiler and runtime toolkit.
http://iree.dev/
Apache License 2.0
2.61k stars 585 forks source link

IR failing for `iree-codegen-pad-dynamic-alloc` pass #10241

Closed vivekkhandelwal1 closed 2 years ago

vivekkhandelwal1 commented 2 years ago

What happened?

v_diffusion_ir.mlir:8493:13: error: 'memref.alloc' op unexpected allocation without upper bound shapes
    %2467 = linalg.generic {indexing_maps = [#map5, #map16], iterator_types = ["parallel", "parallel", "parallel", "reduction"]} ins(%2465 : tensor<2x16x16x16xf32>) outs(%2466 : tensor<2x16x16x1xf32>) {
            ^
v_diffusion_ir.mlir:26:3: note: called from
  func.func @forward(%arg0: tensor<1x3x256x256xf32>, %arg1: tensor<1xf32>) -> tensor<1x3x256x256xf32> {
  ^
v_diffusion_ir.mlir:8498:13: error: failed to run translation of source executable to target executable for backend #hal.executable.target<"cuda", "cuda-nvptx-fb", {target_arch = "sm_35"}>
    %2468 = linalg.generic {indexing_maps = [#map5, #map16, #map5], iterator_types = ["parallel", "parallel", "parallel", "parallel"]} ins(%2465, %2467 : tensor<2x16x16x16xf32>, tensor<2x16x16x1xf32>) outs(%2463 : tensor<2x16x16x16xf32>) {
            ^
v_diffusion_ir.mlir:26:3: note: called from
  func.func @forward(%arg0: tensor<1x3x256x256xf32>, %arg1: tensor<1xf32>) -> tensor<1x3x256x256xf32> {
  ^
v_diffusion_ir.mlir:8498:13: error: failed to serialize executables
    %2468 = linalg.generic {indexing_maps = [#map5, #map16, #map5], iterator_types = ["parallel", "parallel", "parallel", "parallel"]} ins(%2465, %2467 : tensor<2x16x16x16xf32>, tensor<2x16x16x1xf32>) outs(%2463 : tensor<2x16x16x16xf32>) {
            ^
v_diffusion_ir.mlir:26:3: note: called from
  func.func @forward(%arg0: tensor<1x3x256x256xf32>, %arg1: tensor<1xf32>) -> tensor<1x3x256x256xf32> {
  ^
compilation failed

Steps to reproduce your issue

Run:

./build/tools/iree-compile --iree-input-type=none --iree-vm-bytecode-module-output-format=flatbuffer-binary --iree-hal-target-backends=cuda --mlir-print-debuginfo --mlir-print-op-on-diagnostic=false --iree-llvm-target-cpu-features=host --iree-hal-cuda-disable-loop-nounroll-wa --iree-stream-resource-index-bits=64 --iree-vm-target-index-bits=6

for the following IR: https://gist.github.com/vivekkhandelwal1/28709ceb12f8392faed45913428f5740

What component(s) does this issue relate to?

MLIR, Compiler

Version information

No response

Additional context

The IR dump with the use of flag --mlir-print-ir-after-failure is https://gist.github.com/vivekkhandelwal1/1797ae5e99a879d897c091bd26982889. For the following op, the compilation fails: https://gist.github.com/vivekkhandelwal1/1797ae5e99a879d897c091bd26982889#file-diffusion_error-mlir-L27

vivekkhandelwal1 commented 2 years ago

@MaheshRavishankar PTAL

vivekkhandelwal1 commented 2 years ago

Thanks @ThomasRaoux, for fixing this.