A tool for ONNX model:Shape inference, MACs(FLOPs) counting for each layer, Extract subgraph from ONNX model, or do inplace op fusion, and any operation you can image with ONNX.
Project description
onnx-tool
A tool for ONNX model:
- Shape inference.
- MACs(FLOPs) counting for each layer.
- Extract subgraph from ONNX model, or do inplace op fusion.
...
and any operation you can image with ONNX.
New:
- Happy Chinese New Year! Preview of Compute Graph in v0.5.4 release. Compute Graph.
node_profilers.py will be totally DEPRECATED in the next release. - Preview of Shape Engine , update BERT-Base's shapes within 1ms. ShapeEngine
- The speedup of shape inference is 100x in v0.5.0 release. Release detail
- Better support of Tensorflow-converted models in v0.4.0 release.
- Sparse Models are initially supported in v0.3.1 release. view Sparse Model
- Quantized models are initially supported in v0.3.0 release.
- 4 onnx models of Stable Diffusion are supported in v0.2.14 release. view results
...
Shape inference
how to use: data/Profile.md.
pytorch usage: data/PytorchUsage.md.
tensorflow
usage: data/TensorflowUsage.md.
MACs counting for each layer (FLOPs=2*MACs)
how to use: data/Profile.md.
pytorch usage: data/PytorchUsage.md.
tensorflow
usage: data/TensorflowUsage.md.
Compute Graph with Shape Engine
Remove shape calculation layers(created by ONNX export) to get a Compute Graph. Use Shape Engine to update tensor
shapes at runtime.
samples: TODO
Extract subgraph from ONNX model
how to use: data/Subgraph.md.
Inplace op fusion
how to use: data/Subgraph.md.
Add any hidden tensors to model's outputs
how to use: data/Profile.md.
Tensor operations
- Export weight tensors to files
- Simplify tensor and node names, convert name from a long string to a short string
- Remove unused tensors, models like vgg19-7.onnx set its static weight tensors as its input tensors
- Set custom input and output tensors' name and dimension, change model from fixed input to dynamic input
how to use: data/Tensors.md.
How to install
pip install onnx-tool
OR
pip install --upgrade git+https://github.com/ThanatosShinji/onnx-tool.git
python>=3.6
If pip install onnx-tool
failed by onnx's installation, you may try pip install onnx==1.8.1
(a lower version like this) first.
Then pip install onnx-tool
again.
Known Issues
- Loop op is not supported
Results of ONNX Model Zoo and SOTA models
Some models have dynamic input shapes. The MACs varies from input shapes. The input shapes used in these results are writen to data/public/config.py. These onnx models with all tensors' shape can be downloaded: baidu drive(code: p91k) google drive
|
|
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for onnx_tool-0.5.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b26560df580f577bc678bc7a3d6a607796bb302212ede736e69c9da3736bb7c4 |
|
MD5 | 1142b9fa97b56967dfd9116f8deeec50 |
|
BLAKE2b-256 | e3bbd8cffec165df40ea65919375f7576d3ad536b16deb0c14269fd71223d5e2 |