Onnx: check_graph that worked in onnx 1.5 is failing in 1.7

Created on 29 Jun 2020  路  4Comments  路  Source: onnx/onnx

Bug Report

Describe the bug

When upgrading from onnx 1.5 to onnx 1.7 I noticed the following failure (see code below)

System information

  • OS Platform and Distribution (e.g. Linux Ubuntu 16.04): Mac OS
  • ONNX version (e.g. 1.7): 1.7
  • Python version: 3.6
  • Protobuf version: 3.12.2

Reproduction instructions

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 }

Expected behavior

Should this succeed (it does in onnx 1.5)? Or is this a regression?

documentation question

All 4 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chiehpower picture chiehpower  路  4Comments

fdwr picture fdwr  路  3Comments

ezyang picture ezyang  路  3Comments

cdeterman picture cdeterman  路  5Comments

kbullis picture kbullis  路  4Comments