Def _slice from Relay Tensorflow report has no attribute name_hint error

Hi:

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?

Thanks a lot

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:

try:
    axes = _get_list_param(params, inputs[1])
except (IndexError, KeyError, AttributeError):
    axes = _infer_value_simulated(inputs[1], params).asnumpy()

Feel free to send a PR if this fix works!

Thanks a lot. I will definitely try it.

Hi jonso:

I have changed

def _get_param(params, input_node):
    if isinstance(input_node, _expr.Constant):
        return np.atleast_1d(input_node.data.asnumpy())
    return params.pop(input_node.name_hint).asnumpy()

into

def _get_param(params, input_node):
    if isinstance(input_node, _expr.Constant):
        return np.atleast_1d(input_node.data.asnumpy())
    elif isinstance(input_node, _expr.Call):
        return _infer_value_simulated(input_node, params).asnumpy()[0]
    return params.pop(input_node.name_hint).asnumpy()

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

Thanks.