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

onnxruntime errors out due to ORT_ENABLE_EXTENDED optimization: Can't remove node Transpose as it still has output edges. #24137

Open
coffezhou opened this issue Mar 22, 2025 · 0 comments
Labels
core runtime issues related to core runtime

Comments

@coffezhou
Copy link

coffezhou commented Mar 22, 2025

Expected behavior

onnxruntime can run the model when using the optimization ORT_ENABLE_EXTENDED.

Actual behavior

When using the optimization ORT_ENABLE_EXTENDED, onnxruntime crashes.

Traceback (most recent call last):
  File "/home/carla/Documents/test_onnxruntime/0322/test.py", line 15, in <module>
    ort_session = onnxruntime.InferenceSession(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/carla/anaconda3/envs/onnxruntime/lib/python3.11/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 472, in __init__
    self._create_inference_session(providers, provider_options, disabled_optimizers)
  File "/home/carla/anaconda3/envs/onnxruntime/lib/python3.11/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 544, in _create_inference_session
    sess.initialize_session(providers, provider_options, disabled_optimizers)
onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Exception during initialization: /onnxruntime_src/onnxruntime/core/graph/graph.cc:4037 bool onnxruntime::Graph::RemoveNode(onnxruntime::NodeIndex) node->GetOutputEdgesCount() == 0 was false. Can't remove node Transpose as it still has output edges.

To reproduce

Environment

OS: Ubuntu 20.04
onnxruntime: 1.22.0.dev20250320003

Steps to reproduce

This bug can be reproduced by the following code with the model in the attachment. For the model, it can be correctly checked by onnx.checker.check_model. However, if we replace ORT_ENABLE_EXTENDED with ORT_ENABLE_BASIC, every thing is ok.

from typing import Dict, List, Literal, Optional
import sys

import numpy as np
import onnx
import onnxruntime

model_path = "bugs/onnx_output5932/model.onnx"
onnx_model = onnx.load(model_path)
onnx.checker.check_model(onnx_model)

sess_options = onnxruntime.SessionOptions()              
sess_options.graph_optimization_level = onnxruntime.GraphOptimizationLevel.ORT_ENABLE_EXTENDED

ort_session = onnxruntime.InferenceSession(
                     onnx_model.SerializeToString(), sess_options, providers=["CPUExecutionProvider"]
                  )

model.zip

Urgency

No response

Platform

Linux

OS Version

Ubuntu 20.04

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

1.22.0.dev20250320003

ONNX Runtime API

Python

Architecture

X64

Execution Provider

Default CPU

Execution Provider Library Version

No response

@yuslepukhin yuslepukhin changed the title onnxruntime crashes due to ORT_ENABLE_EXTENDED optimization: Can't remove node Transpose as it still has output edges. onnxruntime errors out due to ORT_ENABLE_EXTENDED optimization: Can't remove node Transpose as it still has output edges. Mar 24, 2025
@yuslepukhin yuslepukhin added the core runtime issues related to core runtime label Mar 24, 2025
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
Projects
None yet
Development

No branches or pull requests

2 participants