Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
erdayang opened this issue Feb 24, 2025 · 2 comments
Closed
Labels
needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug

Comments

@erdayang
Copy link

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])
@erdayang erdayang added needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug labels Feb 24, 2025
@Hzfengsy
Copy link
Member

Would you please provide your onnx model or a subgraph that triggers the error?

@Hzfengsy
Copy link
Member

Hzfengsy commented Mar 7, 2025

Closing it as no update for a long time. Feel free to reopen it if needed

@Hzfengsy Hzfengsy closed this as completed Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug
Projects
None yet
Development

No branches or pull requests

2 participants