onnx / onnx-tensorflow

Tensorflow Backend for ONNX
Other
1.27k stars 296 forks source link

Conversion error : Assign is not implemented. #376

Open WilliamTambellini opened 5 years ago

WilliamTambellini commented 5 years ago

Describe the bug TF to onnx conversion error.

To Reproduce install/download gpt-2 : https://github.com/openai/gpt-2 Try to convert models/117M/model.ckpt.data-00000-of-00001 (rename to model.ckpt)

$ onnx-tf convert -t onnx -i model.ckpt -o /tmp/gpt2.onnx /usr/lib/python3.6/site-packages/onnx_tf/common/init.py:87: UserWarning: FrontendHandler.get_outputs_names is deprecated. It will be removed in future release.. Use node.outputs instead. warnings.warn(message) INFO:root:Start converting tf pb to onnx pb: INFO:tensorflow:Restoring parameters from model.ckpt INFO:tensorflow:Restoring parameters from model.ckpt WARNING:tensorflow:From /usr/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py:249: FastGFile.init (from tensorflow.python.platform.gfile) is deprecated and will be removed in a future version. Instructions for updating: Use tf.gfile.GFile. WARNING:tensorflow:From /usr/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py:249: FastGFile.init (from tensorflow.python.platform.gfile) is deprecated and will be removed in a future version. Instructions for updating: Use tf.gfile.GFile. INFO:tensorflow:Restoring parameters from model.ckpt INFO:tensorflow:Restoring parameters from model.ckpt INFO:tensorflow:Froze 148 variables. INFO:tensorflow:Froze 148 variables. INFO:tensorflow:Converted 148 variables to const ops. INFO:tensorflow:Converted 148 variables to const ops. Traceback (most recent call last): File "/usr/bin/onnx-tf", line 10, in sys.exit(main()) File "/usr/lib/python3.6/site-packages/onnx_tf/cli.py", line 19, in main return onnx_tf.converter.main(args[1:]) File "/usr/lib/python3.6/site-packages/onnx_tf/converter.py", line 23, in main convert({k: v for k, v in vars(args).items() if v is not None}) File "/usr/lib/python3.6/site-packages/onnx_tf/converter.py", line 229, in convert onnx_model = frontend.tensorflow_graph_to_onnx_model(graph_def, kwargs) File "/usr/lib/python3.6/site-packages/onnx_tf/frontend.py", line 175, in tensorflow_graph_to_onnx_model graph_def, output_nodes, opset, graph_name, ignore_unimplemented) File "/usr/lib/python3.6/site-packages/onnx_tf/frontend.py", line 104, in tensorflow_graph_to_onnx_graph domain=None if node.domain in handlers else node.domain) File "/usr/lib/python3.6/site-packages/onnx_tf/common/exception.py", line 31, in call super(OpUnimplementedException, self).call(op, version, domain) File "/usr/lib/python3.6/site-packages/onnx_tf/common/exception.py", line 13, in call raise self._func(self.get_message(*args, **kwargs)) NotImplementedError: Assign is not implemented.

A self-contained piece of code that can demonstrate the problem is required. $ onnx-tf convert -t onnx -i models/117M/model.ckpt -o /tmp/gpt2.onnx

Python, ONNX, ONNX-TF, Tensorflow version

fumihwh commented 5 years ago

@WilliamTambellini First, Assign is not a onnx operator. This problem due to you convert from ckpt. So I suggest you to freeze your inference pb then convert again.

TE-WoodyLi commented 5 years ago

@fumihwh I've seen the code, it seems that ckpt has been frozen before do converting. Is this part not finished? I checked the node information is strange, two input and one output for "Assing" operator. Any one knows that?

fumihwh commented 5 years ago

@TE-WoodyLi In my experience, freeze_graph.freeze_graph get little different graph than tf.graph_util.convert_variables_to_constants.