Skip to content

[Bug] [Unity] TVMError when loading ONNX model with CumSum operator #15728

@Thrsu

Description

@Thrsu

When attempting to load an ONNX model that contains the CumSum operator using TVM's relax mode, an error is encountered. The error message suggests that there is an issue with converting the input argument for the cumsum operation, specifically related to the axis value. The error message is as follows:

TVMError: In function relax.op.cumsum(0: RelayExpr, 1: IntImm, 2: DataType) -> RelayExpr: error while converting argument 1: [05:41:36] /workplace/software/tvm/tvm/include/tvm/runtime/packed_func.h:1866: InternalError: Check failed: (!checked_type.defined()) is false: Expected IntImm, but got relax.expr.Var

This issue seems to be similar to #14652

Actual behavior

File "verify_bug.py", line 319, in compile_onnx
    tvm_model = from_onnx(model, opset=18, keep_params_in_input=True)
  File "/workplace/software/tvm/tvm/python/tvm/relax/frontend/onnx/onnx_frontend.py", line 2287, in from_onnx
    return g.from_onnx(graph, opset)
  File "/workplace/software/tvm/tvm/python/tvm/relax/frontend/onnx/onnx_frontend.py", line 1932, in from_onnx
    self._construct_nodes(graph)
  File "/workplace/software/tvm/tvm/python/tvm/relax/frontend/onnx/onnx_frontend.py", line 2095, in _construct_nodes
    op = self._convert_operator(op_name, inputs, attr, self.opset)
  File "/workplace/software/tvm/tvm/python/tvm/relax/frontend/onnx/onnx_frontend.py", line 2191, in _convert_operator
    sym = op_function(self.bb, inputs, attrs, [self._nodes, self._params])
  File "/workplace/software/tvm/tvm/python/tvm/relax/frontend/onnx/onnx_frontend.py", line 710, in _impl_v14
    data = relax.op.cumsum(data, axis)
  File "/workplace/software/tvm/tvm/python/tvm/relax/op/statistical.py", line 241, in cumsum
    return _ffi_api.cumsum(data, axis, dtype)  # type: ignore
  File "/workplace/software/tvm/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 238, in __call__
    raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
  4: TVMFuncCall
  3: _ZN3tvm7runtime13Pac
  2: tvm::runtime::TypedPackedFunc<tvm::RelayExpr (tvm::RelayExpr, tvm::runtime::Optional<tvm::Integer>, tvm::runtime::DataType)>::AssignTypedLambda<tvm::RelayExpr (*)(tvm::RelayExpr, tvm::runtime::Optional<tvm::Integer>, tvm::runtime::DataType)>(tvm::RelayExpr (*)(tvm::RelayExpr, tvm::runtime::Optional<tvm::Integer>, tvm::runtime::DataType), std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}::operator()(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*) const
  1: tvm::runtime::TVMMovableArgValueWithContext_::operator tvm::runtime::Optional<tvm::Integer><tvm::runtime::Optional<tvm::Integer> >() const
  0: _ZN3tvm7runtime6detail
  7: TVMFuncCall
  6: _ZN3tvm7runtime13Pac
  5: tvm::runtime::TypedPackedFunc<tvm::RelayExpr (tvm::RelayExpr, tvm::runtime::Optional<tvm::Integer>, tvm::runtime::DataType)>::AssignTypedLambda<tvm::RelayExpr (*)(tvm::RelayExpr, tvm::runtime::Optional<tvm::Integer>, tvm::runtime::DataType)>(tvm::RelayExpr (*)(tvm::RelayExpr, tvm::runtime::Optional<tvm::Integer>, tvm::runtime::DataType), std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}::operator()(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*) const
  4: tvm::runtime::TVMMovableArgValueWithContext_::operator tvm::runtime::Optional<tvm::Integer><tvm::runtime::Optional<tvm::Integer> >() const
  3: tvm::runtime::TVMMovableArgValue_::operator tvm::runtime::Optional<tvm::Integer><tvm::runtime::Optional<tvm::Integer>, void>() const
  2: tvm::runtime::PackedFuncValueConverter<tvm::Integer>::From(tvm::runtime::TVMPODValue_ const&)
  1: tvm::Integer tvm::runtime::TVMPODValue_::AsObjectRef<tvm::Integer>() const
  0: _ZN3tvm7runtime6detail
  File "/workplace/software/tvm/tvm/include/tvm/runtime/packed_func.h", line 777
TVMError: In function relax.op.cumsum(0: RelayExpr, 1: IntImm, 2: DataType) -> RelayExpr: error while converting argument 1: [05:57:51] /workplace/software/tvm/tvm/include/tvm/runtime/packed_func.h:1866: InternalError: Check failed: (!checked_type.defined()) is false: Expected IntImm, but got relax.expr.Var

Environment

  • branch: unity
  • tvm: v0.14.dev0-595-gfa0d35b
  • onnx: 1.14.0

Steps to reproduce

  1. Download the ONNX model
  2. Run the below script
import onnx
import tvm
from tvm import relax
from tvm.relax.frontend.onnx import from_onnx

onnx_model_path = "Cumsum.onnx"
model = onnx.load(onnx_model_path)
tvm_model = from_onnx(model, opset=18, keep_params_in_input=True)

Triage

  • needs-triage

cc @quic-sanirudh

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triagePRs or issues that need to be investigated by maintainers to find the right assignees to address ittype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions