<class 'tvm.relay.expr.Call'> has no attribute name_hint when importing SSD-ResNet34 from TensorFlow

Hi,

When I import SSD-Resnet34 (it is downloaded from https://github.com/mlperf/inference/tree/master/v0.5/classification_and_detection, ssd-resnet34 1200x1200 Tensorflow model)

import tvm
from tvm import relay
import tensorflow as tf
from tvm.relay.frontend.tensorflow_parser import TFParser
import tvm.relay.testing.tf as tf_testing

target = 'llvm'
target_host = 'llvm'
layout = None
ctx = tvm.cpu(0)

# mlperf model
model_path = './tf_ssd_resnet34_22.1/resnet34_tf.22.1.pb'

parser = TFParser(model_path)
graph_def = parser.parse()

with tf.gfile.GFile(model_path, 'rb') as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())
    graph = tf.import_graph_def(graph_def, name='')
    graph_def = tf_testing.ProcessGraphDefParam(graph_def)

mod, params = relay.frontend.from_tensorflow(graph_def, layout=layout)

The following error occurred:

AttributeError: <class 'tvm.relay.expr.Call'> has no attribute name_hint

Iā€™m not sure what exactly the error is.

Can you print full trace?

Thanks for your quick reply.

WARNING:root:Attribute _output_shapes is ignored in relay.sym.take
WARNING:root:Attribute _node_name is ignored in relay.sym.take
WARNING:root:Attribute _target_layout is ignored in relay.sym.take
WARNING:root:Attribute Tdim is ignored in relay.sym.expand_dims
WARNING:root:Attribute T is ignored in relay.sym.expand_dims
WARNING:root:Attribute _output_shapes is ignored in relay.sym.expand_dims
WARNING:root:Attribute _node_name is ignored in relay.sym.expand_dims
WARNING:root:Attribute _target_layout is ignored in relay.sym.expand_dims
Traceback (most recent call last):
  File "/home/incubator-tvm-0612/python/tvm/runtime/object.py", line 55, in __getattr__
    return _ffi_node_api.NodeGetAttr(self, name)
  File "/home/incubator-tvm-0612/python/tvm/_ffi/_ctypes/packed_func.py", line 225, in __call__
    raise get_last_ffi_error()
AttributeError: Traceback (most recent call last):
  [bt] (4) /home/incubator-tvm-0612/build/libtvm.so(TVMFuncCall+0x65) [0x7fbb7c70a985]
  [bt] (3) /home/incubator-tvm-0612/build/libtvm.so(std::_Function_handler<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*), void (*)(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)>::_M_invoke(std::_Any_data const&, tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&)+0x14) [0x7fbb7bdf3874]
  [bt] (2) /home/incubator-tvm-0612/build/libtvm.so(tvm::NodeGetAttr(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)+0x146) [0x7fbb7bdf3746]
  [bt] (1) /home/incubator-tvm-0612/build/libtvm.so(tvm::ReflectionVTable::GetAttr(tvm::runtime::Object*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const+0x24a) [0x7fbb7bdf317a]
  [bt] (0) /home/incubator-tvm-0612/build/libtvm.so(+0xc7ce8b) [0x7fbb7bdefe8b]
  File "/home/incubator-tvm-0612/src/node/reflection.cc", line 110
AttributeError: relay.Call object has no attributed name_hint

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/incubator-tvm-0612/tutorials/test_tensorflow/ssd_resnet_34.py", line 32, in <module>
    mod, params = relay.frontend.from_tensorflow(graph_def, layout='NHWC', shape=(1, 1200, 1200, 3))
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 3577, in from_tensorflow
    mod, params = g.from_tensorflow(graph, layout, shape, outputs)
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 2970, in from_tensorflow
    func = self._get_relay_func(graph, layout=layout, shape=shape, outputs=outputs)
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 2925, in _get_relay_func
    self._backtrack_construct(node.name)
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 3465, in _backtrack_construct
    self._control_flow_node_map)
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 3212, in _convert_control_flow_operator
    op = self._licm_construct(plname, node.input[0])
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 3400, in _licm_construct
    actual_expr = self._backtrack_construct(node_name)
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 3489, in _backtrack_construct
    converted = self._backtrack_construct(shape_node.name)
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 3471, in _backtrack_construct
    inputs = [self._backtrack_construct(iname) for iname in node.input]
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 3471, in <listcomp>
    inputs = [self._backtrack_construct(iname) for iname in node.input]
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 3471, in _backtrack_construct
    inputs = [self._backtrack_construct(iname) for iname in node.input]
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 3471, in <listcomp>
    inputs = [self._backtrack_construct(iname) for iname in node.input]
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 3471, in _backtrack_construct
    inputs = [self._backtrack_construct(iname) for iname in node.input]
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 3471, in <listcomp>
    inputs = [self._backtrack_construct(iname) for iname in node.input]
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 3471, in _backtrack_construct
    inputs = [self._backtrack_construct(iname) for iname in node.input]
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 3471, in <listcomp>
    inputs = [self._backtrack_construct(iname) for iname in node.input]
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 3511, in _backtrack_construct
    op = self._convert_operator(node.op, inputs, attr, self._graph)
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 3368, in _convert_operator
    sym = convert_map[op_name](inputs, attrs, self._params, self._mod)
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 1564, in _impl
    padlist = _get_param(params, inputs[1])
  File "/home/incubator-tvm-0612/python/tvm/relay/frontend/tensorflow.py", line 84, in _get_param
    return params[input_node.name_hint].asnumpy()
  File "/home/incubator-tvm-0612/python/tvm/runtime/object.py", line 58, in __getattr__
    "%s has no attribute %s" % (str(type(self)), name))
AttributeError: <class 'tvm.relay.expr.Call'> has no attribute name_hint

Process finished with exit code 1

FYI.

This means padlist is actually symbolic. You can try something like padlist = _infer_value(inputs[1], params, mod) to see whether it can be pre-computed.

I tried padlist = _infer_value(inputs[1], params, mod).asnumpy(), and the error is fixed. Thanks!

1 Like

@wwwwcu Would you mind file a patch for this?