Skip to content

onnx_graphsurgeon: toposort failed on a graph without cycle #4086

Open
@xhdhr10000

Description

@xhdhr10000

Description

toposort onnx
Run toposort on this simple onnx got an error:
OnnxGraphSurgeonException: Cycle detected in graph! Are there tensors with duplicate names in the graph?

Environment

onnx==1.16.2
onnx_graphsurgeon==0.5.2

Operating System:
Ubuntu 20.04

Python Version (if applicable):
python==3.8.10

Relevant Files

Model link:
toposort.onnx.zip

Steps To Reproduce

Commands or scripts:

import onnx
import onnx_graphsurgeon as gs

graph = gs.import_onnx(onnx.load('./toposort.onnx'))
graph.toposort()
# `OnnxGraphSurgeonException: Cycle detected in graph! Are there tensors with duplicate names in the graph?`

Have you tried the latest release?:
Yes

Can this model run on other frameworks? For example run ONNX model with ONNXRuntime (polygraphy run <model.onnx> --onnxrt):
Yes

import onnx
import onnxruntime as ort

model = onnx.load('./toposort.onnx')
sess = ort.InferenceSession(model.SerializeToString())
sess.run(['mul_0_output'], {'input': np.array(3., dtype=np.float32)})
# Out: [array(-9., dtype=float32)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Module:GraphSurgeonIssues with ONNX-GraphsurgeontriagedIssue has been triaged by maintainers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions