[vta] [pynq] [tensorflow] Running TensorFlow models on PYNQ FPGA

Hello, my goal is to simply run a CNN image recognition model built using TensorFlow on PYNQ FPGA using the tvm/vta stack.

More specifically, I’m working with the Inception V1 model found in this tutorial.

So far I have this:

with tf.gfile.FastGFile(model_path, 'rb') as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())
    graph = tf.import_graph_def(graph_def, name='')
    # call the utility to import the graph definition into default graph.
    graph_def = tf_testing.ProcessGraphDefParam(graph_def)
    # add shapes to the graph
    with tf.Session() as sess:
        graph_def = tf_testing.AddShapesToGraphDef(sess, 'softmax')

sym, params = nnvm.frontend.from_tensorflow(graph_def)
graph = nnvm.graph.create(sym)
graph = vta.graph.clean_cast(graph)
graph = vta.graph.clean_conv_fuse(graph)

which produces this error:

Traceback (most recent call last):
  File "tvm_classifier.py", line 134, in <module>
generate_graph(graph_def)
  File "tvm_classifier.py", line 63, in generate_graph
graph = vta.graph.clean_cast(graph)
  File "/home/youn/tvm/vta/python/vta/graph.py", line 208, in clean_cast
elif op_name == "conv2d" and attrs["out_dtype"] == "int32":
KeyError: 'out_dtype'

I’m a beginner so any help would be appreciated. I’m using TensorFlow version 1.6.0 If this is relevant (newest version also produces same error).

I tried with tensorflow 1.12, antlr4 latest, altr4 runtime, llvm latest.
It worked for me like that.
I encountered with errors for tensorflow versions above 1.13

I see, this is an issue with the quantization pass that is not pre-processing the graph properly to match the supported VTA types. This is an issue with the quantization pass for VTA which is too rigid and will break easily on new models.

I think that the quantization, and graph partitioning pass will need to be re-written to support accelerators more broadly including the ones of the likes of VTA. Lots of these elements are discussed here: Bring Your Own Codegen to TVM