Skip to content

SegFault during shape inference if the schema not be set inference function #5989

@OYCN

Description

@OYCN

Bug Report

Describe the bug

SegFault during shape inference if the schema not be set inference function

Reproduction instructions

cpp (Optional):

ONNX_OPERATOR_SCHEMA(CustomOp);

python:

import onnx
from onnx import defs

input = """
            <
                ir_version: 7,
                opset_import: [
                    "" : 1
                ]
            >
            agraph (float[N, 128] X, int32 Y) => (float[N] Z)
            {
                Z = CustomOp(X, Y)
            }
           """
model = onnx.parser.parse_model(input)

op_schema = defs.OpSchema(
    'CustomOp',
    '',
    1,
    inputs=[
    ],
    outputs=[
    ],
)

# Uncomment if not register in cpp
# onnx.defs.register_schema(op_schema)
onnx.shape_inference.infer_shapes(model, True)

Expected behavior

Raise a python exception rather than crash.

Notes

The root case is the input or output of schema is empty and the corresponding field in graph is no-empty. So the input.back from schema will invalid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions