Open Kocha opened 4 years ago
Hi
I stumbled upon the same error when I tried to create a nngen model from onnx, and I think I have figured out the cause of this error, so would like to share my conclusion here.
My nngen version: 1.3.0
This error is caused by a lack of supporting onnx operators in nngen. In my case I need the Reszie operator. In @Kocha 's case, it needs Reszie and Split. To resolve this issue, an additional implementation for the operators is needed. If you would like to use Faster-RCNN(ResNet50) model in your project, I recommend opening a issue for a support for these operators.
The model I tried was a PyTorch implementation of Fast-SCNN; I first converted the weights provided by the repository to onnx, and using that onnx file I tried to convert it to a nngen model, which gave me this error
Traceback (most recent call last):
File "onnx_to_nngen.py", line 28, in <module>
default_bias_dtype=bias_dtype,)
File "C:\Users\nagak\Anaconda3\envs\nngen\lib\site-packages\nngen\onnx\__init__.py", line 296, in from_onnx
default_operator_dtype)
File "C:\Users\nagak\Anaconda3\envs\nngen\lib\site-packages\nngen\onnx\__init__.py", line 407, in _to_constants
dtype=dtype, shape=shape, name=name)
File "C:\Users\nagak\Anaconda3\envs\nngen\lib\site-packages\nngen\storage.py", line 30, in __init__
dtype=dtype, shape=shape, name=name)
File "C:\Users\nagak\Anaconda3\envs\nngen\lib\site-packages\nngen\basic_types.py", line 359, in __init__
_Storage.__init__(self, dtype=dtype, shape=shape, name=name, is_input=False)
File "C:\Users\nagak\Anaconda3\envs\nngen\lib\site-packages\nngen\basic_types.py", line 335, in __init__
_Numeric.__init__(self, dtype=dtype, shape=shape, name=name)
File "C:\Users\nagak\Anaconda3\envs\nngen\lib\site-packages\nngen\basic_types.py", line 57, in __init__
raise ValueError("shape contains '0': %s" % str(shape))
ValueError: shape contains '0': (0,)
After some digging around in the code, I found out that this value error pointed to an constant operator which contained no value, and was also an input for the scale parameter for Resize.
I assume that when PyTorch tries to convert the model to onnx, the default parameters of F.inerpolate
layers are automatically converted to onnx constant operators, despite the default parameter is set to None
, hence causing this issue.
I tried Faster-RCNN(ResNet50) model.
But,
ValueError: shape contains '0': (0,)
error message was displayed atng.from_onnx
.Do you know the cause of the error?