Error message: Check failed: dshape.ndim() != 0 (0 vs. 0)

I’m following the android deploy tutorial in TVM. I was able to run the application on smartphone using default libraries that get downloaded as part of compilation.
My next step is to compile the libraries for ARM architecture. When I try to generate the libraries using run_mobile.py
I’m observing the following error :

Build Graph…
[14:20:53] /local/mnt/workspace/abhikran/tvm/tvm_hexagon_2_August/tvm/nnvm/src/compiler/simplify_inference.cc:46: Check failed: dshape.ndim() != 0 (0 vs. 0) :
Stack trace:
[bt] (0) /local/mnt/workspace/abhikran/tvm/tvm_hexagon_2_August/tvm/build/libtvm.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x33) [0x7fad329d2f83]
[bt] (1) /local/mnt/workspace/abhikran/tvm/tvm_hexagon_2_August/tvm/nnvm/python/nnvm/…/…/…/build/libnnvm_compiler.so(nnvm::compiler::BatchNormToInferUnpack(nnvm::NodeAttrs const&, nnvm::NodeEntry, nnvm::NodeEntry, nnvm::NodeEntry, nnvm::NodeEntry, nnvm::NodeEntry, nnvm::TShape, nnvm::TShape)+0xf4) [0x7fad1f57df04]
[bt] (2) /local/mnt/workspace/abhikran/tvm/tvm_hexagon_2_August/tvm/nnvm/python/nnvm/…/…/…/build/libnnvm_compiler.so(+0x1cdfd7) [0x7fad1f582fd7]
[bt] (3) /local/mnt/workspace/abhikran/tvm/tvm_hexagon_2_August/tvm/nnvm/python/nnvm/…/…/…/build/libnnvm_compiler.so(nnvm::compiler::SimplifyInference(nnvm::Graph)+0x9cc) [0x7fad1f581bfc]
[bt] (4) /local/mnt/workspace/abhikran/tvm/tvm_hexagon_2_August/tvm/nnvm/python/nnvm/…/…/…/build/libnnvm_compiler.so(nnvm::Graph std::__1::__invoke_void_return_wrapper < nnvm::Graph>::__call<nnvm::Graph (&)(nnvm::Graph), nnvm::Graph>(nnvm::Graph (&&&)(nnvm::Graph), nnvm::Graph&&)+0xb6) [0x7fad1f552eb6]
[bt] (5) /local/mnt/workspace/abhikran/tvm/tvm_hexagon_2_August/tvm/nnvm/python/nnvm/…/…/…/build/libnnvm_compiler.so(std::__1::__function::__func<nnvm::Graph ()(nnvm::Graph), std::__1::allocator<nnvm::Graph ()(nnvm::Graph)>, nnvm::Graph (nnvm::Graph)>::operator()(nnvm::Graph&&)+0xd) [0x7fad1f552dbd]
[bt] (6) /local/mnt/workspace/abhikran/tvm/tvm_hexagon_2_August/tvm/nnvm/python/nnvm/…/…/…/build/libnnvm_compiler.so(nnvm::ApplyPasses(nnvm::Graph, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > const&)+0x4c2) [0x7fad1f58d842]
[bt] (7) /local/mnt/workspace/abhikran/tvm/tvm_hexagon_2_August/tvm/nnvm/python/nnvm/…/…/…/build/libnnvm_compiler.so(NNGraphApplyPasses+0x1e8) [0x7fad1f5213a8]
[bt] (8) /local/mnt/workspace/abhikran/software/setup/python3/Python-3.5.7/install_dir/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so(ffi_call_unix64+0x4c) [0x7fad3acddc6a]

I checked some topics and found a similar problem faced in this discussion: Run multiple keras models in one program

I tried the solution that worked in the above mentioned discussion i.e. replacing “input_0” in the script with “onnx_graph.graph.input[0].name” but still the error persists.

Request you to please help.

Hi @FrozenGene : Could you please help with the problem I’m seeing ?

Could you make sure your model’s tensor name and shape? If you pass wrong input information, which usually results in this error.

I am using “onnx_graph.graph.input[0].name” to get the name of first layer and the shape is already available in the example script.

org_img = Image.open(’./data/test.jpg’)
org_img = org_img.resize((n, n))
img = np.asarray(org_img).astype(np.float32).copy()
img = img.transpose(2,0,1)
img /= 255.
img = img[np.newaxis,:]

input_name = ‘onnx_graph.graph.input[0].name’
data_shape = img.shape
out_shape = (1,125,n//32,n//32)

Still the error is observed. Do you suspect anything wrong here ?

Also, while debugging, I saw the problem to occur with “SimplifyInference” Pass. Any help would be appreciated.

‘onnx_graph.graph.input[0].name’ is a string. Meanwhile, the model has only one input? Could you share the model, maybe we can get more information.

I’m using this script : https://github.com/tkat0/chainer-nnvm-example/blob/5b97fd4d41aa4dde4b0aceb0be311054fb5de451/run_mobile.py#L19

In line 19, the model gets loaded.

Model used : https://github.com/tkat0/chainer-nnvm-example/tree/master/models/YOLOv2_tiny

The input model name is so strange. Try to set the input name be this strange number.

1 Like

Thank you @FrozenGene. This solved the problem!