I use the code here and try to load saved model. https://tvm.apache.org/docs/tutorials/get_started/relay_quick_start.html#run-the-generate-library
One thing that I am not clear is that, if I feed an int NumPy array to the loaded module, it will cause an assertion error.
loaded_lib = tvm.runtime.load_module(path_lib)
input_data = tvm.nd.array(data.astype("int"))
module = graph_executor.GraphModule(loaded_lib["default"](dev))
module.run(data=input_data)
out_deploy = module.get_output(0).numpy()
# Print first 10 elements of output
print(out_deploy.flatten()[0:10])
And the errors is this:
Traceback (most recent call last):
File "load_save.py", line 148, in <module>
module.run(data=input_data)
File "/data/ytianas/virtualenv/autotvm/lib64/python3.6/site-packages/tvm-0.8.dev1273+gd17f753
84-py3.6-linux-x86_64.egg/tvm/contrib/graph_executor.py", line 205, in run
self.set_input(**input_dict)
File "/data/ytianas/virtualenv/autotvm/lib64/python3.6/site-packages/tvm-0.8.dev1273+gd17f753
84-py3.6-linux-x86_64.egg/tvm/contrib/graph_executor.py", line 194, in set_input
self._get_input(k).copyfrom(params[k])
File "/data/ytianas/virtualenv/autotvm/lib64/python3.6/site-packages/tvm-0.8.dev1273+gd17f753
84-py3.6-linux-x86_64.egg/tvm/runtime/ndarray.py", line 143, in copyfrom
source_array.copyto(self)
File "/data/ytianas/virtualenv/autotvm/lib64/python3.6/site-packages/tvm-0.8.dev1273+gd17f753
84-py3.6-linux-x86_64.egg/tvm/runtime/ndarray.py", line 237, in copyto
return self._copyto(target)
File "/data/ytianas/virtualenv/autotvm/lib64/python3.6/site-packages/tvm-0.8.dev1273+gd17f753
84-py3.6-linux-x86_64.egg/tvm/_ffi/_ctypes/ndarray.py", line 90, in _copyto
check_call(_LIB.TVMArrayCopyFromTo(self.handle, target_nd.handle, None))
File "/data/ytianas/virtualenv/autotvm/lib64/python3.6/site-packages/tvm-0.8.dev1273+gd17f753
84-py3.6-linux-x86_64.egg/tvm/_ffi/base.py", line 348, in check_call
raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
37: 0xffffffffffffffff
36: _start
35: __libc_start_main
34: main
33: Py_Main.cold.3362
32: PyRun_SimpleFileExFlags
31: PyRun_FileExFlags
30: run_mod
29: PyEval_EvalCode
28: _PyEval_EvalCodeWithName
27: _PyEval_EvalFrameDefault
26: call_function
25: fast_function
24: _PyEval_EvalCodeWithName
23: _PyEval_EvalFrameDefault
22: PyObject_Call
21: method_call
20: _PyObject_FastCallDict
19: _PyFunction_FastCallDict
18: _PyEval_EvalCodeWithName
17: _PyEval_EvalFrameDefault
16: call_function
15: fast_function
14: _PyEval_EvalFrameDefault
13: call_function
12: fast_function
11: _PyEval_EvalFrameDefault
10: call_function
9: fast_function
8: _PyEval_EvalFrameDefault
7: call_function
6: _PyObject_FastCallKeywords
5: PyCFuncPtr_call
4: _ctypes_callproc.cold.53
3: ffi_call
2: ffi_call_unix64
1: TVMArrayCopyFromTo
0: tvm::runtime::NDArray::CopyFromTo(DLTensor const*, DLTensor*, void*)
File "/data/ytianas/autotvm/tvm/src/runtime/ndarray.cc", line 232
TVMError:
---------------------------------------------------------------
An error occurred during the execution of TVM.
For more information, please see: https://tvm.apache.org/docs/errors.html
---------------------------------------------------------------
Check failed: from_size == to_size (1204224 vs. 602112) : TVMArrayCopyFromTo: The size must exactly match
I can understand that the module is defined to process a float array. What I cannot understand is that why feed an int array will cause a size mismatch?
Thanks.