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

[Build] TypeInferenceError when quantize an onnx model with custom operator #23191

Open
Liuhehe2019 opened this issue Dec 25, 2024 · 0 comments
Labels
build build issues; typically submitted using template quantization issues related to quantization

Comments

@Liuhehe2019
Copy link

Describe the issue

I use onnxruntime python api to quantize a model with custom operator.

@onnx_op was used in my code to register the custom op:

@onnx_op(op_type='LocatePostNms',
domain='ai.onnx.contrib',
inputs=[PyCustomOpDef.dt_float, PyCustomOpDef.dt_int32, PyCustomOpDef.dt_float, PyCustomOpDef.dt_float,
PyCustomOpDef.dt_int32, PyCustomOpDef.dt_float],
outputs=[PyCustomOpDef.dt_float, PyCustomOpDef.dt_int32],
attrs={"classNumber": PyCustomOpDef.dt_int32,
"iou_thresh": PyCustomOpDef.dt_float,
"scale": PyCustomOpDef.dt_double,
"side": PyCustomOpDef.dt_int32,
"topk": PyCustomOpDef.dt_int32,
"type": PyCustomOpDef.dt_int32}
)
def locatepostnms_compute(x, **kwargs):
padded_box = np.ones((1, 24000, 7))
result_cnt = np.ones(1)
return padded_box, result_cnt

and set sess_options.register_custom_ops_library(get_library_path()), but error happened when running onnxruntime. quantization. quantize. quantize_static interface, report:

onnx.onnx_cpp2py_export.shape_inference.InferenceError: [TypeInferenceError] Cannot infer type and shape for node name 453. No opset import for domain ai.onnx.contrib optype LocatePostNms

where 453 is the name of custom op, how do i infer type and shape for this type of onnx model to finish the quantization?

Sorry that i can't provide the model

Urgency

No response

Target platform

windows 11 PRO/ ubuntu 22.04

Build script

python

Error / output

onnx.onnx_cpp2py_export.shape_inference.InferenceError: [TypeInferenceError] Cannot infer type and shape for node name 453. No opset import for domain ai.onnx.contrib optype LocatePostNms

Visual Studio Version

No response

GCC / Compiler Version

No response

@Liuhehe2019 Liuhehe2019 added the build build issues; typically submitted using template label Dec 25, 2024
@github-actions github-actions bot added the quantization issues related to quantization label Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build issues; typically submitted using template quantization issues related to quantization
Projects
None yet
Development

No branches or pull requests

1 participant