Skip to content

[Bug] Error converting operator Cast, with inputs: [R.shape([x_0, x_1])] #17671

Closed
@erdayang

Description

@erdayang

My model is onnx, I used to work with v0.15, it work successfully. But when I work with 0.20.dev0, I found the exception of cast operation.

Expected behavior

I expect to work successfully with main branch, because main branch have fixed an Attention’s attr.

Actual behavior

Image

this is my graph, two cast operation , then first one have no problem , the second one does not work.

Environment

centos7.0
gcc7.3.1
tvm tag v0.20.dev0
tvm work with cpu, turn on the cmake option of "USE_LLVM"

script

from tvm.relax.frontend.onnx import from_onnx

mod,params = from_onnx(onnx_model)

mod.show()

error info

/home/admin/tvm_home/main/python/tvm/relax/frontend/onnx/onnx_frontend.py:3392: UserWarning: Renaming name 524289_a to input_524289_a
  warnings.warn(("Renaming name %s to %s" % (name, new_name)))
Error converting operator Cast, with inputs: [R.shape([x_0, x_1])]
Traceback (most recent call last):
  File "test.py", line 43, in <module>
    mod,params = from_onnx(onnx_model, shape_dict, type_dict, 16)
  File "/home/admin/tvm_home/main/python/tvm/relax/frontend/onnx/onnx_frontend.py", line 3690, in from_onnx
    return g.from_onnx(graph, opset)
  File "/home/admin/tvm_home/main/python/tvm/relax/frontend/onnx/onnx_frontend.py", line 3321, in from_onnx
    self._construct_nodes(graph)
  File "/home/admin/tvm_home/main/python/tvm/relax/frontend/onnx/onnx_frontend.py", line 3501, in _construct_nodes
    raise err
  File "/home/admin/tvm_home/main/python/tvm/relax/frontend/onnx/onnx_frontend.py", line 3498, in _construct_nodes
    op = self.bb.normalize(op)
  File "/home/admin/tvm_home/main/python/tvm/relax/block_builder.py", line 667, in normalize
    return _ffi_api.BlockBuilderNormalize(self, expr)  # type: ignore
  File "tvm/_ffi/_cython/./packed_func.pxi", line 339, in tvm._ffi._cy3.core.PackedFuncBase.__call__
  File "tvm/_ffi/_cython/./packed_func.pxi", line 270, in tvm._ffi._cy3.core.FuncCall
  File "tvm/_ffi/_cython/./packed_func.pxi", line 259, in tvm._ffi._cy3.core.FuncCall3
  File "tvm/_ffi/_cython/./base.pxi", line 185, in tvm._ffi._cy3.core.CHECK_CALL
  File "/home/admin/tvm_home/main/python/tvm/_ffi/base.py", line 465, in raise_last_ffi_error
    raise py_err
tvm._ffi.base.TVMError: Traceback (most recent call last):
  10: _ZN3tvm7runtime13PackedFuncObj9ExtractorINS0_16PackedFuncSubObjIZNS0_15TypedPackedFuncIFNS_9RelaxExprENS_5relax12BlockBuilderERKS5_EE17AssignTypedLambdaIZNS0_8Registry15set_body_methodIS7_NS6_16BlockBuilderNodeES5_JS9_EvEERSD_MT0_FT1_DpT2_EEUlS7_S9_E_EEvT_SsEUlRKNS0_7TVMArgsEPNS0_11TVMRetValueEE_EEE4CallEPKS1_SP_ST_
  9: tvm::relax::Normalizer::Normalize(tvm::RelaxExpr const&)
  8: tvm::relax::Normalizer::VisitExpr(tvm::RelaxExpr const&)
  7: _ZZN3tvm5relax11ExprFunc
  6: tvm::relax::Normalizer::VisitExpr_(tvm::relax::CallNode const*)
  5: tvm::relax::Normalizer::InferStructInfo(tvm::relax::Call const&)
  4: tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<void tvm::runtime::TypedPackedFunc<tvm::relax::StructInfo (tvm::relax::Call const&, tvm::relax::BlockBuilder const&)>::AssignTypedLambda<tvm::relax::StructInfo (*)(tvm::relax::Call const&, tvm::relax::BlockBuilder const&)>(tvm::relax::StructInfo (*)(tvm::relax::Call const&, tvm::relax::BlockBuilder const&))::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}> >::Call(tvm::runtime::PackedFuncObj const*, tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)
  3: tvm::relax::InferStructInfoAstype(tvm::relax::Call const&, tvm::relax::BlockBuilder const&)
  2: tvm::relax::GetInputTensorStructInfo(tvm::relax::Call const&, tvm::relax::BlockBuilder const&)
  1: tvm::relax::GetInputTensorStructInfo(tvm::relax::Call const&, unsigned long, tvm::relax::BlockBuilder const&)
  0: tvm::relax::BlockBuilderImpl::ReportFatal(tvm::Diagnostic const&)
  File "/home/admin/tvm_home/main/src/relax/ir/block_builder.cc", line 157
TVMError: Operator Op(relax.astype) requires argument 0 (x) to be a tensor.  However, the argument R.shape([x_0, x_1]) is instead of type R.Shape([x_0, x_1])

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