pfnet-research / menoh

Menoh: fast DNN inference library with multiple programming language support
MIT License
279 stars 34 forks source link

Menoh error loading model from onnx file #221

Open kmorito opened 5 years ago

kmorito commented 5 years ago

Hi I'm trying to run Menoh with the ONNX file converted from the Keras/Tensorflow model. The following error occurs when calling the menoh function "make_model_data_from_onnx". menoh invalid attribute type error: attribute type TENSOR for "value"

This ONNX file was created using mmdnn. $ mmdownload -f keras -n vgg16 -o ./ $ mmconvert -sf keras -iw imagenet_vgg16.h5 -df onnx -om imagenet_vgg16.onnx

OS: Windows 10 Keras 2.2.2 Tensorflow 1.8.0 onnx-tf 1.2.1 Menoh 1.2.0

For the following file It works. wget('https://preferredjp.box.com/shared/static/o2xip23e3f0knwc5ve78oderuglkf2wt.onnx', './data/vgg16.onnx')

What should I check?

Kind

okdshin commented 5 years ago

Hi @kmorito It seems Constant operator is contained in imagenet_vgg16.onnx. Menoh 1.2.0 doesn't support Constant operator. Now PR for Constant is created https://github.com/pfnet-research/menoh/pull/222 . It will be merged soon. Also you can use this feature of ONNX official to delete Constant node.

kmorito commented 5 years ago

Hi @okdshin Thank you for your reply.

I tried #222 , but the following error occured. menoh unsupported operator error: Flatten

Menoh doesn't support Flatten node ? Is it as intended?

Kind

okdshin commented 5 years ago

Sorry for my late reply. Flatten node is not supported yet. I estimate Flatten is used to connect the last fc layer in keras's VGG16. Chainer's VGG16 uses Reshape instead of Flatten and Menoh merely ignores the Reshape node. I think you can delete flatten node from the model. Sorry for inconvinience. I will add Flatten node.

kmorito commented 5 years ago

Hi @okdshin

It's working! This is well parallelized internally. That's good. Thank you for your help. I hope to be supported some other effective node. For example PReLU or so... :)

Kind

okdshin commented 5 years ago

Hi @kmorito . Just FYI, now chainer-compiler's menoh API is available. It is compatible to menoh and it supports more ops (including PRelu) and more backends (Intel GPU, CUDA). https://github.com/pfnet-research/chainer-compiler/tree/master/menoh