onnx-subgraph tool provides model auto partitionioning of onnx model to several sub models by operator, performance and model size limitations, with the order and input / output names of sub models.
1. ubuntu >=20.04
2. GCC >= 9.4.0
3. cmake >= 3.10
4. python >= 3.8
5. apt-get install libprotobuf-dev protobuf-compiler libjsoncpp-dev
onnx 1.16.0
onnxruntime 1.18.1
onnxsim 0.4.36
torch 2.3.1
scikit-image
scikit-learn
pandas
tqdm
cd onnx-subgraph
mkdir build & cd build
cmake .. & makewe can get following output at './build'
scripts
├── extract_onnx.py
└── test_model_download.sh
└── subgraphs_ios.txt1. 'bash scripts/test_model_download.sh', then "resnet-test.onnx" will be got in './build'
2. you can change to any other onnx files as your needs, or edit the download link in
"scripts/test_model_download.sh"
note: 'subgraphs_ios.txt' will be generated in future code, suppose we already have it as
the example file now.
python scripts/extract_onnx.py \
-s ./scripts/subgraphs_ios.txt \
-m ./resnet-test.onnxafter extraction done, the subgraphs will be saved at './subgraphs'
subgraphs
├── CPUsubgraph0.onnx
└── CPUsubgraph1.onnx
├── NPUsubgraph0.onnx
└── NPUsubgraph1.onnx