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

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

Closed
OYCN opened this issue Mar 2, 2024 · 0 comments · Fixed by #5990
Closed

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

OYCN opened this issue Mar 2, 2024 · 0 comments · Fixed by #5990
Labels

Comments

@OYCN
Copy link
Contributor

OYCN commented Mar 2, 2024

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.

@OYCN OYCN added the bug label Mar 2, 2024
@OYCN OYCN changed the title [CustomOp] SegFault during shape inference if the schema not be set inference function SegFault during shape inference if the schema not be set inference function Mar 2, 2024
github-merge-queue bot pushed a commit that referenced this issue Mar 4, 2024
### Description

The bug is SegFault during shape inference if the schema not be set
inference function.

The schema has `CheckInputOutputType` for shape inference and `Verify`
for raw node proto. And the behavior is not fully aligned.

### Motivation and Context

fixes #5989

---------

Signed-off-by: opluss <opluss@qq.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com>
cjvolzka pushed a commit that referenced this issue Mar 4, 2024
### Description
Cherry-pick #5990 into `rel-1.16.0` branch

The bug is SegFault during shape inference if the schema not be set
inference function.

The schema has `CheckInputOutputType` for shape inference and `Verify`
for raw node proto. And the behavior is not fully aligned.

### Motivation and Context

fixes #5989

---------

Signed-off-by: opluss <opluss@qq.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com>
cjvolzka added a commit that referenced this issue Mar 5, 2024
### Description
Cherry-Pick #5990 into `rel-1.16.0` branch

The bug is SegFault during shape inference if the schema not be set
inference function.

The schema has `CheckInputOutputType` for shape inference and `Verify`
for raw node proto. And the behavior is not fully aligned.

### Motivation and Context

fixes #5989

Signed-off-by: opluss <opluss@qq.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Co-authored-by: oPluss <opluss@qq.com>
Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com>
isdanni pushed a commit to isdanni/onnx that referenced this issue Mar 18, 2024
### Description

The bug is SegFault during shape inference if the schema not be set
inference function.

The schema has `CheckInputOutputType` for shape inference and `Verify`
for raw node proto. And the behavior is not fully aligned.

### Motivation and Context

fixes onnx#5989

---------

Signed-off-by: opluss <opluss@qq.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: isdanni <leedanni@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant