onnxslim 0.1.81__tar.gz → 0.1.82__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.81 → onnxslim-0.1.82}/PKG-INFO +1 -1
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/optimization/dead_node_elimination.py +4 -4
- {onnxslim-0.1.81 → onnxslim-0.1.82}/pyproject.toml +1 -1
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/test_dead_node_elimination.py +21 -21
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/test_modelzoo.py +15 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/.codespellignore +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/.github/FUNDING.yml +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/.github/workflows/ci.yml +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/.github/workflows/format.yml +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/.github/workflows/nightly-test.yml +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/.github/workflows/python-publish.yml +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/.gitignore +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/.prettierignore +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/CODE_OF_CONDUCT.md +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/CONTRIBUTING.md +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/LICENSE +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/README.md +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/assets/logo/onnxslim-banner-light.svg +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/assets/logo/onnxslim-banner.svg +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/assets/logo/onnxslim-logo-os-bw.svg +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/assets/logo/onnxslim-logo-os-white.svg +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/assets/logo/onnxslim-logo-os.svg +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/bin/onnxslim +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/docs/_static/style.css +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/docs/_templates/layout.html +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/docs/conf.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/docs/index.rst +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/docs/main/toc.rst +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/docs/requirements.txt +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/examples/Boost-onnx-load-speed-by-10/342/200/22315-percent-with-onnxslim-python-package.ipynb" +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/examples/common_subexpression_elimination/README.md +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/examples/common_subexpression_elimination/cse_demo.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/examples/input_shape_modification/README.md +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/examples/model_inspect/README.md +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/examples/output_modification/README.md +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/format.sh +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/images/after_cse.png +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/images/before_cse.png +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/images/cse.png +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/images/input_shape_modification.jpg +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/images/model_inspect.jpg +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/images/onnxslim.gif +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/images/output_modification.jpg +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/__init__.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/__main__.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/argparser.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/cli/__init__.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/cli/_main.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/__init__.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/optimization/__init__.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/optimization/subexpression_elimination.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/optimization/weight_tying.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/pattern/__init__.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/pattern/elimination/__init__.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/pattern/elimination/concat.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/pattern/elimination/reshape.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/pattern/elimination/reshape_as.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/pattern/elimination/slice.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/pattern/elimination/unsqueeze.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/pattern/fusion/__init__.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/pattern/fusion/concat_reshape.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/pattern/fusion/convadd.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/pattern/fusion/convbn.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/pattern/fusion/convmul.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/pattern/fusion/gelu.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/pattern/fusion/gemm.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/pattern/fusion/padconv.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/pattern/fusion/reduce.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/core/pattern/registry.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/misc/__init__.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/misc/tabulate.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/__init__.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/_sympy/__init__.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/_sympy/functions.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/_sympy/numbers.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/_sympy/printers.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/_sympy/solve.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/_sympy/symbol.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/__init__.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/exporters/__init__.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/exporters/base_exporter.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/exporters/onnx_exporter.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/graph_pattern/__init__.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/graph_pattern/graph_pattern.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/importers/__init__.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/importers/base_importer.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/importers/onnx_importer.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/ir/__init__.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/ir/function.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/ir/graph.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/ir/node.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/ir/tensor.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/logger/__init__.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/logger/logger.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/util/__init__.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/util/exception.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/util/misc.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/symbolic_shape_infer.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/utils.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/version.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/conftest.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/test_benchmark.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/test_cli_main.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/test_coverage.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/test_elimination_patterns.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/test_folder.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/test_fusion_patterns.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/test_nvidia.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/test_onnx_nets.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/test_onnxslim.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/test_pattern_generator.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/test_pattern_matcher.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/test_shape_folding.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/test_subexpression_elimination.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/test_symbolic_shape_inference.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/test_utils.py +0 -0
- {onnxslim-0.1.81 → onnxslim-0.1.82}/tests/utils.py +0 -0
|
@@ -53,10 +53,10 @@ 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
|
-
elif node.op == "Slice":
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
# elif node.op == "Slice":
|
|
57
|
+
# if node.inputs[0].shape and node.outputs[0].shape and node.inputs[0].shape == node.outputs[0].shape and all(isinstance(item, int) for item in node.inputs[0].shape):
|
|
58
|
+
# node.erase()
|
|
59
|
+
# logger.debug(f"removing {node.op} op: {node.name}")
|
|
60
60
|
elif node.op == "Mul":
|
|
61
61
|
if (isinstance(node.inputs[1], Constant) and isinstance(node.inputs[0], Variable)) or (
|
|
62
62
|
isinstance(node.inputs[0], Constant) and isinstance(node.inputs[1], Variable)
|
|
@@ -366,34 +366,34 @@ class TestDeadNodeElimination:
|
|
|
366
366
|
# Split node with single output should be eliminated
|
|
367
367
|
assert final_node_count <= initial_node_count
|
|
368
368
|
|
|
369
|
-
def test_noop_slice_elimination(self, request):
|
|
370
|
-
|
|
369
|
+
# def test_noop_slice_elimination(self, request):
|
|
370
|
+
# """Test that Slice nodes that don't change the tensor are eliminated.
|
|
371
371
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
372
|
+
# Construct the ONNX graph manually to ensure a `Slice` node exists
|
|
373
|
+
# with starts/ends/axes/constants that represent a no-op slice.
|
|
374
|
+
# """
|
|
375
375
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
376
|
+
# # Create a simple graph with an explicit Slice node
|
|
377
|
+
# input_tensor = gs.Variable(name="input", dtype=np.float32, shape=(1, 512, 8, 8))
|
|
378
|
+
# output_tensor = gs.Variable(name="output", dtype=np.float32, shape=(1, 512, 8, 8))
|
|
379
379
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
380
|
+
# starts = gs.Constant(name="starts", values=np.array([0, 0], dtype=np.int64))
|
|
381
|
+
# ends = gs.Constant(name="ends", values=np.array([8, 8], dtype=np.int64))
|
|
382
|
+
# axes = gs.Constant(name="axes", values=np.array([2, 3], dtype=np.int64))
|
|
383
383
|
|
|
384
|
-
|
|
384
|
+
# slice_node = gs.Node(op="Slice", inputs=[input_tensor, starts, ends, axes], outputs=[output_tensor])
|
|
385
385
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
386
|
+
# graph = gs.Graph(
|
|
387
|
+
# inputs=[input_tensor],
|
|
388
|
+
# outputs=[output_tensor],
|
|
389
|
+
# nodes=[slice_node],
|
|
390
|
+
# )
|
|
391
391
|
|
|
392
|
-
|
|
393
|
-
|
|
392
|
+
# dead_node_elimination(graph)
|
|
393
|
+
# graph.cleanup().toposort()
|
|
394
394
|
|
|
395
|
-
|
|
396
|
-
|
|
395
|
+
# # Slice that does not change shape should be eliminated
|
|
396
|
+
# assert not any(node.op == "Slice" for node in graph.nodes)
|
|
397
397
|
|
|
398
398
|
def test_check_shape_function(self):
|
|
399
399
|
"""Test the check_shape helper function."""
|
|
@@ -193,6 +193,21 @@ class TestModelZoo:
|
|
|
193
193
|
assert len(summary.op_info["/avgpool/GlobalAveragePool"].outputs) == 1
|
|
194
194
|
assert summary.op_info["/avgpool/GlobalAveragePool"].outputs[0].shape == (1, 2048, 1, 1)
|
|
195
195
|
|
|
196
|
+
def test_yolo11n(self, request):
|
|
197
|
+
name = request.node.originalname[len("test_") :]
|
|
198
|
+
filename = f"{MODELZOO_PATH}/{name}/{name}.onnx"
|
|
199
|
+
|
|
200
|
+
with tempfile.TemporaryDirectory() as tempdir:
|
|
201
|
+
slim(filename, os.path.join(tempdir, f"{name}_slim.onnx"))
|
|
202
|
+
input = np.zeros((1, 3, 256, 256), dtype=np.float32)
|
|
203
|
+
|
|
204
|
+
ort_sess = ort.InferenceSession(os.path.join(tempdir, f"{name}_slim.onnx"))
|
|
205
|
+
ort_sess.run(None, {"images": input})
|
|
206
|
+
|
|
207
|
+
summary = summarize_model(os.path.join(tempdir, f"{name}_slim.onnx"), tag=request.node.name)
|
|
208
|
+
assert summary.op_type_counts["Add"] == 25
|
|
209
|
+
assert summary.op_type_counts["Concat"] == 44
|
|
210
|
+
|
|
196
211
|
|
|
197
212
|
if __name__ == "__main__":
|
|
198
213
|
import sys
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/exporters/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/graph_pattern/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/importers/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/logger/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{onnxslim-0.1.81 → onnxslim-0.1.82}/onnxslim/third_party/onnx_graphsurgeon/util/exception.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|