onnxslim 0.1.82__tar.gz → 0.1.84__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- onnxslim-0.1.84/.github/ISSUE_TEMPLATE/bug_report.md +30 -0
- onnxslim-0.1.84/.github/ISSUE_TEMPLATE/custom.md +10 -0
- onnxslim-0.1.84/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/.github/workflows/ci.yml +1 -1
- onnxslim-0.1.84/.github/workflows/nightly-test.yml +90 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/PKG-INFO +21 -11
- {onnxslim-0.1.82 → onnxslim-0.1.84}/README.md +20 -10
- onnxslim-0.1.84/README_CN.md +190 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/optimization/dead_node_elimination.py +85 -4
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/pattern/elimination/slice.py +15 -8
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/pattern/fusion/concat_reshape.py +3 -1
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/pattern/fusion/convadd.py +23 -7
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/pattern/fusion/convbn.py +24 -11
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/pattern/fusion/convmul.py +26 -9
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/pattern/fusion/gemm.py +7 -5
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/pattern/fusion/padconv.py +5 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/__init__.py +378 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/aten_ops/__init__.py +16 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/aten_ops/argmax.py +47 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/aten_ops/bitwise_or.py +28 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/aten_ops/diagonal.py +52 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/aten_ops/embedding.py +23 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/aten_ops/group_norm.py +41 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/aten_ops/min_max.py +64 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/aten_ops/multinomial.py +39 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/aten_ops/numpy_t.py +22 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/aten_ops/pool2d.py +40 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/aten_ops/unfold.py +44 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/aten_ops/upsample.py +44 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/base.py +111 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/context.py +645 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/__init__.py +8 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/attention/__init__.py +15 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/attention/attention.py +61 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/attention/decoder_masked_mha.py +37 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/attention/gated_relative_position_bias.py +35 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/attention/longformer_attention.py +21 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/attention/multi_head_attention.py +82 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/attention/multi_scale_deformable_attn.py +29 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/attention/packed_attention.py +39 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/attention/packed_multi_head_attention.py +33 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/attention/remove_padding.py +41 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/attention/restore_padding.py +29 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/misc/__init__.py +15 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/misc/bias_add.py +21 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/misc/bias_gelu.py +21 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/misc/bias_split_gelu.py +30 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/misc/fast_gelu.py +21 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/misc/gelu.py +21 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/misc/gemm_fast_gelu.py +21 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/misc/gemm_float8.py +21 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/misc/python_op.py +67 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/misc/quick_gelu.py +21 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/misc/rotary_embedding.py +31 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/normalization/__init__.py +12 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/normalization/embed_layer_normalization.py +41 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/normalization/group_norm.py +21 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/normalization/layer_normalization.py +42 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/normalization/simplified_layer_normalization.py +23 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/normalization/skip_group_norm.py +23 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/normalization/skip_layer_normalization.py +26 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/contrib_ops/normalization/skip_simplified_layer_normalization.py +23 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/registry.py +90 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/__init__.py +11 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/control_flow/__init__.py +8 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/control_flow/if_op.py +43 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/control_flow/loop.py +74 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/control_flow/scan.py +54 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/math/__init__.py +20 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/math/_symbolic_compute.py +34 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/math/add.py +10 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/math/div.py +10 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/math/einsum.py +119 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/math/equal.py +10 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/math/floor.py +10 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/math/matmul.py +21 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/math/matmul_integer.py +23 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/math/max.py +10 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/math/min.py +10 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/math/mul.py +10 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/math/neg.py +10 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/math/reduce_prod.py +27 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/math/reduce_sum.py +53 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/math/sub.py +10 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/math/where.py +10 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/misc/__init__.py +22 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/misc/array_feature_extractor.py +32 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/misc/cast.py +21 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/misc/category_mapper.py +30 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/misc/compress.py +39 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/misc/constant.py +27 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/misc/constant_of_shape.py +45 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/misc/dequantize_linear.py +26 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/misc/non_max_suppression.py +26 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/misc/non_zero.py +26 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/misc/one_hot.py +42 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/misc/quantize_linear.py +29 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/misc/range.py +41 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/misc/relative_position_bias.py +31 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/misc/resize.py +74 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/misc/scatter_elements.py +31 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/misc/softmax_cross_entropy_loss.py +44 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/misc/top_k.py +44 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/nn/__init__.py +18 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/nn/all_reduce.py +9 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/nn/average_pool.py +40 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/nn/batch_normalization.py +26 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/nn/conv.py +33 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/nn/cum_sum.py +9 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/nn/identity.py +9 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/nn/max_pool.py +9 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/nn/memcpy_from_host.py +9 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/nn/memcpy_to_host.py +9 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/nn/moe.py +9 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/nn/nhwc_conv.py +33 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/nn/reciprocal.py +9 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/nn/round.py +9 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/sequence/__init__.py +10 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/sequence/concat_from_sequence.py +40 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/sequence/sequence_at.py +31 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/sequence/sequence_insert.py +26 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/sequence/split_to_sequence.py +24 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/sequence/zip_map.py +36 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/tensor/__init__.py +20 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/tensor/concat.py +62 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/tensor/expand.py +36 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/tensor/gather.py +48 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/tensor/gather_elements.py +31 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/tensor/gather_nd.py +42 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/tensor/pad.py +41 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/tensor/reshape.py +72 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/tensor/shape.py +38 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/tensor/size.py +29 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/tensor/slice.py +183 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/tensor/split.py +57 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/tensor/squeeze.py +69 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/tensor/tile.py +41 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/tensor/transpose.py +30 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/standard_ops/tensor/unsqueeze.py +54 -0
- onnxslim-0.1.84/onnxslim/core/shape_inference/utils.py +244 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/ir/graph.py +0 -103
- onnxslim-0.1.84/onnxslim/third_party/symbolic_shape_infer.py +189 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/utils.py +4 -2
- {onnxslim-0.1.82 → onnxslim-0.1.84}/pyproject.toml +6 -4
- onnxslim-0.1.84/tests/exporters/__init__.py +0 -0
- onnxslim-0.1.84/tests/exporters/onnx/__init__.py +0 -0
- onnxslim-0.1.84/tests/exporters/onnx/test_export_cli.py +787 -0
- onnxslim-0.1.84/tests/exporters/onnx/utils_tests.py +392 -0
- onnxslim-0.1.84/tests/test_amd.py +103 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/test_dead_node_elimination.py +21 -21
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/test_fusion_patterns.py +197 -3
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/test_modelzoo.py +28 -1
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/test_onnxslim.py +3 -2
- onnxslim-0.1.84/tests/test_ultralytics.py +170 -0
- onnxslim-0.1.82/.github/workflows/nightly-test.yml +0 -32
- onnxslim-0.1.82/onnxslim/third_party/symbolic_shape_infer.py +0 -3272
- {onnxslim-0.1.82 → onnxslim-0.1.84}/.codespellignore +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/.github/FUNDING.yml +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/.github/workflows/format.yml +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/.github/workflows/python-publish.yml +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/.gitignore +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/.prettierignore +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/CODE_OF_CONDUCT.md +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/CONTRIBUTING.md +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/LICENSE +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/assets/logo/onnxslim-banner-light.svg +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/assets/logo/onnxslim-banner.svg +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/assets/logo/onnxslim-logo-os-bw.svg +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/assets/logo/onnxslim-logo-os-white.svg +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/assets/logo/onnxslim-logo-os.svg +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/bin/onnxslim +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/docs/_static/style.css +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/docs/_templates/layout.html +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/docs/conf.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/docs/index.rst +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/docs/main/toc.rst +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/docs/requirements.txt +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/examples/Boost-onnx-load-speed-by-10/342/200/22315-percent-with-onnxslim-python-package.ipynb" +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/examples/common_subexpression_elimination/README.md +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/examples/common_subexpression_elimination/cse_demo.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/examples/input_shape_modification/README.md +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/examples/model_inspect/README.md +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/examples/output_modification/README.md +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/format.sh +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/images/after_cse.png +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/images/before_cse.png +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/images/cse.png +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/images/input_shape_modification.jpg +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/images/model_inspect.jpg +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/images/onnxslim.gif +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/images/output_modification.jpg +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/__init__.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/__main__.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/argparser.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/cli/__init__.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/cli/_main.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/__init__.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/optimization/__init__.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/optimization/subexpression_elimination.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/optimization/weight_tying.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/pattern/__init__.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/pattern/elimination/__init__.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/pattern/elimination/concat.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/pattern/elimination/reshape.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/pattern/elimination/reshape_as.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/pattern/elimination/unsqueeze.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/pattern/fusion/__init__.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/pattern/fusion/gelu.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/pattern/fusion/reduce.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/core/pattern/registry.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/misc/__init__.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/misc/tabulate.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/__init__.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/_sympy/__init__.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/_sympy/functions.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/_sympy/numbers.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/_sympy/printers.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/_sympy/solve.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/_sympy/symbol.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/__init__.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/exporters/__init__.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/exporters/base_exporter.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/exporters/onnx_exporter.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/graph_pattern/__init__.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/graph_pattern/graph_pattern.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/importers/__init__.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/importers/base_importer.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/importers/onnx_importer.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/ir/__init__.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/ir/function.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/ir/node.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/ir/tensor.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/logger/__init__.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/logger/logger.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/util/__init__.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/util/exception.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/third_party/onnx_graphsurgeon/util/misc.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/onnxslim/version.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/conftest.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/test_benchmark.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/test_cli_main.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/test_coverage.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/test_elimination_patterns.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/test_folder.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/test_nvidia.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/test_onnx_nets.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/test_pattern_generator.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/test_pattern_matcher.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/test_shape_folding.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/test_subexpression_elimination.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/test_symbolic_shape_inference.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/test_utils.py +0 -0
- {onnxslim-0.1.82 → onnxslim-0.1.84}/tests/utils.py +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: ''
|
|
5
|
+
labels: bug
|
|
6
|
+
assignees: inisis
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Describe the bug**
|
|
11
|
+
A clear and concise description of what the bug is.
|
|
12
|
+
|
|
13
|
+
**To Reproduce**
|
|
14
|
+
Steps to reproduce the bug:
|
|
15
|
+
|
|
16
|
+
**Expected behavior**
|
|
17
|
+
A clear and concise description of what you expected to happen.
|
|
18
|
+
|
|
19
|
+
**Screenshots**
|
|
20
|
+
If applicable, add screenshots to help explain your problem.
|
|
21
|
+
|
|
22
|
+
**Environment:**
|
|
23
|
+
run the script and paste the output.
|
|
24
|
+
```
|
|
25
|
+
python -c "import importlib; pkgs=['onnx','onnxruntime','onnxslim']; \
|
|
26
|
+
[print(f'{p}: {importlib.import_module(p).__version__}') if importlib.util.find_spec(p) else print(f'{p}: missing') for p in pkgs]"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Additional context**
|
|
30
|
+
Add any other context about the problem here.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest an idea for this project
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Is your feature request related to a problem? Please describe.**
|
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
12
|
+
|
|
13
|
+
**Describe the solution you'd like**
|
|
14
|
+
A clear and concise description of what you want to happen.
|
|
15
|
+
|
|
16
|
+
**Describe alternatives you've considered**
|
|
17
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
|
18
|
+
|
|
19
|
+
**Additional context**
|
|
20
|
+
Add any other context or screenshots about the feature request here.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
name: nightly-test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
schedule:
|
|
5
|
+
- cron: "0 18 * * *" # Runs at 6:00 PM UTC every day, which is 2:00 AM Beijing Time the next day
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
benchmark:
|
|
10
|
+
runs-on: self-hosted
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v3
|
|
14
|
+
|
|
15
|
+
- uses: actions/setup-python@v4
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.12"
|
|
18
|
+
|
|
19
|
+
- name: install dependency
|
|
20
|
+
run: |
|
|
21
|
+
python -m pip install --upgrade pip wheel setuptools
|
|
22
|
+
pip install .
|
|
23
|
+
pip install pytest onnxruntime
|
|
24
|
+
|
|
25
|
+
- name: benchmark test
|
|
26
|
+
run: |
|
|
27
|
+
python tests/test_benchmark.py
|
|
28
|
+
|
|
29
|
+
timm-test:
|
|
30
|
+
runs-on: self-hosted
|
|
31
|
+
needs: benchmark
|
|
32
|
+
|
|
33
|
+
steps:
|
|
34
|
+
- uses: actions/checkout@v3
|
|
35
|
+
|
|
36
|
+
- uses: actions/setup-python@v4
|
|
37
|
+
with:
|
|
38
|
+
python-version: "3.12"
|
|
39
|
+
|
|
40
|
+
- name: install dependency
|
|
41
|
+
run: |
|
|
42
|
+
python -m pip install --upgrade pip wheel setuptools
|
|
43
|
+
pip install .
|
|
44
|
+
pip install pytest pytest-xdist onnxruntime timm torchvision --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cpu
|
|
45
|
+
|
|
46
|
+
- name: timm test
|
|
47
|
+
run: |
|
|
48
|
+
python tests/test_onnx_nets.py
|
|
49
|
+
|
|
50
|
+
ultralytics-test:
|
|
51
|
+
runs-on: self-hosted
|
|
52
|
+
needs: timm-test
|
|
53
|
+
|
|
54
|
+
steps:
|
|
55
|
+
- uses: actions/checkout@v3
|
|
56
|
+
|
|
57
|
+
- uses: actions/setup-python@v4
|
|
58
|
+
with:
|
|
59
|
+
python-version: "3.12"
|
|
60
|
+
|
|
61
|
+
- name: install dependency
|
|
62
|
+
run: |
|
|
63
|
+
python -m pip install --upgrade pip wheel setuptools
|
|
64
|
+
pip install .
|
|
65
|
+
pip install pytest pytest-xdist onnxruntime -U ultralytics
|
|
66
|
+
|
|
67
|
+
- name: ultralytics test
|
|
68
|
+
run: |
|
|
69
|
+
pytest tests/test_ultralytics.py -v -n 1
|
|
70
|
+
|
|
71
|
+
optimum-test:
|
|
72
|
+
runs-on: self-hosted
|
|
73
|
+
needs: ultralytics-test
|
|
74
|
+
|
|
75
|
+
steps:
|
|
76
|
+
- uses: actions/checkout@v3
|
|
77
|
+
|
|
78
|
+
- uses: actions/setup-python@v4
|
|
79
|
+
with:
|
|
80
|
+
python-version: "3.12"
|
|
81
|
+
|
|
82
|
+
- name: install dependency
|
|
83
|
+
run: |
|
|
84
|
+
python -m pip install --upgrade pip wheel setuptools
|
|
85
|
+
uv sync --dev
|
|
86
|
+
pip install einops parameterized transformers "optimum[onnxruntime]"
|
|
87
|
+
|
|
88
|
+
- name: optimum test
|
|
89
|
+
run: |
|
|
90
|
+
pytest tests/exporters/onnx/test_export_cli.py -v -n 4
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: onnxslim
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.84
|
|
4
4
|
Summary: OnnxSlim: A Toolkit to Help Optimize Onnx Model
|
|
5
5
|
Project-URL: homepage, https://github.com/inisis/OnnxSlim
|
|
6
6
|
Project-URL: issues, https://github.com/inisis/OnnxSlim/issues
|
|
@@ -20,17 +20,14 @@ Requires-Dist: sympy>=1.13.1
|
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
|
|
22
22
|
<p align="center">
|
|
23
|
-
<img src="assets/logo/onnxslim-banner-light.svg#gh-light-mode-only" alt="OnnxSlim Logo" width="640"/>
|
|
24
|
-
<img src="assets/logo/onnxslim-banner.svg#gh-dark-mode-only" alt="OnnxSlim Logo" width="640"/>
|
|
23
|
+
<img src="https://raw.githubusercontent.com/inisis/OnnxSlim/main/assets/logo/onnxslim-banner-light.svg#gh-light-mode-only" alt="OnnxSlim Logo" width="640"/>
|
|
24
|
+
<img src="https://raw.githubusercontent.com/inisis/OnnxSlim/main/assets/logo/onnxslim-banner.svg#gh-dark-mode-only" alt="OnnxSlim Logo" width="640"/>
|
|
25
25
|
</p>
|
|
26
26
|
|
|
27
27
|
<p align="center">
|
|
28
28
|
<a href="https://pypi.org/project/onnxslim">
|
|
29
29
|
<img src="https://img.shields.io/pypi/v/onnxslim?color=blue" />
|
|
30
30
|
</a>
|
|
31
|
-
<a href="https://pypi.org/project/onnxslim">
|
|
32
|
-
<img src="https://static.pepy.tech/badge/onnxslim/week" />
|
|
33
|
-
</a>
|
|
34
31
|
<a href="https://pypi.org/project/onnxslim">
|
|
35
32
|
<img src="https://static.pepy.tech/badge/onnxslim/month" />
|
|
36
33
|
</a>
|
|
@@ -51,6 +48,7 @@ Description-Content-Type: text/markdown
|
|
|
51
48
|
|
|
52
49
|
OnnxSlim can help you slim your onnx model, with less operators, but same accuracy, better inference speed.
|
|
53
50
|
|
|
51
|
+
- 🚀 2026/01/04: Achieved 5M downloads
|
|
54
52
|
- 🚀 2025/11/29: Top 1% on PyPI
|
|
55
53
|
- 🚀 2025/11/27: OnnxSlim is merged into [NVIDIA TensorRT-Model-Optimizer](https://github.com/NVIDIA/TensorRT-Model-Optimizer) 🤗🤗🤗
|
|
56
54
|
- 🚀 2025/05/17: OnnxSlim is merged into [HuggingFace optimum](https://github.com/huggingface/optimum) 🤗🤗🤗
|
|
@@ -61,10 +59,6 @@ OnnxSlim can help you slim your onnx model, with less operators, but same accura
|
|
|
61
59
|
- 🚀 2024/04/30: Rank 1st in the [AICAS 2024 LLM inference optimization challenge](https://tianchi.aliyun.com/competition/entrance/532170/customize440) held by Arm and T-head
|
|
62
60
|
- 🚀 2024/01/25: OnnxSlim is merged to [mnn-llm](https://github.com/wangzhaode/mnn-llm), performance increased by 5%
|
|
63
61
|
|
|
64
|
-
# Benchmark
|
|
65
|
-
|
|
66
|
-

|
|
67
|
-
|
|
68
62
|
# Installation
|
|
69
63
|
|
|
70
64
|
## Using Prebuilt
|
|
@@ -104,7 +98,9 @@ import onnxslim
|
|
|
104
98
|
|
|
105
99
|
model = onnx.load("model.onnx")
|
|
106
100
|
slimmed_model = onnxslim.slim(model)
|
|
107
|
-
|
|
101
|
+
|
|
102
|
+
if slimmed_model:
|
|
103
|
+
onnx.save(slimmed_model, "slimmed_model.onnx")
|
|
108
104
|
```
|
|
109
105
|
|
|
110
106
|
For more usage, see onnxslim -h or refer to our [examples](./examples)
|
|
@@ -182,6 +178,14 @@ For more usage, see onnxslim -h or refer to our [examples](./examples)
|
|
|
182
178
|
<a href="https://github.com/deepghs/imgutils" target="_blank">deepghs/imgutils</a>
|
|
183
179
|
</td>
|
|
184
180
|
</tr>
|
|
181
|
+
<tr>
|
|
182
|
+
<td style="vertical-align:middle;">
|
|
183
|
+
<img src="https://avatars.githubusercontent.com/u/430818?s=48&v=4" width="22" height="22" style="vertical-align:middle; margin-right:8px;"/>
|
|
184
|
+
<a href="https://github.com/amd/Quark" target="_blank">amd/Quark</a>
|
|
185
|
+
</td>
|
|
186
|
+
<td style="vertical-align:middle;">
|
|
187
|
+
</td>
|
|
188
|
+
</tr>
|
|
185
189
|
</table>
|
|
186
190
|
|
|
187
191
|
# References
|
|
@@ -192,6 +196,12 @@ For more usage, see onnxslim -h or refer to our [examples](./examples)
|
|
|
192
196
|
> - [tabulate](https://github.com/astanin/python-tabulate)
|
|
193
197
|
> - [onnxruntime](https://github.com/microsoft/onnxruntime)
|
|
194
198
|
|
|
199
|
+
# Contributors
|
|
200
|
+
|
|
201
|
+
<a href="https://github.com/inisis/onnxslim/graphs/contributors">
|
|
202
|
+
<img src="https://contrib.rocks/image?repo=inisis/onnxslim" />
|
|
203
|
+
</a>
|
|
204
|
+
|
|
195
205
|
# Contact
|
|
196
206
|
|
|
197
207
|
Discord: https://discord.gg/nRw2Fd3VUS QQ Group: `873569894`
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="assets/logo/onnxslim-banner-light.svg#gh-light-mode-only" alt="OnnxSlim Logo" width="640"/>
|
|
3
|
-
<img src="assets/logo/onnxslim-banner.svg#gh-dark-mode-only" alt="OnnxSlim Logo" width="640"/>
|
|
2
|
+
<img src="https://raw.githubusercontent.com/inisis/OnnxSlim/main/assets/logo/onnxslim-banner-light.svg#gh-light-mode-only" alt="OnnxSlim Logo" width="640"/>
|
|
3
|
+
<img src="https://raw.githubusercontent.com/inisis/OnnxSlim/main/assets/logo/onnxslim-banner.svg#gh-dark-mode-only" alt="OnnxSlim Logo" width="640"/>
|
|
4
4
|
</p>
|
|
5
5
|
|
|
6
6
|
<p align="center">
|
|
7
7
|
<a href="https://pypi.org/project/onnxslim">
|
|
8
8
|
<img src="https://img.shields.io/pypi/v/onnxslim?color=blue" />
|
|
9
9
|
</a>
|
|
10
|
-
<a href="https://pypi.org/project/onnxslim">
|
|
11
|
-
<img src="https://static.pepy.tech/badge/onnxslim/week" />
|
|
12
|
-
</a>
|
|
13
10
|
<a href="https://pypi.org/project/onnxslim">
|
|
14
11
|
<img src="https://static.pepy.tech/badge/onnxslim/month" />
|
|
15
12
|
</a>
|
|
@@ -30,6 +27,7 @@
|
|
|
30
27
|
|
|
31
28
|
OnnxSlim can help you slim your onnx model, with less operators, but same accuracy, better inference speed.
|
|
32
29
|
|
|
30
|
+
- 🚀 2026/01/04: Achieved 5M downloads
|
|
33
31
|
- 🚀 2025/11/29: Top 1% on PyPI
|
|
34
32
|
- 🚀 2025/11/27: OnnxSlim is merged into [NVIDIA TensorRT-Model-Optimizer](https://github.com/NVIDIA/TensorRT-Model-Optimizer) 🤗🤗🤗
|
|
35
33
|
- 🚀 2025/05/17: OnnxSlim is merged into [HuggingFace optimum](https://github.com/huggingface/optimum) 🤗🤗🤗
|
|
@@ -40,10 +38,6 @@ OnnxSlim can help you slim your onnx model, with less operators, but same accura
|
|
|
40
38
|
- 🚀 2024/04/30: Rank 1st in the [AICAS 2024 LLM inference optimization challenge](https://tianchi.aliyun.com/competition/entrance/532170/customize440) held by Arm and T-head
|
|
41
39
|
- 🚀 2024/01/25: OnnxSlim is merged to [mnn-llm](https://github.com/wangzhaode/mnn-llm), performance increased by 5%
|
|
42
40
|
|
|
43
|
-
# Benchmark
|
|
44
|
-
|
|
45
|
-

|
|
46
|
-
|
|
47
41
|
# Installation
|
|
48
42
|
|
|
49
43
|
## Using Prebuilt
|
|
@@ -83,7 +77,9 @@ import onnxslim
|
|
|
83
77
|
|
|
84
78
|
model = onnx.load("model.onnx")
|
|
85
79
|
slimmed_model = onnxslim.slim(model)
|
|
86
|
-
|
|
80
|
+
|
|
81
|
+
if slimmed_model:
|
|
82
|
+
onnx.save(slimmed_model, "slimmed_model.onnx")
|
|
87
83
|
```
|
|
88
84
|
|
|
89
85
|
For more usage, see onnxslim -h or refer to our [examples](./examples)
|
|
@@ -161,6 +157,14 @@ For more usage, see onnxslim -h or refer to our [examples](./examples)
|
|
|
161
157
|
<a href="https://github.com/deepghs/imgutils" target="_blank">deepghs/imgutils</a>
|
|
162
158
|
</td>
|
|
163
159
|
</tr>
|
|
160
|
+
<tr>
|
|
161
|
+
<td style="vertical-align:middle;">
|
|
162
|
+
<img src="https://avatars.githubusercontent.com/u/430818?s=48&v=4" width="22" height="22" style="vertical-align:middle; margin-right:8px;"/>
|
|
163
|
+
<a href="https://github.com/amd/Quark" target="_blank">amd/Quark</a>
|
|
164
|
+
</td>
|
|
165
|
+
<td style="vertical-align:middle;">
|
|
166
|
+
</td>
|
|
167
|
+
</tr>
|
|
164
168
|
</table>
|
|
165
169
|
|
|
166
170
|
# References
|
|
@@ -171,6 +175,12 @@ For more usage, see onnxslim -h or refer to our [examples](./examples)
|
|
|
171
175
|
> - [tabulate](https://github.com/astanin/python-tabulate)
|
|
172
176
|
> - [onnxruntime](https://github.com/microsoft/onnxruntime)
|
|
173
177
|
|
|
178
|
+
# Contributors
|
|
179
|
+
|
|
180
|
+
<a href="https://github.com/inisis/onnxslim/graphs/contributors">
|
|
181
|
+
<img src="https://contrib.rocks/image?repo=inisis/onnxslim" />
|
|
182
|
+
</a>
|
|
183
|
+
|
|
174
184
|
# Contact
|
|
175
185
|
|
|
176
186
|
Discord: https://discord.gg/nRw2Fd3VUS QQ Group: `873569894`
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/inisis/OnnxSlim/main/assets/logo/onnxslim-banner-light.svg#gh-light-mode-only" alt="OnnxSlim Logo" width="640"/>
|
|
3
|
+
<img src="https://raw.githubusercontent.com/inisis/OnnxSlim/main/assets/logo/onnxslim-banner.svg#gh-dark-mode-only" alt="OnnxSlim Logo" width="640"/>
|
|
4
|
+
</p>
|
|
5
|
+
|
|
6
|
+
<p align="center">
|
|
7
|
+
<a href="https://pypi.org/project/onnxslim">
|
|
8
|
+
<img src="https://img.shields.io/pypi/v/onnxslim?color=blue" />
|
|
9
|
+
</a>
|
|
10
|
+
<a href="https://pypi.org/project/onnxslim">
|
|
11
|
+
<img src="https://static.pepy.tech/badge/onnxslim/month" />
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://pypi.org/project/onnxslim">
|
|
14
|
+
<img src="https://static.pepy.tech/badge/onnxslim" />
|
|
15
|
+
</a>
|
|
16
|
+
<a href="https://github.com/inisis/onnxslim/actions/workflows/ci.yaml">
|
|
17
|
+
<img src="https://github.com/inisis/onnxslim/actions/workflows/ci.yml/badge.svg" />
|
|
18
|
+
</a>
|
|
19
|
+
<a href="https://codecov.io/gh/inisis/onnxslim" >
|
|
20
|
+
<img src="https://codecov.io/gh/inisis/onnxslim/branch/main/graph/badge.svg?token=C69ZH6802N"/>
|
|
21
|
+
</a>
|
|
22
|
+
<a href="https://muhammadrizwanmunawar.medium.com/boost-onnx-load-speed-by-10-15-with-onnxslims-python-package-d401eb8c2e69">
|
|
23
|
+
<img src="https://img.shields.io/badge/Blog-OnnxSlim?style=flat&label=OnnxSlim" />
|
|
24
|
+
</a>
|
|
25
|
+
<a href="https://deepwiki.com/inisis/OnnxSlim"><img src="https://img.shields.io/badge/DeepWiki-inisis%2FOnnxSlim-blue.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAyCAYAAAAnWDnqAAAAAXNSR0IArs4c6QAAA05JREFUaEPtmUtyEzEQhtWTQyQLHNak2AB7ZnyXZMEjXMGeK/AIi+QuHrMnbChYY7MIh8g01fJoopFb0uhhEqqcbWTp06/uv1saEDv4O3n3dV60RfP947Mm9/SQc0ICFQgzfc4CYZoTPAswgSJCCUJUnAAoRHOAUOcATwbmVLWdGoH//PB8mnKqScAhsD0kYP3j/Yt5LPQe2KvcXmGvRHcDnpxfL2zOYJ1mFwrryWTz0advv1Ut4CJgf5uhDuDj5eUcAUoahrdY/56ebRWeraTjMt/00Sh3UDtjgHtQNHwcRGOC98BJEAEymycmYcWwOprTgcB6VZ5JK5TAJ+fXGLBm3FDAmn6oPPjR4rKCAoJCal2eAiQp2x0vxTPB3ALO2CRkwmDy5WohzBDwSEFKRwPbknEggCPB/imwrycgxX2NzoMCHhPkDwqYMr9tRcP5qNrMZHkVnOjRMWwLCcr8ohBVb1OMjxLwGCvjTikrsBOiA6fNyCrm8V1rP93iVPpwaE+gO0SsWmPiXB+jikdf6SizrT5qKasx5j8ABbHpFTx+vFXp9EnYQmLx02h1QTTrl6eDqxLnGjporxl3NL3agEvXdT0WmEost648sQOYAeJS9Q7bfUVoMGnjo4AZdUMQku50McDcMWcBPvr0SzbTAFDfvJqwLzgxwATnCgnp4wDl6Aa+Ax283gghmj+vj7feE2KBBRMW3FzOpLOADl0Isb5587h/U4gGvkt5v60Z1VLG8BhYjbzRwyQZemwAd6cCR5/XFWLYZRIMpX39AR0tjaGGiGzLVyhse5C9RKC6ai42ppWPKiBagOvaYk8lO7DajerabOZP46Lby5wKjw1HCRx7p9sVMOWGzb/vA1hwiWc6jm3MvQDTogQkiqIhJV0nBQBTU+3okKCFDy9WwferkHjtxib7t3xIUQtHxnIwtx4mpg26/HfwVNVDb4oI9RHmx5WGelRVlrtiw43zboCLaxv46AZeB3IlTkwouebTr1y2NjSpHz68WNFjHvupy3q8TFn3Hos2IAk4Ju5dCo8B3wP7VPr/FGaKiG+T+v+TQqIrOqMTL1VdWV1DdmcbO8KXBz6esmYWYKPwDL5b5FA1a0hwapHiom0r/cKaoqr+27/XcrS5UwSMbQAAAABJRU5ErkJggg==" alt="DeepWiki"></a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
<p align="center">
|
|
29
|
+
<a href="./README.md">English</a> | <b>简体中文</b>
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
OnnxSlim 可以帮助您精简 ONNX 模型,减少算子数量,同时保持精度不变,提升推理速度。
|
|
33
|
+
|
|
34
|
+
- 🚀 2026/01/04: 下载量突破 500 万
|
|
35
|
+
- 🚀 2025/11/29: PyPI 排名前 1%
|
|
36
|
+
- 🚀 2025/11/27: OnnxSlim 已合并至 [NVIDIA TensorRT-Model-Optimizer](https://github.com/NVIDIA/TensorRT-Model-Optimizer) 🤗🤗🤗
|
|
37
|
+
- 🚀 2025/05/17: OnnxSlim 已合并至 [HuggingFace optimum](https://github.com/huggingface/optimum) 🤗🤗🤗
|
|
38
|
+
- 🚀 2025/04/30: 在 [AICAS 2025 大模型推理优化挑战赛](https://tianchi.aliyun.com/competition/entrance/532289/customize588)中荣获第一名
|
|
39
|
+
- 🚀 2025/01/28: 下载量突破 100 万
|
|
40
|
+
- 🚀 2024/06/23: OnnxSlim 已合并至 [transformers.js](https://github.com/huggingface/transformers.js) 🤗🤗🤗
|
|
41
|
+
- 🚀 2024/06/02: OnnxSlim 已合并至 [ultralytics](https://github.com/ultralytics/ultralytics) ❤️❤️❤️
|
|
42
|
+
- 🚀 2024/04/30: 在 Arm 和平头哥举办的 [AICAS 2024 大模型推理优化挑战赛](https://tianchi.aliyun.com/competition/entrance/532170/customize440)中荣获第一名
|
|
43
|
+
- 🚀 2024/01/25: OnnxSlim 已合并至 [mnn-llm](https://github.com/wangzhaode/mnn-llm),性能提升 5%
|
|
44
|
+
|
|
45
|
+
# 安装
|
|
46
|
+
|
|
47
|
+
## 使用预构建版本
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install onnxslim
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## 从源码安装
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install git+https://github.com/inisis/OnnxSlim@main
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 从本地安装
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
git clone https://github.com/inisis/OnnxSlim && cd OnnxSlim/
|
|
63
|
+
pip install .
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
# 使用方法
|
|
67
|
+
|
|
68
|
+
## 命令行
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
onnxslim your_onnx_model slimmed_onnx_model
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
<div align=left><img src="https://raw.githubusercontent.com/inisis/onnxslim/main/images/onnxslim.gif"></div>
|
|
75
|
+
|
|
76
|
+
## 代码调用
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
import onnx
|
|
80
|
+
import onnxslim
|
|
81
|
+
|
|
82
|
+
model = onnx.load("model.onnx")
|
|
83
|
+
slimmed_model = onnxslim.slim(model)
|
|
84
|
+
|
|
85
|
+
if slimmed_model:
|
|
86
|
+
onnx.save(slimmed_model, "slimmed_model.onnx")
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
更多用法请参考 `onnxslim -h` 或查看我们的[示例](./examples)
|
|
90
|
+
|
|
91
|
+
# 使用 OnnxSlim 的项目
|
|
92
|
+
|
|
93
|
+
<table style="width:100%; border-collapse:separate; border-spacing:10px;">
|
|
94
|
+
<tr>
|
|
95
|
+
<td style="vertical-align:middle;">
|
|
96
|
+
<img src="https://avatars.githubusercontent.com/u/1728152?s=200&v=4" width="22" height="22" style="vertical-align:middle; margin-right:8px;"/>
|
|
97
|
+
<a href="https://github.com/NVIDIA/TensorRT-Model-Optimizer" target="_blank">NVIDIA/TensorRT-Model-Optimizer</a>
|
|
98
|
+
</td>
|
|
99
|
+
<td style="vertical-align:middle;">
|
|
100
|
+
<img src="https://avatars.githubusercontent.com/u/1961952?s=48&v=4" width="22" height="22" style="vertical-align:middle; margin-right:8px;"/>
|
|
101
|
+
<a href="https://github.com/alibaba/MNN" target="_blank">alibaba/MNN</a>
|
|
102
|
+
</td>
|
|
103
|
+
</tr>
|
|
104
|
+
<tr>
|
|
105
|
+
<td style="vertical-align:middle;">
|
|
106
|
+
<img src="https://avatars.githubusercontent.com/u/26833451?s=48&v=4" width="22" height="22" style="vertical-align:middle; margin-right:8px;"/>
|
|
107
|
+
<a href="https://github.com/ultralytics/ultralytics" target="_blank">ultralytics/ultralytics</a>
|
|
108
|
+
</td>
|
|
109
|
+
<td style="vertical-align:middle;">
|
|
110
|
+
<img src="https://avatars.githubusercontent.com/u/131524?s=48&v=4" width="22" height="22" style="vertical-align:middle; margin-right:8px;"/>
|
|
111
|
+
<a href="https://github.com/mozilla/smart_autofill" target="_blank">Mozilla/smart_autofill</a>
|
|
112
|
+
</td>
|
|
113
|
+
</tr>
|
|
114
|
+
<tr>
|
|
115
|
+
<td style="vertical-align:middle;">
|
|
116
|
+
<img src="https://avatars.githubusercontent.com/u/1961952?s=48&v=4" width="22" height="22" style="vertical-align:middle; margin-right:8px;"/>
|
|
117
|
+
<a href="https://github.com/wangzhaode/mnn-llm" target="_blank">alibaba/MNN-LLM</a>
|
|
118
|
+
</td>
|
|
119
|
+
<td style="vertical-align:middle;">
|
|
120
|
+
<img src="https://avatars.githubusercontent.com/u/25720743?s=48&v=4" width="22" height="22" style="vertical-align:middle; margin-right:8px;"/>
|
|
121
|
+
<a href="https://github.com/huggingface/transformers.js" target="_blank">huggingface/transformers.js</a>
|
|
122
|
+
</td>
|
|
123
|
+
</tr>
|
|
124
|
+
<tr>
|
|
125
|
+
<td style="vertical-align:middle;">
|
|
126
|
+
<img src="https://avatars.githubusercontent.com/u/25720743?s=48&v=4" width="22" height="22" style="vertical-align:middle; margin-right:8px;"/>
|
|
127
|
+
<a href="https://github.com/huggingface/optimum" target="_blank">huggingface/optimum</a>
|
|
128
|
+
</td>
|
|
129
|
+
<td style="vertical-align:middle;">
|
|
130
|
+
<img src="https://avatars.githubusercontent.com/u/23534030?s=48&v=4" width="22" height="22" style="vertical-align:middle; margin-right:8px;"/>
|
|
131
|
+
<a href="https://github.com/PaddlePaddle/PaddleOCR" target="_blank">PaddlePaddle/PaddleOCR</a>
|
|
132
|
+
</td>
|
|
133
|
+
</tr>
|
|
134
|
+
<tr>
|
|
135
|
+
<td style="vertical-align:middle;">
|
|
136
|
+
<img src="https://avatars.githubusercontent.com/u/109945100?s=48&v=4" width="22" height="22" style="vertical-align:middle; margin-right:8px;"/>
|
|
137
|
+
<a href="https://github.com/modelscope/FunASR" target="_blank">ModelScope/FunASR</a>
|
|
138
|
+
</td>
|
|
139
|
+
<td style="vertical-align:middle;">
|
|
140
|
+
<img src="https://avatars.githubusercontent.com/u/111754012?s=48&v=4" width="22" height="22" style="vertical-align:middle; margin-right:8px;"/>
|
|
141
|
+
<a href="https://github.com/CVCUDA/CV-CUDA" target="_blank">CVCUDA/CV-CUDA</a>
|
|
142
|
+
</td>
|
|
143
|
+
</tr>
|
|
144
|
+
<tr>
|
|
145
|
+
<td style="vertical-align:middle;">
|
|
146
|
+
<img src="https://avatars.githubusercontent.com/u/86091366?s=48&v=4" width="22" height="22" style="vertical-align:middle; margin-right:8px;"/>
|
|
147
|
+
<a href="https://github.com/THU-MIG/yolov10" target="_blank">THU-MIG/yolov10</a>
|
|
148
|
+
</td>
|
|
149
|
+
<td style="vertical-align:middle;">
|
|
150
|
+
<img src="https://avatars.githubusercontent.com/u/48153283?s=48&v=4" width="22" height="22" style="vertical-align:middle; margin-right:8px;"/>
|
|
151
|
+
<a href="https://github.com/sunsmarterjie/yolov12" target="_blank">sunsmarterjie/yolov12</a>
|
|
152
|
+
</td>
|
|
153
|
+
</tr>
|
|
154
|
+
<tr>
|
|
155
|
+
<td style="vertical-align:middle;">
|
|
156
|
+
<img src="https://avatars.githubusercontent.com/u/147458884?s=48&v=4" width="22" height="22" style="vertical-align:middle; margin-right:8px;"/>
|
|
157
|
+
<a href="https://github.com/nndeploy/nndeploy" target="_blank">nndeploy/nndeploy</a>
|
|
158
|
+
</td>
|
|
159
|
+
<td style="vertical-align:middle;">
|
|
160
|
+
<img src="https://avatars.githubusercontent.com/u/126587470?s=48&v=4" width="22" height="22" style="vertical-align:middle; margin-right:8px;"/>
|
|
161
|
+
<a href="https://github.com/deepghs/imgutils" target="_blank">deepghs/imgutils</a>
|
|
162
|
+
</td>
|
|
163
|
+
</tr>
|
|
164
|
+
<tr>
|
|
165
|
+
<td style="vertical-align:middle;">
|
|
166
|
+
<img src="https://avatars.githubusercontent.com/u/430818?s=48&v=4" width="22" height="22" style="vertical-align:middle; margin-right:8px;"/>
|
|
167
|
+
<a href="https://github.com/amd/Quark" target="_blank">amd/Quark</a>
|
|
168
|
+
</td>
|
|
169
|
+
<td style="vertical-align:middle;">
|
|
170
|
+
</td>
|
|
171
|
+
</tr>
|
|
172
|
+
</table>
|
|
173
|
+
|
|
174
|
+
# 参考项目
|
|
175
|
+
|
|
176
|
+
> - [onnx-graphsurgeon](https://github.com/NVIDIA/TensorRT/tree/main/tools/onnx-graphsurgeon)
|
|
177
|
+
> - [Polygraphy](https://github.com/NVIDIA/TensorRT/tree/main/tools/Polygraphy/polygraphy)
|
|
178
|
+
> - [onnx-simplifier](https://github.com/daquexian/onnx-simplifier)
|
|
179
|
+
> - [tabulate](https://github.com/astanin/python-tabulate)
|
|
180
|
+
> - [onnxruntime](https://github.com/microsoft/onnxruntime)
|
|
181
|
+
|
|
182
|
+
# 贡献者
|
|
183
|
+
|
|
184
|
+
<a href="https://github.com/inisis/onnxslim/graphs/contributors">
|
|
185
|
+
<img src="https://contrib.rocks/image?repo=inisis/onnxslim" />
|
|
186
|
+
</a>
|
|
187
|
+
|
|
188
|
+
# 联系我们
|
|
189
|
+
|
|
190
|
+
Discord: https://discord.gg/nRw2Fd3VUS QQ 群: `873569894`
|
|
@@ -53,10 +53,17 @@ def dead_node_elimination(graph, is_subgraph=False):
|
|
|
53
53
|
node.inputs.pop(1)
|
|
54
54
|
node.inputs.insert(1, reshape_const)
|
|
55
55
|
logger.debug(f"replacing {node.op} op: {node.name}")
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
elif node.op == "Slice":
|
|
57
|
+
if (node.inputs[0].shape and node.outputs[0].shape
|
|
58
|
+
and node.inputs[0].shape == node.outputs[0].shape
|
|
59
|
+
and all(isinstance(item, int) for item in node.inputs[0].shape)):
|
|
60
|
+
|
|
61
|
+
# Check if slice is a no-op by analyzing parameters directly
|
|
62
|
+
# Slice inputs: data, starts, ends, [axes], [steps]
|
|
63
|
+
if is_noop_slice(node):
|
|
64
|
+
node.erase()
|
|
65
|
+
logger.debug(f"removing {node.op} op: {node.name}")
|
|
66
|
+
|
|
60
67
|
elif node.op == "Mul":
|
|
61
68
|
if (isinstance(node.inputs[1], Constant) and isinstance(node.inputs[0], Variable)) or (
|
|
62
69
|
isinstance(node.inputs[0], Constant) and isinstance(node.inputs[1], Variable)
|
|
@@ -153,3 +160,77 @@ def get_constant_variable(node, return_idx=False):
|
|
|
153
160
|
for idx, input in enumerate(list(node.inputs)):
|
|
154
161
|
if isinstance(input, Constant):
|
|
155
162
|
return (idx, input) if return_idx else input
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def is_noop_slice(node):
|
|
166
|
+
"""Check if a Slice node is a no-op by analyzing its parameters directly.
|
|
167
|
+
|
|
168
|
+
A Slice is a no-op when it extracts the entire tensor, i.e., for each sliced axis:
|
|
169
|
+
- start == 0 (or equivalent negative index)
|
|
170
|
+
- end >= dim_size (or is INT_MAX-like value)
|
|
171
|
+
- step == 1
|
|
172
|
+
"""
|
|
173
|
+
# Slice inputs: data, starts, ends, [axes], [steps]
|
|
174
|
+
if len(node.inputs) < 3:
|
|
175
|
+
return False
|
|
176
|
+
|
|
177
|
+
data_shape = node.inputs[0].shape
|
|
178
|
+
if not data_shape or not all(isinstance(d, int) for d in data_shape):
|
|
179
|
+
return False
|
|
180
|
+
|
|
181
|
+
# Get starts and ends (required)
|
|
182
|
+
starts_input = node.inputs[1]
|
|
183
|
+
ends_input = node.inputs[2]
|
|
184
|
+
|
|
185
|
+
if not isinstance(starts_input, Constant) or not isinstance(ends_input, Constant):
|
|
186
|
+
return False
|
|
187
|
+
|
|
188
|
+
starts = starts_input.values.flatten().tolist()
|
|
189
|
+
ends = ends_input.values.flatten().tolist()
|
|
190
|
+
|
|
191
|
+
# Get axes (optional, defaults to [0, 1, 2, ...])
|
|
192
|
+
if len(node.inputs) > 3 and isinstance(node.inputs[3], Constant):
|
|
193
|
+
axes = node.inputs[3].values.flatten().tolist()
|
|
194
|
+
else:
|
|
195
|
+
axes = list(range(len(starts)))
|
|
196
|
+
|
|
197
|
+
# Get steps (optional, defaults to [1, 1, 1, ...])
|
|
198
|
+
if len(node.inputs) > 4 and isinstance(node.inputs[4], Constant):
|
|
199
|
+
steps = node.inputs[4].values.flatten().tolist()
|
|
200
|
+
else:
|
|
201
|
+
steps = [1] * len(starts)
|
|
202
|
+
|
|
203
|
+
# Check each axis
|
|
204
|
+
ndim = len(data_shape)
|
|
205
|
+
for start, end, axis, step in zip(starts, ends, axes, steps):
|
|
206
|
+
# Normalize negative axis
|
|
207
|
+
if axis < 0:
|
|
208
|
+
axis = ndim + axis
|
|
209
|
+
|
|
210
|
+
if axis < 0 or axis >= ndim:
|
|
211
|
+
return False
|
|
212
|
+
|
|
213
|
+
dim_size = data_shape[axis]
|
|
214
|
+
|
|
215
|
+
# Step must be 1 for no-op
|
|
216
|
+
if step != 1:
|
|
217
|
+
return False
|
|
218
|
+
|
|
219
|
+
# Normalize negative start index
|
|
220
|
+
if start < 0:
|
|
221
|
+
start = max(0, dim_size + start)
|
|
222
|
+
|
|
223
|
+
# Start must be 0
|
|
224
|
+
if start != 0:
|
|
225
|
+
return False
|
|
226
|
+
|
|
227
|
+
# Normalize negative end index
|
|
228
|
+
if end < 0:
|
|
229
|
+
end = dim_size + end
|
|
230
|
+
|
|
231
|
+
# End must cover the entire dimension
|
|
232
|
+
# Common patterns: end == dim_size, or end is a large value like INT_MAX
|
|
233
|
+
if end < dim_size:
|
|
234
|
+
return False
|
|
235
|
+
|
|
236
|
+
return True
|