microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.9k stars 2.95k forks source link

Extract node info #17444

Open wxthu opened 1 year ago

wxthu commented 1 year ago

Describe the issue

I want to extract the input shape, weight shape and output shape of each node . How can I do it

To reproduce

no

Urgency

No response

Platform

Linux

OS Version

ubuntu2004

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

no

ONNX Runtime API

Python

Architecture

X64

Execution Provider

CUDA

Execution Provider Library Version

No response

hariharans29 commented 1 year ago

All shape information should be made available by using ONNX's (https://github.com/onnx/onnx) shape inferencing capability.

https://github.com/onnx/onnx/blob/main/docs/ShapeInference.md

https://github.com/onnx/onnx/blob/main/docs/PythonAPIOverview.md#running-shape-inference-on-an-onnx-model

wxthu commented 1 year ago

All shape information should be made available by using ONNX's (https://github.com/onnx/onnx) shape inferencing capability.

https://github.com/onnx/onnx/blob/main/docs/ShapeInference.md

https://github.com/onnx/onnx/blob/main/docs/PythonAPIOverview.md#running-shape-inference-on-an-onnx-model

That is, I have to extract each node then using above method to manually infer output shape of each node?

skottmckay commented 1 year ago

If you save the 'inferred_model' in the ONNX shape inferencing example using onnx.save that would include the inferred information. Typically it is not included in the model as it would waste space to do so given the values can be inferred. You can view the updated model in Netron to see the shapes.