Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[preprocess] Pad is not folded in Conv when opset_import is > 20 #23973

Open
Johansmm opened this issue Mar 10, 2025 · 0 comments
Open

[preprocess] Pad is not folded in Conv when opset_import is > 20 #23973

Johansmm opened this issue Mar 10, 2025 · 0 comments

Comments

@Johansmm
Copy link
Contributor

Describe the issue

Preprocess does not fold 'Pad' in 'Conv' when model has an opset version higher than 20.

To reproduce

def test_pad(op_version=22):
    path = "opt_model.onnx"
    model = onnx.parser.parse_model(
        """
        <ir_version: 9, opset_import: ["": {op_version}]>
        agraph (float[1, 3, 10, 10] X) => (float[1, ?, ?, ?] Y){{
            pad_values = Constant<value_ints=[0,0,1,1,0,0,1,1]>()
            pad = Pad(X, pad_values)
            Y = Conv(pad, W)
        }}
        """.format(
            op_version=op_version
        )
    )
    w = onnx.numpy_helper.from_array(np.ones((3, 3, 3, 3), "float32"), "W")
    model.graph.initializer.extend([w])

    ort_quant.quant_pre_process(model, path, skip_symbolic_shape=True)

    opt_model = onnx.load(path)
    current_nodes = [node.op_type for node in opt_model.graph.node]
    print([node.op_type for node in opt_model.graph.node])
    assert current_nodes == ["Conv"], f"Wrong. Current nodes: {current_nodes}."

test_pad(op_version=18) # This pass
test_pad(op_version=21) # This raises an exception

Urgency

No response

Platform

Linux

OS Version

Ubuntu 22.04

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.21.0

ONNX Runtime API

Python

Architecture

X64

Execution Provider

Default CPU

Execution Provider Library Version

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant