[Tensorflow][CropAndResize] Potential bug or limitation -> AttributeError: '<class 'tvm.relay.expr.Call'>' object has no attribute 'name_hint'



I have an isssue with a model that has a CropAndResize operator related to the processing of the boxes input. The error is as following:

Traceback (most recent call last):
  File "tvm_eval_2nd_half.py", line 247, in <module>
    mod, params = tvm_eval_non_tuned()
  File "tvm_eval_2nd_half.py", line 75, in tvm_eval_non_tuned
  File "/home/tvm/tvm/python/tvm/relay/frontend/tensorflow.py", line 2441, in from_tensorflow
    mod, params = g.from_tensorflow(graph, layout, shape, outputs)
  File "/home/tvm/tvm/python/tvm/relay/frontend/tensorflow.py", line 2085, in from_tensorflow
    op = self._convert_operator(node.op, inputs, attr, graph)
  File "/home/tvm/tvm/python/tvm/relay/frontend/tensorflow.py", line 2404, in _convert_operator
    sym = convert_map[op_name](inputs, attrs, self._params)
  File "/home/tvm/tvm/python/tvm/relay/frontend/tensorflow.py", line 504, in _impl
    boxes = params.pop(inputs[1].name_hint).asnumpy().tolist()
  File "/home/tvm/tvm/python/tvm/_ffi/_ctypes/node.py", line 75, in __getattr__
    "'%s' object has no attribute '%s'" % (str(type(self)), name))
AttributeError: '<class 'tvm.relay.expr.Call'>' object has no attribute 'name_hint'

I have tried to add AtributteError to the except but still it does not work as I get the following error:

AssertionError: All inputs to infer must be available in params.

@yongwww @srkreddy1238 maybe you can comment on this since you added this operator recently



It seems that only in the inputs are constants it works. If the boxes input comes from a placeholder or another operator it fails while processing the crop_and_resize operator in the Tensorflow frontend.

I am currently debugging the Tensorflow frontend but any hint would be highly appreciated!


After having a look at the test_forward.py script and the generated Relay IR, I see that TVM generates one image.resize op for every box. In other words, the number of boxes must be known a compile time.

Is this right? If so, how to use it then in models where the number of boxes is not known or not constant?

@vinx13 Maybe you can also give me hint about this?



@yongwww @srkreddy1238 @vinx13 Any ideas about this?

The only way that I was able to properly compile my model with CropAndResize was to remove the following assertion.

The test case located at test_forward.py works since all inputs given are constants. As soon as you use a Placeholder or another operator as input then you hit the error mentioned above.

The following is a minimal test model that also fails.

    image = tf.placeholder(tf.float32, shape=(1, 24, 42, 64), name='image')
    boxes = tf.placeholder(tf.float32, shape=(1, 4), name='boxes')
    box_ind = tf.zeros(shape=tf.shape(boxes)[0], dtype=tf.int32)
    crop_size = [4, 4]
    crop = tf.image.crop_and_resize(image, boxes, box_ind=box_ind, crop_size = crop_size, name='crop')