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

   The input_dtype == 'float64' will lead to a check failure and throw "Check 
failed: from_size == to_size (3360 vs. 1680) : TVMArrayCopyFromTo: The size 
must exactly match".
   
   This bug looks similar to this PR #7665.
    
   
   
   ### Actual behavior
   
   ```
   Traceback (most recent call last):
     File "test.py", line 28, in <module>
       res_tvm = model(tvm.nd.array(test_x_tvm.astype('float64'))).numpy()
     File "/workplace/software/tvm/tvm_/python/tvm/relay/build_module.py", line 
537, in _graph_wrapper
       gmodule.set_input(i, arg)
     File "/workplace/software/tvm/tvm_/python/tvm/contrib/graph_executor.py", 
line 199, in set_input
       v.copyfrom(value)
     File "/workplace/software/tvm/tvm_/python/tvm/runtime/ndarray.py", line 
143, in copyfrom
       source_array.copyto(self)
     File "/workplace/software/tvm/tvm_/python/tvm/runtime/ndarray.py", line 
251, in copyto
       return self._copyto(target)
     File "/workplace/software/tvm/tvm_/python/tvm/_ffi/_ctypes/ndarray.py", 
line 90, in _copyto
       check_call(_LIB.TVMArrayCopyFromTo(self.handle, target_nd.handle, None))
     File "/workplace/software/tvm/tvm_/python/tvm/_ffi/base.py", line 348, in 
check_call
       raise get_last_ffi_error()
   tvm._ffi.base.TVMError: Traceback (most recent call last):
     49: 0x000055c08bd49b32
           at ../sysdeps/x86_64/elf/start.S:103
     48: __libc_start_main
     47: Py_BytesMain
           at /tmp/build/80754af9/python_1589913560097/work/Modules/main.c:1089
     46: Py_RunMain
           at /tmp/build/80754af9/python_1589913560097/work/Modules/main.c:650
     45: pymain_run_python
           at /tmp/build/80754af9/python_1589913560097/work/Modules/main.c:571
     44: pymain_run_file
           at /tmp/build/80754af9/python_1589913560097/work/Modules/main.c:387
     43: PyRun_SimpleFileExFlags
           at 
/tmp/build/80754af9/python_1589913560097/work/Python/pythonrun.c:428
     42: PyRun_FileExFlags
           at 
/tmp/build/80754af9/python_1589913560097/work/Python/pythonrun.c:1063
     41: run_mod
           at 
/tmp/build/80754af9/python_1589913560097/work/Python/pythonrun.c:1147
     40: run_eval_code_obj
           at 
/tmp/build/80754af9/python_1589913560097/work/Python/pythonrun.c:1125
     39: PyEval_EvalCode
           at /tmp/build/80754af9/python_1589913560097/work/Python/ceval.c:718
     38: PyEval_EvalCodeEx
           at /tmp/build/80754af9/python_1589913560097/work/Python/ceval.c:4327
     37: _PyEval_EvalCodeWithName
           at /tmp/build/80754af9/python_1589913560097/work/Python/ceval.c:4298
     36: _PyEval_EvalFrameDefault
           at /tmp/build/80754af9/python_1589913560097/work/Python/ceval.c:3500
     35: call_function
           at /tmp/build/80754af9/python_1589913560097/work/Python/ceval.c:4963
     34: _PyObject_Vectorcall
           at 
/tmp/build/80754af9/python_1589913560097/work/Include/cpython/abstract.h:127
     33: _PyFunction_Vectorcall
           at /tmp/build/80754af9/python_1589913560097/work/Objects/call.c:435
     32: _PyEval_EvalCodeWithName
           at /tmp/build/80754af9/python_1589913560097/work/Python/ceval.c:4298
     31: _PyEval_EvalFrameDefault
           at /tmp/build/80754af9/python_1589913560097/work/Python/ceval.c:3486
     30: call_function
           at /tmp/build/80754af9/python_1589913560097/work/Python/ceval.c:4963
     29: _PyObject_Vectorcall
           at 
/tmp/build/80754af9/python_1589913560097/work/Include/cpython/abstract.h:127
     28: _PyFunction_Vectorcall
           at /tmp/build/80754af9/python_1589913560097/work/Objects/call.c:435
     27: _PyEval_EvalCodeWithName
           at /tmp/build/80754af9/python_1589913560097/work/Python/ceval.c:4298
     26: _PyEval_EvalFrameDefault
           at /tmp/build/80754af9/python_1589913560097/work/Python/ceval.c:3486
     25: call_function
           at /tmp/build/80754af9/python_1589913560097/work/Python/ceval.c:4963
     24: _PyObject_Vectorcall
           at 
/tmp/build/80754af9/python_1589913560097/work/Include/cpython/abstract.h:127
     23: _PyFunction_Vectorcall
           at /tmp/build/80754af9/python_1589913560097/work/Objects/call.c:410
     22: function_code_fastcall
           at /tmp/build/80754af9/python_1589913560097/work/Objects/call.c:283
     21: _PyEval_EvalFrameDefault
           at /tmp/build/80754af9/python_1589913560097/work/Python/ceval.c:3486
     20: call_function
           at /tmp/build/80754af9/python_1589913560097/work/Python/ceval.c:4963
     19: _PyObject_Vectorcall
           at 
/tmp/build/80754af9/python_1589913560097/work/Include/cpython/abstract.h:127
     18: _PyFunction_Vectorcall
           at /tmp/build/80754af9/python_1589913560097/work/Objects/call.c:435
     17: _PyEval_EvalCodeWithName
           at /tmp/build/80754af9/python_1589913560097/work/Python/ceval.c:4298
     16: _PyEval_EvalFrameDefault
           at /tmp/build/80754af9/python_1589913560097/work/Python/ceval.c:3486
     15: call_function
           at /tmp/build/80754af9/python_1589913560097/work/Python/ceval.c:4963
     14: _PyObject_Vectorcall
           at 
/tmp/build/80754af9/python_1589913560097/work/Include/cpython/abstract.h:127
     13: _PyFunction_Vectorcall
           at /tmp/build/80754af9/python_1589913560097/work/Objects/call.c:410
     12: function_code_fastcall
           at /tmp/build/80754af9/python_1589913560097/work/Objects/call.c:283
     11: _PyEval_EvalFrameDefault
           at /tmp/build/80754af9/python_1589913560097/work/Python/ceval.c:3469
     10: call_function
           at /tmp/build/80754af9/python_1589913560097/work/Python/ceval.c:4963
     9: _PyObject_Vectorcall
           at 
/tmp/build/80754af9/python_1589913560097/work/Include/cpython/abstract.h:125
     8: _PyObject_MakeTpCall
           at /tmp/build/80754af9/python_1589913560097/work/Objects/call.c:159
     7: PyCFuncPtr_call
           at /usr/local/src/conda/python-3.8.3/Modules/_ctypes/_ctypes.c:4201
     6: _ctypes_callproc
           at /usr/local/src/conda/python-3.8.3/Modules/_ctypes/callproc.c:1199
     5: _call_function_pointer
           at /usr/local/src/conda/python-3.8.3/Modules/_ctypes/callproc.c:871
     4: ffi_call_int
     3: ffi_call_unix64
     2: TVMArrayCopyFromTo
     1: tvm::runtime::NDArray::CopyFromTo(DLTensor const*, DLTensor*, void*)
     0: _ZN3tvm7runtime6detail
     File "/workplace/software/tvm/tvm_/src/runtime/ndarray.cc", line 270
   TVMError:
   ```
   
   ### Environment
   
   Any environment details, such as: Operating System, TVM version, etc
   
   ### Steps to reproduce
   
   ```
   import tvm
   import tvm.relay as relay
   import numpy as np
   from tensorflow import keras
   from tensorflow.keras import layers, models
   
   input_shape = (1, 5, 7, 6, 2)
   
   input_data = np.random.random(size=input_shape)
   x = layers.Input(shape=input_shape[1:], dtype='float64')
   
   layer = keras.layers.Conv3D(filters=1, kernel_size=3)
   layer.set_weights(layer.get_weights())
   
   y = layer(x)
   model = models.Model(x, y)
   model.summary()
   res_keras = model(input_data)
   
   shape_dict = {'input_1': input_shape}
   mod, params = relay.frontend.from_keras(model, shape_dict,layout='NDHWC')
   with tvm.transform.PassContext(opt_level=3):
       model = relay.build_module.create_executor("graph", mod, tvm.cpu(0), 
'llvm', params).evaluate()
   
   test_x_tvm = input_data
   res_tvm = model(tvm.nd.array(test_x_tvm.astype('float64'))).numpy()
   
   np.testing.assert_allclose(res_keras, res_tvm, atol=1e-3, rtol=1e-3)
   ```
   
   cc @comaniac @tkonolige 
   
   
   


-- 
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