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

RUNTIME_EXCEPTION : Non-zero status code returned while running Reshape node #20026

Open
Priyanshu88 opened this issue Mar 22, 2024 · 3 comments
Labels
core runtime issues related to core runtime stale issues that have not been addressed in a while; categorized by a bot

Comments

@Priyanshu88
Copy link

Describe the issue

onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Non-zero status code returned while running Reshape node. Name:'/Reshape_16_output_0_ReduceMax_Reshape' Status Message: /onnxruntime_src/onnxruntime/core/providers/cpu/tensor/reshape_helper.h:44 onnxruntime::ReshapeHelper::ReshapeHelper(const onnxruntime::TensorShape&, onnxruntime::TensorShapeVector&, bool) input_shape_size == size was false. The input tensor cannot be reshaped to the requested shape. Input shape:{0,1}, requested shape:{1}

Urgency

Yeah urgency

Target platform

OpenMMLab

Build script

I am using the below config to convert the rtmo model to onnx model with the help of mmdeploy
https://github.com/open-mmlab/mmdeploy/blob/main/configs/mmpose/pose-detection_rtmo_onnxruntime_dynamic.py

onnx_config = dict(
    output_names=['dets', 'keypoints'],
    dynamic_axes={
        'input': {
            0: 'batch',
        },
        'dets': {
            0: 'batch',
        },
        'keypoints': {
            0: 'batch'
        }
    })

codebase_config = dict(
    post_processing=dict(
        score_threshold=0.05,
        iou_threshold=0.5,
        max_output_boxes_per_class=200,
        pre_top_k=2000,
        keep_top_k=50,
        background_label_id=-1,
    ))

Error / output

Full log describing the path

When keeping the batch size as 32, am getting below failure.

onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Non-zero status code returned while running Reshape node. Name:'/Reshape_16_output_0_ReduceMax_Reshape' Status Message: /onnxruntime_src/onnxruntime/core/providers/cpu/tensor/reshape_helper.h:44 onnxruntime::ReshapeHelper::ReshapeHelper(const onnxruntime::TensorShape&, onnxruntime::TensorShapeVector&, bool) input_shape_size == size was false. The input tensor cannot be reshaped to the requested shape. Input shape:{0,1}, requested shape:{1}

When keeping the batch size as 1, am getting below failure.

[ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Non-zero status code returned while running Reshape node. Name:'/Tile_output_0_ReduceMax_Reshape' Status Message: /onnxruntime_src/onnxruntime/core/providers/cpu/tensor/reshape_helper.h:44 onnxruntime::ReshapeHelper::ReshapeHelper(const onnxruntime::TensorShape&, onnxruntime::TensorShapeVector&, bool) input_shape_size == size was false. The input tensor cannot be reshaped to the requested shape. Input shape:{1,0,1}, requested shape:{1}

Visual Studio Version

No response

GCC / Compiler Version

No response

@Priyanshu88 Priyanshu88 added the build build issues; typically submitted using template label Mar 22, 2024
@skottmckay
Copy link
Contributor

Reshape can only change the shape of the data. It does not create/destroy data.

In both cases the input to the Reshape node has no data as one of the dimensions is 0. So we can't 'reshape' no data to data with 1 element.

Most likely part of your model has some sort of selection logic, and nothing was selected, leading to a dimension with a value of 0.

It's also slightly unusual to be using Reshape with a target shape of {1}. Squeeze may be an alternative option as it would handle dims with a value of zero as it removes dimensions with a value of 1.

@skottmckay skottmckay added core runtime issues related to core runtime and removed build build issues; typically submitted using template labels Mar 22, 2024
@Priyanshu88
Copy link
Author

Reshape can only change the shape of the data. It does not create/destroy data.

In both cases the input to the Reshape node has no data as one of the dimensions is 0. So we can't 'reshape' no data to data with 1 element.

Most likely part of your model has some sort of selection logic, and nothing was selected, leading to a dimension with a value of 0.

It's also slightly unusual to be using Reshape with a target shape of {1}. Squeeze may be an alternative option as it would handle dims with a value of zero as it removes dimensions with a value of 1.

But why is this different for two different batch sizes?
Any possible solution will work that would handle my case of conversion, also did you take a look at onnx config specific to model and it's expected behavior ? let me know any modification if you can provide.

Copy link
Contributor

This issue has been automatically marked as stale due to inactivity and will be closed in 30 days if no further activity occurs. If further support is needed, please provide an update and/or more details.

@github-actions github-actions bot added the stale issues that have not been addressed in a while; categorized by a bot label Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core runtime issues related to core runtime stale issues that have not been addressed in a while; categorized by a bot
Projects
None yet
Development

No branches or pull requests

2 participants