Import Tensorflow graph into Relay (Data format "NHWC" Issue)


#1

Hi, when I load a Tensorflow graph into Relay, I encountered a “NHWC” supporting issue. I have two questions listed as follows,

  1. As an example is given in the tutorial about importing Tensorflow protobuf into Relay and it works well, I wonder how this pre-trained model is generated?

The link to the pre-trained model used in the tutorial:
https://github.com/dmlc/web-data/raw/master/tensorflow/models/InceptionV1/

  1. If I have a Tensorflow pre-trained model with default data format “NHWC”, is it possible to reuse it in TVM? If yes, how can I do that?

For instance, what should I do if I would like to use the vgg16 pre-trained model from Davi Frossard: https://www.cs.toronto.edu/~frossard/tags/vgg16/.

Thanks,


#2

Can you post the specific error you encountered? The Tensorflow frontend supports both NCHW and NHWC layouts so it should work fine, there might just be a bug in one of the ops.


#3

As an alternative, you can call from_tensorflow with layout set to NCHW. The TensorFlow frontend will do the layout conversion for you.


#4

However the conversion implies lots of transpose operators which are expensive. We did some benchmarks. In addition, since the transpose operators are not yet quantized in TVM (although is very easy to add this support) it breaks the sequence of quantized conv2d requiring int to float conversions back and fort