Open nickfraser opened 4 years ago
Note, I have a workaround which appears to work, replacing view
with flatten
here: https://github.com/NVIDIA/DeepLearningExamples/blob/4e00153ab5c4963c0505c6cebfc07730a42ef7dc/PyTorch/Classification/RN50v1.5/image_classification/resnet.py#L201
However, the original issue remains.
Hi @nickfraser , thanks for your feedback, it seems torch cannot inference outputshape in some special cases. We will look into this issue.
@XiaoXYe do you have updates on this issue?
I have committed some code. If pytorch cannot inference the outputshape, MMdnn will raise a warning and set the outputshape to None in IR json file. You can set the outputshape manually in json file but actually outputshape is not necessary in most cases.
Platform (like ubuntu 16.04/win10): Ubuntu 16.04
Python version: 3.6.8
Source framework with version (like Tensorflow 1.4.1 with GPU): PyTorch 1.5.1
Destination framework with version (like CNTK 2.3 with GPU): MMIR
Pre-trained model path (webpath or webdisk path): Nvidia's ResNet-18 example
Running scripts:
PYTHONPATH=`readlink -f .` mmtoir -f pytorch -in resnet18/model_best_only.pth -o resnet18-mmir/ --inputShape 3,224,224
Note, the current working directory is the path given in the link to the model path. Also, the model 'model_best_only.pth' has been updated to save the entire model, not just the state dict as specified in the PyTorch instructions. I'm using the current master branch of MMdnn.
When running this script, the original output is:
After some investigation, I can trace the issue back to this regex which returns the string
', scope: ResNet'
when the input string is'%191 : Tensor = onnx::Constant[value={0}](), scope: ResNet'
.All other layers appear to be parsed correctly. Printing both
node.__str__()
andoutput_shape_str
reveals the following:What output shape should there be for this constant tensor? Should it be '0'?