microsoft / MMdnn

MMdnn is a set of tools to help users inter-operate among different deep learning frameworks. E.g. model conversion and visualization. Convert models between Caffe, Keras, MXNet, Tensorflow, CNTK, PyTorch Onnx and CoreML.
MIT License
5.79k stars 964 forks source link

Tensorflow to IR rep not working - `TensorflowEmitter has not supported operator [BiasAdd] with name [dense/BiasAdd].` #610

Open aruna-ram opened 5 years ago

aruna-ram commented 5 years ago

Platform (like ubuntu 16.04/win10): kubuntu 18.10

Python version: 3.6

Source framework with version (like Tensorflow 1.4.1 with GPU): tensorflow 1.12.0 with CPU

Destination framework with version (like CNTK 2.3 with GPU): ONNX with CPU

Pre-trained model path (webpath or webdisk path): Using own simple feed forward model [relu_MNIST_forissue.txt](https://github.com/Microsoft/MMdnn/files/2945398/relu_MNIST_forissue.

OUTLINE OF ISSUE: Conversion from tensorflow to IR rep is not working.

I have made a simple feed forward network will Relu activations to classify MNIST, with only weights no biases (see relu_MNIST_forissue.txt). I saved as ckpt, ckpt.meta files.

I had previously used mmdnn to convert from tensorflow ckpt using the following: mmconvert -sf tensorflow -in /home/aruna/projects_code/relu_MNIST.ckpt.meta -iw /home/aruna/projects_code/relu_MNIST.ckpt --dstNodeName dense_3/Relu -df onnx -om /home/aruna/projects_code/relu_MNIST.onnx

This worked absolutely fine, the terminal output for the conversion (that worked):

/projects_code/relu_MNIST_ir Parse file [/home/aruna/projects_code/relu_MNIST.ckpt.meta] with binary format successfully. Tensorflow model file [/home/aruna/projects_code/relu_MNIST.ckpt.meta] loaded successfully. Tensorflow checkpoint file [/home/aruna/projects_code/relu_MNIST.ckpt] loaded successfully. [17] variables loaded. Tensorflow has not supported operator [VarHandleOp] with name [dense/kernel]. Tensorflow has not supported operator [VarHandleOp] with name [dense/bias]. Tensorflow has not supported operator [VarHandleOp] with name [dense_1/kernel]. Tensorflow has not supported operator [VarHandleOp] with name [dense_1/bias]. Tensorflow has not supported operator [VarHandleOp] with name [dense_2/kernel]. Tensorflow has not supported operator [VarHandleOp] with name [dense_2/bias]. Tensorflow has not supported operator [VarHandleOp] with name [dense_3/kernel]. Tensorflow has not supported operator [VarHandleOp] with name [dense_3/bias]. Tensorflow has not supported operator [ReadVariableOp] with name [dense/MatMul/ReadVariableOp]. Tensorflow has not supported operator [ReadVariableOp] with name [dense/BiasAdd/ReadVariableOp]. Tensorflow has not supported operator [ReadVariableOp] with name [dense_1/MatMul/ReadVariableOp]. Tensorflow has not supported operator [ReadVariableOp] with name [dense_1/BiasAdd/ReadVariableOp]. Tensorflow has not supported operator [ReadVariableOp] with name [dense_2/MatMul/ReadVariableOp]. Tensorflow has not supported operator [ReadVariableOp] with name [dense_2/BiasAdd/ReadVariableOp]. Tensorflow has not supported operator [ReadVariableOp] with name [dense_3/MatMul/ReadVariableOp]. // Tensorflow has not supported operator [ReadVariableOp] with name [dense_3/BiasAdd/ReadVariableOp]. IR network structure is saved as [/home/aruna/projects_code/relu_MNIST_ir.json]. IR network structure is saved as [/home/aruna/projects_code/relu_MNIST_ir.pb]. IR weights are saved as [/home/aruna/projects_code/relu_MNIST_ir.npy].

However trying the above again, with a different version of the checkpoint files doesn't extract the structure of the network correctly - it leaves out connections between layers. The only thing I think has changed between the versions is that the node names have capitals - e.g. dense/Relu in this graph rather than dense/relu for the above graph.

This is the output for the incorrect IR conversion:

Parse file [/home/aruna/projects_code/relu_MNIST_V4.ckpt.meta] with binary format successfully. Tensorflow model file [/home/aruna/projects_code/relu_MNIST_V4.ckpt.meta] loaded successfully. Tensorflow checkpoint file [/home/aruna/projects_code/relu_MNIST.ckpt] loaded successfully. [17] variables loaded. 2019-03-08 10:01:09.742964: I tensorflow/tools/graph_transforms/transform_graph.cc:317] Applying fold_constants 2019-03-08 10:01:09.776952: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 2019-03-08 10:01:09.781310: I tensorflow/core/common_runtime/process_util.cc:69] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance. TensorflowEmitter has not supported operator [VarHandleOp] with name [dense/kernel]. TensorflowEmitter has not supported operator [VarHandleOp] with name [dense/bias]. TensorflowEmitter has not supported operator [VarHandleOp] with name [dense_1/kernel]. TensorflowEmitter has not supported operator [VarHandleOp] with name [dense_1/bias]. TensorflowEmitter has not supported operator [VarHandleOp] with name [dense_2/kernel]. TensorflowEmitter has not supported operator [VarHandleOp] with name [dense_2/bias]. TensorflowEmitter has not supported operator [VarHandleOp] with name [dense_3/kernel]. TensorflowEmitter has not supported operator [VarHandleOp] with name [dense_3/bias]. TensorflowEmitter has not supported operator [ReadVariableOp] with name [dense/MatMul/ReadVariableOp]. TensorflowEmitter has not supported operator [ReadVariableOp] with name [dense/BiasAdd/ReadVariableOp]. TensorflowEmitter has not supported operator [ReadVariableOp] with name [dense_1/MatMul/ReadVariableOp]. TensorflowEmitter has not supported operator [ReadVariableOp] with name [dense_1/BiasAdd/ReadVariableOp]. TensorflowEmitter has not supported operator [ReadVariableOp] with name [dense_2/MatMul/ReadVariableOp]. TensorflowEmitter has not supported operator [ReadVariableOp] with name [dense_2/BiasAdd/ReadVariableOp]. TensorflowEmitter has not supported operator [ReadVariableOp] with name [dense_3/MatMul/ReadVariableOp]. TensorflowEmitter has not supported operator [ReadVariableOp] with name [dense_3/BiasAdd/ReadVariableOp]. TensorflowEmitter has not supported operator [BiasAdd] with name [dense/BiasAdd]. TensorflowEmitter has not supported operator [BiasAdd] with name [dense_1/BiasAdd]. TensorflowEmitter has not supported operator [BiasAdd] with name [dense_2/BiasAdd]. TensorflowEmitter has not supported operator [BiasAdd] with name [dense_3/BiasAdd]. IR network structure is saved as [/home/aruna/projects_code/relu_MNIST_ir_V4.json]. IR network structure is saved as [/home/aruna/projects_code/relu_MNIST_ir_V4.pb]. IR weights are saved as [/home/aruna/projects_code/relu_MNIST_ir_V4.npy].

Clearly the issue is due to: TensorflowEmitter has not supported operator [BiasAdd] with name [dense/BiasAdd].

But i cannot understand why the conversion worked one time and is now not working for a very simple operation (BiasAdd)?

The IR representations (the correct and incorrect) (which can be visualised using the mmdnn tool) can be compared - these are the files:

  1. CORRECT IR REP - relu_MNIST_ir.tar.gz

  2. INCORRECT IR REP - relu_MNIST_ir_V4.tar.gz

Thank you for your time! If you require further information do ask.

lswgh commented 4 years ago

Hi,aruna-ram. did you know how to see the IR representations (the correct and incorrect) ?can you give me some tricks of it? Thanks.