onnx / models

A collection of pre-trained, state-of-the-art models in the ONNX format
http://onnx.ai/models/
Apache License 2.0
7.99k stars 1.41k forks source link

Run official model fasterrcnn failed by onnxruntime #565

Open cccxinli opened 2 years ago

cccxinli commented 2 years ago

Bug Report

Which model does this pertain to?

FasterRCNN-12.onnx (https://github.com/onnx/models/blob/main/vision/object_detection_segmentation/faster-rcnn/model/FasterRCNN-12.onnx)

Describe the bug

onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Non-zero status code returned while running Add node. Name:'451' Status Message: /onnxruntime_src/onnxruntime/core/providers/cpu/math/element_wise_ops.h:503 void onnxruntime::BroadcastIterator::Init(ptrdiff_t, ptrdiff_t) axis == 1 || axis == largest was false. Attempting to broadcast an axis by a dimension other than 1. 75 by 76

Reproduction instructions

System Information
onnxruntime versiont 1.12.1 numpy version 1.23.4 python version 3.8.8

Provide a code snippet to reproduce your errors.

import numpy
from onnxruntime import InferenceSession, RunOptions

X = numpy.ones([3,600,600], dtype="float32")
sess = InferenceSession("FasterRCNN-12.onnx")
names = [o.name for o in sess._sess.outputs_meta]
ro = RunOptions()
result = sess._sess.run(names, {'image': X}, ro)
...

Notes

Any additional information

mszhanyi commented 2 years ago

It's skipped in tests

[ RUN  ] ModelTests/ModelTest.Run/cpu__models_zoo_opset12_Faster_RCNN_R50FPNfp32_FasterRCNN12
/home/yizhang/git/ort/onnxruntime/test/providers/cpu/model_tests.cc:86: Skipped
Skipping single test It has training domain

@snnn @jcwchen

snnn commented 2 years ago

@jcwchen, you may transfer this issue to ORT repo.

jcwchen commented 2 years ago

Hi @cccxinli, I tried different combinations of input shape, but only few of them can work. For instance, the size of demo image 640 x 480 is workable. Still, ideally it should not be input-shape-sensitive.

@jcwchen, you may transfer this issue to ORT repo.

Actually I am not able to transfer this issue to onnxruntime repo. @cccxinli could you please raise this issue in the onnxruntime repo instead if you have time? Thanks.

snnn commented 2 years ago

Is it a model issue or implementation issue?

jcwchen commented 2 years ago

Good question... I slightly tend to it's a model issue, because the error is related to broadcast and the previous Resize op before the failed Add op seems unreliable for every kind of shape. Also onnx.shape_inference cannot detect this kind of issue in advance because the input is symbolic without real data. Ideally the converted ONNX model should be shape-insensitive if their inputs are symbolic.

cccxinli commented 2 years ago

I also tend to it is a model or conversion issue rather than runtime issue. It will be shape-insensitiv if replace resize with convtranspose. Specific shape works for now. Thanks.