Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use mmdnn to transform network with custom layer from pytorch to IR #709

Open
hnuhchen opened this issue Aug 5, 2019 · 1 comment
Open

Comments

@hnuhchen
Copy link

hnuhchen commented Aug 5, 2019

Platform (like ubuntu 16.04/win10):
centos6
Python version:
2.7.5
Source framework with version (like Tensorflow 1.4.1 with GPU):
pytorch0.4.0 CPU
Destination framework with version (like CNTK 2.3 with GPU):
IR(eventually caffe) CPU
Pre-trained model path (webpath or webdisk path):

Running scripts:

Hello, everyone.
I want to transform network from pytorch to caffe. First i should transform it from pytorch to IR. In the network, there are basic layers like conv2d,pooling2d,fc and a custom layer written by myself. I generated the module file and transformed it from pytorch to IR. But an error occured, it seemed like that it was problem about torch.jit.
Detailed information:
Traceback (most recent call last): File "demo_pt2caffe.py", line 56, in <module> test = Convert('/mnt/chenhui/code/mmdnn_custom/tests/model/net.pth'); File "demo_pt2caffe.py", line 11, in __init__ self.PytorchParse() File "demo_pt2caffe.py", line 30, in PytorchParse parser = PytorchParser(self.src_model_path[0], [1, 28, 28]) File "/usr/local/lib/python2.7/site-packages/mmdnn/conversion/pytorch/pytorch_parser.py", line 85, in __init__ self.pytorch_graph.build(self.input_shape) File "/usr/local/lib/python2.7/site-packages/mmdnn/conversion/pytorch/pytorch_graph.py", line 125, in build trace, output = torch.jit.get_trace_graph(self.model, (dummy_input, )) File "/usr/local/lib/python2.7/site-packages/torch/jit/__init__.py", line 255, in get_trace_graph return LegacyTracedModule(f, nderivs=nderivs)(*args, **kwargs) File "/usr/local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 491, in __call__ result = self.forward(*input, **kwargs) File "/usr/local/lib/python2.7/site-packages/torch/jit/__init__.py", line 288, in forward out = self.inner(*trace_inputs) File "/usr/local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 489, in __call__ result = self._slow_forward(*input, **kwargs) File "/usr/local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 479, in _slow_forward result = self.forward(*input, **kwargs) File "/mnt/chenhui/code/mmdnn_custom/tests/mnist_test.py", line 67, in forward x = self.abc(x, self.abc) File "/usr/local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 489, in __call__ result = self._slow_forward(*input, **kwargs) File "/usr/local/lib/python2.7/site-packages/torch/nn/modules/module.py", line 466, in _slow_forward input_vars = tuple(torch.autograd.function._iter_tensors(input)) File "/usr/local/lib/python2.7/site-packages/torch/autograd/function.py", line 275, in _iter for var in _iter(o): File "/usr/local/lib/python2.7/site-packages/torch/autograd/function.py", line 284, in _iter if condition_msg else "")) ValueError: Auto nesting doesn't know how to process an input object of type mnist_test.ABC. Accepted types: Tensors, or lists/tuples of them

So, can you tell me how to solve this problem? And how to transfrom network with customer layers from pytorch to IR?

Thank you very much.

@rainLiuplus
Copy link
Collaborator

Hi @hchnu. It looks like this is a problem related to PyTorch. Maybe this will help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants