Issue description
Conversion of pretrained quantized GluonCV models ssd_512_resnet50_v1_voc_int8
and ssd_512_mobilenet1.0_voc_int8
to TVM Relay graphs fails with KeyError for missing key “attrs”.
Steps to reproduce the issue
- Prepare hardware and environment that meet the requirements for TVM
- Install MXNet 1.5.1 or 1.6.0, GluonCV 0.7.0, and the latest MKL-DNN library
- Build TVM with USE_MKLDNN ON
- Download pretrained INT8 model
ssd_512_resnet50_v1_voc_int8
orssd_512_mobilenet1.0_voc_int8
from GluonCV withgluoncv.model_zoo_get_model()
- Convert the model to a TVM Relay graph with
tvm.relay.frontend.from_mxnet()
What’s the expected result?
- Graph conversion succeeds
What’s the actual result?
-
Graph conversion fails with the following KeyError:
File "/usr/tvm/python/tvm/relay/frontend/mxnet.py", line 1589, in _get_bn_alpha_coeff bn_attrs = _get_subgraph_op(subgraphs, 'BatchNorm')['attrs'] KeyError: 'attrs'
Additional details
- The offending graph node is a BatchNorm node in a subgraph of operator
_sg_mkldnn_conv
-
_qnn_conv
inrelay/frontend/mxnet.py
expects a key “attrs” in all BatchNorm nodes in this operator - The error occurs because the BatchNorm nodes
ssd0_expand_*
in this operator have no key “attrs”
Suggested solutions
- Fix TVM graph conversion of quantized models so as not to cause KeyError