TVM should compile the model correctly.
Traceback (most recent call last):
File "/home/ubuntu/Documents/DLCompiler-test/tvm/1126/bugs/onnx_output4/test1.py", line 52, in <module>
test(onnx_model)
File "/home/ubuntu/Documents/DLCompiler-test/tvm/1126/bugs/onnx_output4/test1.py", line 45, in test
tvm_model = relax.transform.LegalizeOps()(tvm_model)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/Documents/DLCompilers/tvm/python/tvm/ir/transform.py", line 167, in __call__
return _ffi_transform_api.RunPass(self, mod)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "python/tvm_ffi/cython/function.pxi", line 904, in tvm_ffi.core.Function.__call__
File "<unknown>", line 0, in tvm::transform::Pass::operator()(tvm::IRModule) const
File "<unknown>", line 0, in tvm::transform::Pass::operator()(tvm::IRModule, tvm::transform::PassContext const&) const
File "<unknown>", line 0, in tvm::transform::ModulePassNode::operator()(tvm::IRModule, tvm::transform::PassContext const&) const
File "<unknown>", line 0, in std::_Function_handler<tvm::IRModule (tvm::IRModule, tvm::transform::PassContext), tvm::relax::transform::LegalizeOps(tvm::ffi::Optional<tvm::ffi::Map<tvm::ffi::String, tvm::ffi::Function, void>, void>, tvm::ffi::Optional<tvm::ffi::Array<tvm::ffi::String, void>, void>, bool)::{lambda(tvm::IRModule, tvm::transform::PassContext)#1}>::_M_invoke(std::_Any_data const&, tvm::IRModule&&, tvm::transform::PassContext&&)
File "<unknown>", line 0, in tvm::relax::transform::LegalizeOps(tvm::ffi::Optional<tvm::ffi::Map<tvm::ffi::String, tvm::ffi::Function, void>, void>, tvm::ffi::Optional<tvm::ffi::Array<tvm::ffi::String, void>, void>, bool)::{lambda(tvm::IRModule, tvm::transform::PassContext)#1}::operator()(tvm::IRModule, tvm::transform::PassContext) const
File "<unknown>", line 0, in tvm::relax::LegalizeMutator::Transform()
File "<unknown>", line 0, in tvm::relax::ExprMutator::VisitExpr(tvm::RelaxExpr const&)
File "<unknown>", line 0, in tvm::relax::ExprFunctor<tvm::RelaxExpr (tvm::RelaxExpr const&)>::VisitExpr(tvm::RelaxExpr const&)
File "<unknown>", line 0, in tvm::relax::ExprFunctor<tvm::RelaxExpr (tvm::RelaxExpr const&)>::InitVTable()::{lambda(tvm::ffi::ObjectRef const&, tvm::relax::ExprFunctor<tvm::RelaxExpr (tvm::RelaxExpr const&)>*)#8}::_FUN(tvm::ffi::ObjectRef const&, tvm::relax::ExprFunctor<tvm::RelaxExpr (tvm::RelaxExpr const&)>*)
File "<unknown>", line 0, in tvm::relax::ExprMutator::VisitExpr_(tvm::relax::FunctionNode const*)
File "<unknown>", line 0, in tvm::relax::ExprMutator::VisitWithNewScope(tvm::RelaxExpr const&, tvm::ffi::Optional<tvm::ffi::Array<tvm::relax::Var, void>, void>)
File "<unknown>", line 0, in tvm::relax::ExprMutator::VisitExpr(tvm::RelaxExpr const&)
File "<unknown>", line 0, in tvm::relax::ExprFunctor<tvm::RelaxExpr (tvm::RelaxExpr const&)>::VisitExpr(tvm::RelaxExpr const&)
File "<unknown>", line 0, in tvm::relax::ExprFunctor<tvm::RelaxExpr (tvm::RelaxExpr const&)>::InitVTable()::{lambda(tvm::ffi::ObjectRef const&, tvm::relax::ExprFunctor<tvm::RelaxExpr (tvm::RelaxExpr const&)>*)#10}::_FUN(tvm::ffi::ObjectRef const&, tvm::relax::ExprFunctor<tvm::RelaxExpr (tvm::RelaxExpr const&)>*)
File "<unknown>", line 0, in tvm::relax::ExprMutator::VisitExpr_(tvm::relax::SeqExprNode const*)
File "<unknown>", line 0, in tvm::relax::ExprMutator::VisitBindingBlock(tvm::relax::BindingBlock const&)
File "<unknown>", line 0, in tvm::relax::ExprMutator::VisitBindingBlock_(tvm::relax::DataflowBlockNode const*)
File "<unknown>", line 0, in tvm::relax::ExprMutator::VisitBinding(tvm::relax::Binding const&)
File "<unknown>", line 0, in tvm::relax::ExprMutator::VisitBinding_(tvm::relax::VarBindingNode const*)
File "<unknown>", line 0, in tvm::relax::ExprMutator::VisitBinding_(tvm::relax::VarBindingNode const*, tvm::relax::IfNode const*)
File "<unknown>", line 0, in tvm::relax::ExprMutator::VisitExpr(tvm::RelaxExpr const&)
File "<unknown>", line 0, in tvm::relax::ExprFunctor<tvm::RelaxExpr (tvm::RelaxExpr const&)>::VisitExpr(tvm::RelaxExpr const&)
File "<unknown>", line 0, in tvm::relax::ExprFunctor<tvm::RelaxExpr (tvm::RelaxExpr const&)>::InitVTable()::{lambda(tvm::ffi::ObjectRef const&, tvm::relax::ExprFunctor<tvm::RelaxExpr (tvm::RelaxExpr const&)>*)#9}::_FUN(tvm::ffi::ObjectRef const&, tvm::relax::ExprFunctor<tvm::RelaxExpr (tvm::RelaxExpr const&)>*)
File "<unknown>", line 0, in tvm::relax::LegalizeMutator::VisitExpr_(tvm::relax::CallNode const*)
File "python/tvm_ffi/cython/function.pxi", line 1058, in tvm_ffi.core.tvm_ffi_callback
File "/home/ubuntu/Documents/DLCompilers/tvm/python/tvm/relax/transform/legalize_ops/nn.py", line 493, in _nn_prelu
return bb.call_te(topi.nn.prelu, call.args[0], call.args[1], call.attrs.axis)
File "/home/ubuntu/Documents/DLCompilers/tvm/python/tvm/relax/block_builder.py", line 361, in call_te
tir_func, call_args, output_sinfo, tir_vars = gen_call_tir_inputs(func, *args, **kwargs)
File "/home/ubuntu/Documents/DLCompilers/tvm/python/tvm/relax/utils.py", line 355, in gen_call_tir_inputs
te_out = func(*te_args, **te_kwargs)
File "/home/ubuntu/Documents/DLCompilers/tvm/python/tvm/te/tag.py", line 57, in tagged_fdecl
return fdecl(*args, **kwargs)
File "/home/ubuntu/Documents/DLCompilers/tvm/python/tvm/topi/nn/elemwise.py", line 130, in prelu
assert len(slope.shape) == 1
AssertionError
This bug can be reproduced by the following code with the model in the attachment. As shown in the code, the model can be executed by onnxruntime.
Expected behavior
TVM should compile the model correctly.
Actual behavior
For the following model,
TVM crashes:
I am not sure that this is a bug for TVM. This issue is same as the question that has been fixed.
Environment
OS: Ubuntu 20.04
TVM: 0.23.dev0 (f4e28d3)
onnxruntime: 1.23.2
Steps to reproduce
This bug can be reproduced by the following code with the model in the attachment. As shown in the code, the model can be executed by onnxruntime.
testcase.zip
Triage
Please refer to the list of label tags here to find the relevant tags and add them below in a bullet format (example below).