Inceptionv3 compilation failed - pool size (8) exceeds input (5 padded to 5)


#1

I’m using the following code to compile

import sys
import nnvm

from mxnet.gluon.model_zoo.vision import get_model

sys.setrecursionlimit(2031)

batch_size = 1
image_shape = (3, 224, 224)
data_shape = (batch_size,) + image_shape
model_name = 'inceptionv3'

block = get_model(model_name, pretrained=True)
sym, params = nnvm.frontend.from_mxnet(block)
sym = nnvm.sym.softmax(sym)

opt_level = 1
target = 'llvm'
target_host = None

print('model:', model_name, ', target:', target, ', target_host:', target_host, ', opt_level:', opt_level, ', data_shape:', data_shape)

with nnvm.compiler.build_config(opt_level=opt_level):
    graph, lib, params = nnvm.compiler.build(sym, target, shape={"data": data_shape}, params=params, target_host=target_host)

Error:

model: inceptionv3 , target: llvm , target_host: None , opt_level: 1 , data_shape: (1, 3, 224, 224)
Traceback (most recent call last):
  File "./c.py", line 26, in <module>
    graph, lib, params = nnvm.compiler.build(sym, target, shape={"data": data_shape}, params=params, target_host=target_host)
  File "/usr/local/lib/python3.5/dist-packages/nnvm-0.8.0-py3.5.egg/nnvm/compiler/build_module.py", line 270, in build
    ishape, _ = graph_util.infer_shape(graph, **shape)
  File "/usr/local/lib/python3.5/dist-packages/nnvm-0.8.0-py3.5.egg/nnvm/compiler/graph_util.py", line 31, in infer_shape
    graph = graph.apply("InferShape")
  File "/usr/local/lib/python3.5/dist-packages/nnvm-0.8.0-py3.5.egg/nnvm/graph.py", line 234, in apply
    check_call(_LIB.NNGraphApplyPasses(self.handle, npass, cpass, ctypes.byref(ghandle)))
  File "/usr/local/lib/python3.5/dist-packages/nnvm-0.8.0-py3.5.egg/nnvm/_base.py", line 75, in check_call
    raise NNVMError(py_str(_LIB.NNGetLastError()))
nnvm._base.NNVMError: Error in operator avg_pool2d9: [03:23:43] /root/workplace/tvm/nnvm/src/top/nn/pooling.cc:65: Check failed: param.pool_size[0] <= dshape[hidx] + pad_h pool size (8) exceeds input (5 padded to 5)

Stack trace returned 10 entries:
[bt] (0) /usr/local/lib/python3.5/dist-packages/tvm-0.5.dev0-py3.5-linux-x86_64.egg/tvm/libtvm.so(dmlc::StackTrace[abi:cxx11](unsigned long)+0x1fd) [0x7f1743a630ad]
[bt] (1) /usr/local/lib/python3.5/dist-packages/tvm-0.5.dev0-py3.5-linux-x86_64.egg/tvm/libtvm.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x2d) [0x7f1743a63cfd]
[bt] (2) /usr/local/lib/python3.5/dist-packages/nnvm-0.8.0-py3.5.egg/nnvm/libnnvm_compiler.so(bool nnvm::top::Pool2DInferShape<nnvm::top::AvgPool2DParam>(nnvm::NodeAttrs const&, std::vector<nnvm::TShape, std::allocator<nnvm::TShape> >*, std::vector<nnvm::TShape, std::allocator<nnvm::TShape> >*)+0x5aa) [0x7f173e6b2eba]
[bt] (3) /usr/local/lib/python3.5/dist-packages/nnvm-0.8.0-py3.5.egg/nnvm/libnnvm_compiler.so(+0x118a21) [0x7f173e5b9a21]
[bt] (4) /usr/local/lib/python3.5/dist-packages/nnvm-0.8.0-py3.5.egg/nnvm/libnnvm_compiler.so(+0x119d7a) [0x7f173e5bad7a]
[bt] (5) /usr/local/lib/python3.5/dist-packages/nnvm-0.8.0-py3.5.egg/nnvm/libnnvm_compiler.so(+0x11add6) [0x7f173e5bbdd6]
[bt] (6) /usr/local/lib/python3.5/dist-packages/nnvm-0.8.0-py3.5.egg/nnvm/libnnvm_compiler.so(nnvm::ApplyPasses(nnvm::Graph, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)+0x32b) [0x7f173e58f0ab]
[bt] (7) /usr/local/lib/python3.5/dist-packages/nnvm-0.8.0-py3.5.egg/nnvm/libnnvm_compiler.so(NNGraphApplyPasses+0x348) [0x7f173e572188]
[bt] (8) /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so(ffi_call_unix64+0x4c) [0x7f1770eebe20]
[bt] (9) /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so(ffi_call+0x2eb) [0x7f1770eeb88b]

#2

looks like it does not support (1, 3, 224, 224)
I tried (1, 3, 299, 299) instead and it works!


#3

seems the supported shape for inception-v3 is 3x299x299, can not change the shape as i know.


#4

yes, autotvm examples use 299 instead of 224 for inception_v3