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

Hi,

I’m trying to import tf graph to Relay, but the error happens at the Tile node. It seems that the error occurs in the function.

def _tile():
    def _impl(inputs, attr, params):
        reps = _get_list_param(params, inputs.pop())
        new_input = []
        new_input.append(inputs.pop(0))

        return AttrCvt(
            op_name='tile',
            extras={'reps': tuple(reps)},
            ignores=['Tmultiples'])(new_input, attr)
    return _impl

Does anyone know how to solve this error?

error message:

Traceback (most recent call last):

  File "from_tensorflow_yolo.py", line 175, in <module>
    shape=shape_dict)

  File "/home/user/tvm/python/tvm/relay/frontend/tensorflow.py", line 2675, in from_tensorflow
    mod, params = g.from_tensorflow(graph, layout, shape, outputs)

  File "/home/user/tvm/python/tvm/relay/frontend/tensorflow.py", line 2310, in from_tensorflow
    op = self._convert_operator(node.op, inputs, attr, graph)

  File "/home/user/tvm/python/tvm/relay/frontend/tensorflow.py", line 2637, in _convert_operator
    sym = convert_map[op_name](inputs, attrs, self._params)

  File "/home/user/tvm/python/tvm/relay/frontend/tensorflow.py", line 781, in _impl
    reps = _get_list_param(params, inputs.pop())

  File "/home/user/tvm/python/tvm/relay/frontend/tensorflow.py", line 105, in _get_list_param
    return _get_param(params, input_node).tolist()

  File "/home/user/tvm/python/tvm/relay/frontend/tensorflow.py", line 87, in _get_param
    return params.pop(input_node.name_hint).asnumpy()

  File "/home/user/tvm/python/tvm/_ffi/object.py", line 68, in __getattr__
    "%s has no attribute %s" % (str(type(self)), name))

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

Related issues: https://github.com/apache/incubator-tvm/issues/4262

@garyyyccc I met same issue, what’s the multiples argument of tf.tile Node in your tf graph?

@zhuochenKIDD Here are the codes:

 y = tf.tile(tf.range(output_size, dtype=tf.int32)[:, tf.newaxis], [1, output_size])
 x = tf.tile(tf.range(output_size, dtype=tf.int32)[tf.newaxis, :], [output_size, 1]) 

Have you solved it?

as far as I know, tvm graph runtime does not support dynamic shape tensor. So if you set out_size fixed, perhaps it works.

This is absolutely an error in the tensorflow converter. @jroesch

I do not know how to trigger this error. If you guys give me a minimual reproducible example that’d be great.

@MarisaKirisame here is an example, pls check that

dense_shape = (1, 2)
dense_input = tf.placeholder(tf.float32, shape=dense_shape, name="demo_in")
i = tf.shape(dense_input, name="dense_input_shape")[0]  # error
# i = 1  # good
out = tf.tile(dense_input, [i, 1], name="demo_out")

I notice the code in relay:


Expr MakeTile(Expr data,
              Array<Integer> reps)

perhaps reps must be known before relay is constructed? it is an fixed attribute rather than dynamic input?

but in TensorFlow, reps might be dynamic, see:

def tile(input, multiples ...
"""
Args:
    input: A `Tensor`. 1-D or higher.
    multiples: A `Tensor`
"""

I see. this is indeed a problem with the relay operator.

@garyyyccc @MarisaKirisame I met same issue.Have you solved this problem?

1 Like

Hello, I have a very similar problem I was trying to implement deeplabv3plus using this code - https://github.com/keras-team/keras-io/blob/master/examples/vision/deeplabv3_plus.py The model compiles in tensorflow, also able to convert to onnx but finally when I run this function

mod, params = relay.frontend.from_onnx(onnx_model, shape={input_name : input_shape})

I get this error: AttributeErrorTraceback (most recent call last) /usr/local/lib/python3.6/dist-packages/tvm/runtime/object.py in getattr(self, name) 62 try: —> 63 return _ffi_node_api.NodeGetAttr(self, name) 64 except AttributeError:

tvm/_ffi/_cython/./packed_func.pxi in tvm._ffi._cy3.core.PackedFuncBase.call()

tvm/_ffi/_cython/./packed_func.pxi in tvm._ffi._cy3.core.FuncCall()

tvm/_ffi/_cython/./packed_func.pxi in tvm._ffi._cy3.core.FuncCall3()

tvm/_ffi/_cython/./base.pxi in tvm._ffi._cy3.core.CALL()

AttributeError: Traceback (most recent call last): 3: TVMFuncCall 2: _ZNSt17_Function_handlerI 1: tvm::NodeGetAttr(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*) 0: tvm::ReflectionVTable::GetAttr(tvm::runtime::Object*, tvm::runtime::String const&) const File “/home/a0230315/workarea/psdkra_git/tvm/src/node/reflection.cc”, line 109 AttributeError: relay.Call object has no attributed name_hint

During handling of the above exception, another exception occurred:

AttributeErrorTraceback (most recent call last) in ----> 1 mod, params = relay.frontend.from_onnx(onnx_model, shape={input_name : input_shape})

/usr/local/lib/python3.6/dist-packages/tvm/relay/frontend/onnx.py in from_onnx(model, shape, dtype, opset, freeze_params) 3636 # Use the graph proto as a scope so that ops can access other nodes if needed. 3637 with g: → 3638 mod, params = g.from_onnx(graph, opset) 3639 return mod, params

/usr/local/lib/python3.6/dist-packages/tvm/relay/frontend/onnx.py in from_onnx(self, graph, opset, get_output_expr) 3422 attr[“tvm_custom”][“num_outputs”] = len(node_output) 3423 → 3424 op = self._convert_operator(op_name, inputs, attr, opset) 3425 if not isinstance(op, _expr.TupleWrapper): 3426 outputs_num = 1

/usr/local/lib/python3.6/dist-packages/tvm/relay/frontend/onnx.py in _convert_operator(self, op_name, inputs, attrs, opset) 3551 sym = get_relay_op(op_name)(*inputs, **attrs) 3552 elif op_name in convert_map: → 3553 sym = convert_map[op_name](inputs, attrs, self._params) 3554 else: 3555 raise NotImplementedError(“Operator {} not implemented.”.format(op_name))

/usr/local/lib/python3.6/dist-packages/tvm/relay/frontend/onnx.py in _impl_v11(cls, inputs, attr, params) 2316 ), “One of scale or size should be passed, not both.” 2317 size = inputs[3] → 2318 known_size = params[size.name_hint].asnumpy().astype(“int32”) 2319 out_size = (known_size[2], known_size[3]) 2320 else:

/usr/local/lib/python3.6/dist-packages/tvm/runtime/object.py in getattr(self, name) 63 return _ffi_node_api.NodeGetAttr(self, name) 64 except AttributeError: —> 65 raise AttributeError("%s has no attribute %s" % (str(type(self)), name)) 66 67 def hash(self):

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

Please help !