cvpr2020-videomodeling-deployment icon indicating copy to clipboard operation
cvpr2020-videomodeling-deployment copied to clipboard

IndexError: Index out of range. size: 4, got index 4

Open siriusmehta opened this issue 4 years ago • 3 comments

Hi,

I am trying to convert slowfast_4x16_resnet50_kinetics400 to TVM using the below notebook:

https://github.com/zhreshold/cvpr2020-videomodeling-deployment/blob/master/03_deploy_video_model_to_tvm.ipynb

But getting below error in line:

gcv.utils.export_tvm(model_name, net, data_shape=(1, 3, 224, 224), preprocess=TvmPreprocess(), target='cuda', ctx=mx.gpu(0), opt_level=3, use_autotvm=False)

Error:

IndexError Traceback (most recent call last) in 1 gcv.utils.export_tvm(model_name, net, data_shape=(1, 3, 224, 224), preprocess=TvmPreprocess(), ----> 2 target='cuda', ctx=mx.gpu(0), opt_level=3, use_autotvm=False)

~/archiconda3/envs/mx1.7/lib/python3.6/site-packages/gluoncv/utils/export_helper.py in export_tvm(path, block, data_shape, epoch, preprocess, layout, ctx, target, opt_level, use_autotvm) 227 228 # convert to relay graph --> 229 sym, params = relay.frontend.from_mxnet(wrapper_block, shape={"data": data_shape}) 230 231 if use_autotvm:

~/archiconda3/envs/mx1.7/lib/python3.6/site-packages/tvm-0.8.dev245+gb2e418cb1-py3.6-linux-aarch64.egg/tvm/relay/frontend/mxnet.py in from_mxnet(symbol, shape, dtype, arg_params, aux_params) 2881 sym = mx.sym.Group(sym) 2882 shape, dtype = _update_shape_dtype(shape, dtype, params) -> 2883 func = _from_mxnet_impl(sym, shape, dtype, params, mod) 2884 elif isinstance(symbol, mx.gluon.Block): 2885 raise NotImplementedError("Only Hybrid Blocks are supported now.")

~/archiconda3/envs/mx1.7/lib/python3.6/site-packages/tvm-0.8.dev245+gb2e418cb1-py3.6-linux-aarch64.egg/tvm/relay/frontend/mxnet.py in _from_mxnet_impl(symbol, shape_dict, dtype_info, params, mod) 2790 assert op_name in _convert_map 2791 op_params = _get_op_params(children, attrs, op_name, node, params) -> 2792 res = _convert_mapop_name 2793 if res is None: 2794 # defer conversion, used in RNN state initialization

~/archiconda3/envs/mx1.7/lib/python3.6/site-packages/tvm-0.8.dev245+gb2e418cb1-py3.6-linux-aarch64.egg/tvm/relay/frontend/mxnet.py in _mx_slice(inputs, attrs) 509 for i, ed in enumerate(end): 510 if ed is None: --> 511 end[i] = input_shape[i] 512 new_attrs = {"begin": list(begin), "end": list(end)} 513 if stride is not None:

~/archiconda3/envs/mx1.7/lib/python3.6/site-packages/tvm-0.8.dev245+gb2e418cb1-py3.6-linux-aarch64.egg/tvm/ir/container.py in getitem(self, idx) 34 35 def getitem(self, idx): ---> 36 return getitem_helper(self, _ffi_node_api.ArrayGetItem, len(self), idx) 37 38 def len(self):

~/archiconda3/envs/mx1.7/lib/python3.6/site-packages/tvm-0.8.dev245+gb2e418cb1-py3.6-linux-aarch64.egg/tvm/runtime/container.py in getitem_helper(obj, elem_getter, length, idx) 55 56 if idx < -length or idx >= length: ---> 57 raise IndexError("Index out of range. size: {}, got index {}".format(length, idx)) 58 if idx < 0: 59 idx += length

IndexError: Index out of range. size: 4, got index 4

Thanks

siriusmehta avatar Nov 24 '20 17:11 siriusmehta

I would suggest that you use v0.7 as the notebook is tested with tvm version 0.7, the converter may have been updated since then

zhreshold avatar Nov 25 '20 00:11 zhreshold

Built the tvm from source for v0.7 but still facing the same error. My current environment is:

import gluoncv as gcv import mxnet as mx import tvm print('Requires gluoncv>=0.8.0 alpha:', gcv.version) print(mx.version) print(tvm.version)

Requires gluoncv>=0.8.0 alpha: 0.9.0 1.7.0 0.7.0

siriusmehta avatar Nov 25 '20 09:11 siriusmehta

Thanks it got solved! there was a data shape error.

siriusmehta avatar Nov 25 '20 19:11 siriusmehta