I am trying to convert a SSD model from the Object Detection of Tensorflow Models into tvm.
And I got an error <class 'tvm.relay.expr.Call'> has no attribute name_hint when converting a Slice operation.
It seems that one input node of the Slice operation is an ‘ExpandDims’ operation, which is converted into tvm.relay.expr.Call object. And when the def _slice() function for converting Slice operation calsl _get_list_param to get size, it crashes, since _get_list_param can not handle ``tvm.relay.expr.Call` object
So, any suggestion to fix such problems? I can only think of adjusting the Tensorflow graph_def before relay.frontend.from_tensorflow by replacing the ExpandDims nodes with Const nodes? Is there some simpler way?
Recently, we’ve been solving this by inferring the value of ExpandDims by running the graph up until that point and using that returned value as the input. As an example, check out how we get axes in _transpose:
I have changed the def _get_param function since def _slice seems to be not the only operation need to handle tvm.relay.expr.Call input. Although the error before seems to be fixed, another bug comes out. When a reshape node with two inputs, which are an add operation node and a concatv2 node, is converted, there comes out antoher error info:
Check failed: begin_v < end_v (0 vs. 0) : strided_slice get empty slice at axis 0
This is the url of the graph_def I want to convert, which can be loaded by
def load_graph_def(graph_def_path):
infer_graph_def = tf.GraphDef()
with open(graph_def_path, 'rb') as f:
infer_graph_def.ParseFromString(f.read())
return infer_graph_def
Perhaps one attr of _impl returns an empty array. But I remember they have solved this problem. Try to get the latest TVM code and run it again.
If it still not works, you can try to add something like this into the def _impl before _op.strided_slice
# handle situations when return empty constant
input0_np = _infer_value(inputs[0], params).asnumpy()
input0_shape = input0_np.shape
for input_dim_i, begin_i, size_i in zip(input0_shape, begin, size):
# when one size_i == 0, return empty constant
if size_i == 0:
return _expr.const([], dtype=input0_np.dtype)
# when begin index larger than the dimension of inputs[0]
if begin_i >= input_dim_i:
return _expr.const([], dtype=input0_np.dtype)
Well, I can only guess from strided_slice get empty slice at axis 0 that some attribute maybe empty. Perhaps you can try to run _infer_value for every input or attribute to see it.