You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/05/09 01:34:14 UTC

[GitHub] [incubator-mxnet] nicklhy commented on issue #14916: Failed to convert pytorch networks with "torch.view()" to mxnet with ONNX

nicklhy commented on issue #14916: Failed to convert pytorch networks with "torch.view()" to mxnet with ONNX
URL: https://github.com/apache/incubator-mxnet/issues/14916#issuecomment-490709737
 
 
   After a deeper look at the source code. I noticed the convert function for "reshape" tries to read the "shape" values from the graph params dict at [python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L462](https://github.com/apache/incubator-mxnet/blob/2e03e9ff07b4c34cd165071aeb785db14b965ade/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L462).
   
   ```
   reshape_shape = list(proto_obj._params[inputs[1].name].asnumpy())
   ```
   
   However, the "shape" tensor in ONNX has never been read and saved in that params dict. I managed to solve this problem by adding two lines listed below in [python/mxnet/contrib/onnx/onnx2mx/import_onnx.py](https://github.com/nicklhy/incubator-mxnet/commit/ed9651f4b087ed9e34fd1718302a5737ea3a1864) when performing the operator conversion
   ```
   if op_name == 'Constant':
       self._params[mxnet_sym.name] = self._parse_array(node.attribute[0].t)
   ```
   This may not work in the dynamic reshape case.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services