Open pdhirajkumarprasad opened 2 weeks ago
iree-compile --iree-hal-target-backends=llvm-cpu model.mlir -o model.vmfb --dump-compilation-phases-to=./tmp/
In the phases output, the hal is generated. The error happens when lower hal to vm phase
module {
^
<unknown>:0: error: failed to legalize unresolved materialization from ('i64') to ('index') that remained live after conversion
<unknown>:0: note: see current operation: %18 = "builtin.unrealized_conversion_cast"(%17) : (i64) -> index
model.mlir:865:12: note: see existing live user here: %x, %y, %z = flow.dispatch.workgroup_count_from_dag_root %19, %0, %1
%867 = torch.operator "onnx.Add"(%866, %813) : (!torch.vtensor<[?,256,768],f32>, !torch.vtensor<[1,256,768],f32>) -> !torch.vtensor<[?,256,768],f32>
^
model.mlir:1:1: error: conversion to vm.module failed
The VM will be created successfully if delete the code after
%866 = torch.operator "onnx.Add"(%838, %865) : (!torch.vtensor<[?,256,768],f32>, !torch.vtensor<[?,256,768],f32>) -> !torch.vtensor<[?,256,768],f32>
get smallest reproducer
iree-compile --iree-hal-target-backends=llvm-cpu model.mlir -o model.vmfb --dump-compilation-phases-to=./tmp/
module {
func.func @tf2onnx(%arg0: !torch.vtensor<[?,768],f32>, %arg1: !torch.vtensor<[3],si64>, %arg2: !torch.vtensor<[?,256,768],f32>) -> ( !torch.vtensor<[?,256,768],f32>) attributes {torch.onnx_meta.ir_version = 7 : si64, torch.onnx_meta.opset_version = 21 : si64, torch.onnx_meta.producer_name = "tf2onnx", torch.onnx_meta.producer_version = "1.5.2"} {
%reshape = torch.operator "onnx.Reshape"(%arg0, %arg1) : (!torch.vtensor<[?,768],f32>, !torch.vtensor<[3],si64>) -> !torch.vtensor<[?,256,768],f32>
%866 = torch.operator "onnx.Add"(%reshape, %arg2) : (!torch.vtensor<[?,256,768],f32>, !torch.vtensor<[?,256,768],f32>) -> !torch.vtensor<[?,256,768],f32>
return %866 : !torch.vtensor<[?,256,768],f32>
}
}
For the attached IR, seeing crash as
1> If we run 10 times, 2/3 times, it works fine while rest of time, it's giving above stack 2> in IR, we have few line commented, which is not needed, If I delete those then it works fine for most of time
command: iree-compile --iree-hal-target-backends=llvm-cpu model.torch_onnx.mlir -o abc.vmfb tt.mlir.txt