onnxruntime icon indicating copy to clipboard operation
onnxruntime copied to clipboard

[EP ABI] Update Graph_GetGraphView() implementation

Open chilo-ms opened this issue 2 months ago • 0 comments

Description

In some cases, e.g. when model has a node that produces output consumed by multiple nodes, calling the current implementation of Graph_GetGraphView() to get a subgraph returns incorrect OrtGraph.

This PR fixes the issue.

  • Original graph:

    image
  • Incorrect graph after calling Graph_GetGraphView() to get the subgraph:

    It includes three of the nodes from the original graph. The topk_indices is the output of the TopK and it shouldn't be added as a graph input shown in the graph below. The API implementation has issue handling this case. If we feed this subgraph into TRT parser, it would fail to parse the graph.

    image
  • Correct graph after calling Graph_GetGraphView() to get the subgraph:

    It includes three of the nodes from the original graph. The topk_indices now is not added as a graph input. Instead, the topk_indices is added as a graph output which is expected as Mod is in another subgraph that consumes it, so this subgraph has to make topk_indices a graph output.

    image

Motivation and Context

chilo-ms avatar Dec 03 '25 00:12 chilo-ms