When upgrading from onnx 1.5 to onnx 1.7 I noticed the following failure (see code below)
import onnx
from onnx import helper, checker
from onnx.helper import make_tensor_value_info
nodes = []
inputs = []
outputs = []
input = onnx.helper.make_tensor_value_info("input1", 1, (2, 3, 20, 20))
node = onnx.helper.make_node('Pad', inputs=['input1'], outputs=["pad0"], mode='constant', value=0.0, pads=[0, 0, 0, 0, 0, 0, 0, 0],name="pad0")
another_node = onnx.helper.make_node('LpPool', ['pad0'], ['pooling0'], p=1, kernel_shape=(4,5), pads=[0, 0, 0, 0], strides=(1, 1), name="pooling0")
output = make_tensor_value_info(name="pooling0",elem_type=1,shape=(2, 3, 17, 16))
nodes.append(node)
nodes.append(another_node)
inputs.append(input)
outputs.append(output)
graph = helper.make_graph(nodes,"mxnet_converted_model",inputs,outputs)
checker.check_graph(graph)
The error I'm getting in onnx 1.7 is the following:
Traceback (most recent call last):
File "bug_repro_2.py", line 21, in <module>
checker.check_graph(graph)
File "/opt/anaconda3/envs/p36/lib/python3.6/site-packages/onnx/checker.py", line 54, in checker
proto.SerializeToString(), ctx)
onnx.onnx_cpp2py_export.checker.ValidationError: Node (pad0) has input size 1 not in range [min=2, max=3].
==> Context: Bad node spec: input: "input1" output: "pad0" name: "pad0" op_type: "Pad" attribute { name: "mode" s: "constant" type: STRING } attribute { name: "pads" ints: 0 ints: 0 ints: 0 ints: 0 ints: 0 ints: 0 ints: 0 ints: 0 type: INTS } attribute { name: "value" f: 0 type: FLOAT }
Should this succeed (it does in onnx 1.5)? Or is this a regression?
Hi @ma-hei,
Similar to https://github.com/onnx/onnx/issues/2423#issuecomment-547692700?
I encountered the same error on my Mac. (onnx 1.7)
The input of Pad operator has been changed by newer ONNX. Modify them should work.
Yep. @jcwchen already gave the correct answer.
Just wanna to add one more cent: the error message "Node (pad0) has input size 1 not in range [min=2, max=3]" is trying to tell that the node using the op "Pad" must have 2-3 inputs (there're optional inputs), while only 1 is given.
I'm removing the "bug" label, let me know if that should not be done.
thanks @jcwchen and @linkerzhang