Civitasv opened a new issue, #15180:
URL: https://github.com/apache/tvm/issues/15180

   ### Expected behavior
   
   I'm translating onnx file to relax IR format using code snippets like below.
   
   ```py
   from tvm.relax.frontend.onnx import from_onnx
   
   onnx_file = "/path/to/sigmoid.onnx"
   model = onnx.load(onnx_file)
   
   ir_mod, params = from_onnx(model, keep_params_in_input=True)
   ```
   
   The `sigmoid.onnx` is generated using `onnx.save_model(model, 
"sigmoid.onnx")` using this 
https://github.com/apache/tvm/blob/0dba0e3ed297a5f80dcd02031bb8c2664a3b5c4b/tests/python/relax/test_frontend_onnx.py#L399
 and this 
https://github.com/apache/tvm/blob/0dba0e3ed297a5f80dcd02031bb8c2664a3b5c4b/tests/python/relax/test_frontend_onnx.py#L188.
   
   And this test works as expected. But after I save it to a file and load from 
this file using `onnx.load`, it does not work.
   
   ### Actual behavior
   
   It will show error:
   
   ```txt
   ---------------------------------------------------------------------------
   TVMError                                  Traceback (most recent call last)
   Cell In[83], line 123
       119 model = onnx.load(onnx_file)
   --> 123 ir_mod, params = from_onnx(model, keep_params_in_input=True)
   
   File 
[~/miniconda3/envs/tvm-venv/lib/python3.10/site-packages/tvm-0.13.dev667](https://vscode-remote+ssh-002dremote-002b10-002e224-002e105-002e236.vscode-resource.vscode-cdn.net/home/wyc/husen/sandbox/~/miniconda3/envs/tvm-venv/lib/python3.10/site-packages/tvm-0.13.dev667)+g730d380ff-py3.10-linux-x86_64.egg/tvm/ir/module.py:127,
 in IRModule.__getitem__(self, var)
       125 if isinstance(var, _expr.GlobalVar):
       126     return _ffi_api.Module_Lookup(self, var)
   --> 127 return _ffi_api.Module_LookupDef(self, var)
   
   File 
[~/miniconda3/envs/tvm-venv/lib/python3.10/site-packages/tvm-0.13.dev667](https://vscode-remote+ssh-002dremote-002b10-002e224-002e105-002e236.vscode-resource.vscode-cdn.net/home/wyc/husen/sandbox/~/miniconda3/envs/tvm-venv/lib/python3.10/site-packages/tvm-0.13.dev667)+g730d380ff-py3.10-linux-x86_64.egg/tvm/_ffi/_ctypes/packed_func.py:238,
 in PackedFuncBase.__call__(self, *args)
       226 ret_tcode = ctypes.c_int()
       227 if (
       228     _LIB.TVMFuncCall(
       229         self.handle,
      (...)
       236     != 0
       237 ):
   --> 238     raise get_last_ffi_error()
       239 _ = temp_args
       240 _ = args
   
   TVMError: Traceback (most recent call last):
     2: TVMFuncCall
     1: 
tvm::runtime::PackedFuncObj::Extractor::AssignTypedLambda(tvm::{lambda(tvm::IRModule,
 tvm::GlobalTypeVar)#6}, std::__cxx11::basic_string, std::allocator 
>)::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}> 
>::Call(tvm::runtime::PackedFuncObj const*, tvm::runtime::TVMArgs, 
tvm::runtime::TVMRetValue*)
     0: tvm::runtime::TVMMovableArgValueWithContext_::operator 
tvm::GlobalTypeVar() const
     3: TVMFuncCall
     2: 
tvm::runtime::PackedFuncObj::Extractor::AssignTypedLambda(tvm::{lambda(tvm::IRModule,
 tvm::GlobalTypeVar)#6}, std::__cxx11::basic_string, std::allocator 
>)::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}> 
>::Call(tvm::runtime::PackedFuncObj const*, tvm::runtime::TVMArgs, 
tvm::runtime::TVMRetValue*)
     1: tvm::runtime::TVMMovableArgValueWithContext_::operator 
tvm::GlobalTypeVar() const
     0: tvm::GlobalTypeVar tvm::runtime::TVMPODValue_::AsObjectRef() const
     File "/home/wyc/husen/sandbox/tvm/include/tvm/runtime/packed_func.h", line 
777
   TVMError: In function ir.Module_LookupDef(0: IRModule, 1: GlobalTypeVar) -> 
relay.TypeData: error while converting argument 1: [16:02:13] 
/home/wyc/husen/sandbox/tvm/include/tvm/runtime/packed_func.h:1890: 
   ---------------------------------------------------------------
   An error occurred during the execution of TVM.
   For more information, please see: https://tvm.apache.org/docs/errors.html
   ---------------------------------------------------------------
   
     Check failed: type_code_ == kTVMObjectHandle (0 vs. 8) : expected Object 
but got int
   ```
   
   ### Environment
   
   OS: Ubuntu 20.04
   TVM version: tvm-0.13.dev667+g730d380ff-py3.10-linux-x86_64
   
   ### Steps to reproduce
   
   ```py
   from tvm.relax.frontend.onnx import from_onnx
   
   onnx_file = "/path/to/sigmoid.onnx"
   model = onnx.load(onnx_file)
   
   ir_mod, params = from_onnx(model, keep_params_in_input=True)
   ```
   
   ### Triage
   
   * needs-triage
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to