[TFLite] Tutorial Compile TFLite Models occur AttributeError: 'SubGraph' object has no attribute 'InputsAsNumpy'


I follow the tutorial: Compile TFLite Models, and get error AttributeError: 'SubGraph' object has no attribute 'InputsAsNumpy'

  • Python: 3.6.7 (anaconda)
  • flatc: 1.7.0
  • tflite:
    wget https://raw.githubusercontent.com/tensorflow/tensorflow/r1.12/tensorflow/contrib/lite/schema/schema.fb
    flatc --python schema.fbs

(I have also tried tensorflow r1.13)

I check the source code of tflite generated by flatc, there is no InputsAsNumpy in SubGraph.py.

from tvm import relay
func, params = relay.frontend.from_tflite(tflite_model,
                                          shape_dict={input_tensor: input_shape},
                                          dtype_dict={input_tensor: input_dtype})

The error is

File "xxxx/tvm/tvm/python/tvm/relay/frontend/tflite.py", line 609, in from_tflite
    model_inputs = subgraph.InputsAsNumpy()

I think the tutorial is definitely right, but I can’t find where I make a mistake……


I have confirmed. The issue is flatc version is too low. Please use the latest flatc version. For example, 1.9 or 1.10. Go to https://github.com/google/flatbuffers to find how to build.


Thanks for your prompt answer. And Your tutorial and code help me a lot, a great job!