以下 tensorflow 模型到 UFF 的转换在 tf.matmul 操作时失败:
x = tf.placeholder(tf.float32, shape=[None, 1, 1, 100], name="input_x")
y = tf.placeholder(tf.float32, shape=[None, 1, 200, 3], name="input_y")
net = layers.conv2d(x, 100, [1,1], data_format='NHWC')
net = layers.conv2d(net, 200, [1,1], data_format='NHWC')
output = tf.matmul(net, y, name="output")
错误:
Warning: No conversion function registered for layer: BatchMatMul yet.
Converting as custom op BatchMatMul output
name: "output"
op: "BatchMatMul"
input: "Conv_1/Relu"
input: "input_y"
attr {
key: "T"
value {
type: DT_FLOAT
}
}
attr {
key: "adj_x"
value {
b: false
}
}
attr {
key: "adj_y"
value {
b: false
}
}
Traceback (most recent call last):
File "simple_mlp.py", line 69, in <module>
tf_graph_to_uff(frozen_graph, output_name_list)
File "simple_mlp.py", line 64, in tf_graph_to_uff
text=True)
File "/usr/local/lib/python2.7/dist- packages/uff/converters/tensorflow/conversion_helpers.py", line 75, in from_tensorflow
name="main")
File "/usr/local/lib/python2.7/dist- packages/uff/converters/tensorflow/converter.py", line 64, in convert_tf2uff_graph
uff_graph, input_replacements)
File "/usr/local/lib/python2.7/dist- packages/uff/converters/tensorflow/converter.py", line 51, in convert_tf2uff_node
op, name, tf_node, inputs, uff_graph, tf_nodes=tf_nodes)
File "/usr/local/lib/python2.7/dist- packages/uff/converters/tensorflow/converter.py", line 28, in convert_layer
fields = cls.parse_tf_attrs(tf_node.attr)
File "/usr/local/lib/python2.7/dist- packages/uff/converters/tensorflow/converter.py", line 177, in parse_tf_attrs
for key, val in attrs.items()}
File "/usr/local/lib/python2.7/dist- packages/uff/converters/tensorflow/converter.py", line 177, in <dictcomp>
for key, val in attrs.items()}
File "/usr/local/lib/python2.7/dist- packages/uff/converters/tensorflow/converter.py", line 172, in parse_tf_attr_value
return cls.convert_tf2uff_field(code, val)
File "/usr/local/lib/python2.7/dist- packages/uff/converters/tensorflow/converter.py", line 146, in convert_tf2uff_field
return TensorFlowToUFFConverter.convert_tf2numpy_dtype(val)
File "/usr/local/lib/python2.7/dist- packages/uff/converters/tensorflow/converter.py", line 74, in convert_tf2numpy_dtype
return np.dtype(dt[dtype])
TypeError: list indices must be integers, not AttrValue
在 matmul 之后,我的实际网络有更多的 conv2d 操作。所以我可以想到以下选项:
使用 TensorRT c++ API 重写整个网络。(类似于 sampleMNISTAPI 示例)
将网络分成两个 UFF 文件,然后以某种方式将它们组合成一个网络。我不确定这个选项有多可行。
还有其他更好的选择吗?