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.8k stars 965 forks source link

KeyError Thrown trying to convert split Op #719

Open zcin opened 5 years ago

zcin commented 5 years ago

Platform: Ubuntu 16.04

Python version: 3.6.9

Source framework with version: Tensorflow 1.4.0 with CPU

Destination framework with version: PyTorch 1.1.0 with CPU

Pre-trained model path: N/A

Running scripts: mmtoir -f tensorflow -d vgg_output -n vgg.ckpt.meta -w vgg.ckpt --dstNodeName add_16

I am using a version of the vgg16 tensorflow model that has been converted from ONNX using onnx-tf. Within this model there are split operators, at which the converter throws an error:


Traceback (most recent call last):
  File "/home/mtc/anaconda3/envs/torch-onnx/bin/mmtoir", line 10, in <module>
    sys.exit(_main())
  File "/home/mtc/anaconda3/envs/torch-onnx/lib/python3.6/site-packages/mmdnn/conversion/_script/convertToIR.py", line 192, in _main
    ret = _convert(args)
  File "/home/mtc/anaconda3/envs/torch-onnx/lib/python3.6/site-packages/mmdnn/conversion/_script/convertToIR.py", line 115, in _convert
    parser.run(args.dstPath)
  File "/home/mtc/anaconda3/envs/torch-onnx/lib/python3.6/site-packages/mmdnn/conversion/common/DataStructure/parser.py", line 22, in run
    self.gen_IR()
  File "/home/mtc/anaconda3/envs/torch-onnx/lib/python3.6/site-packages/mmdnn/conversion/tensorflow/tensorflow_parser.py", line 424, in gen_IR
    func(current_node)
  File "/home/mtc/anaconda3/envs/torch-onnx/lib/python3.6/site-packages/mmdnn/conversion/tensorflow/tensorflow_parser.py", line 548, in rename_Conv2D
    self.set_weight(source_node.name, 'weights', self.ckpt_data[W.name])
KeyError: 'split/split_dim'

Does the converter currently support converting split operators?
Any help would be appreciated, thanks!
JiahaoYao commented 5 years ago

In the onnx model, the vgg network looks like this: Screenshot from 2019-08-16 16-13-28

However, when converted to the tensorflow by onnx-tf, there are split operations. Screenshot from 2019-08-16 16-14-56

However, I think split is not supported in MMdnn now.