onnxslim 0.1.73__py3-none-any.whl → 0.1.75__py3-none-any.whl
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/core/pattern/fusion/convbn.py +4 -4
- onnxslim/core/pattern/fusion/padconv.py +3 -2
- onnxslim/third_party/symbolic_shape_infer.py +9 -3
- onnxslim/version.py +1 -1
- {onnxslim-0.1.73.dist-info → onnxslim-0.1.75.dist-info}/METADATA +3 -2
- {onnxslim-0.1.73.dist-info → onnxslim-0.1.75.dist-info}/RECORD +11 -11
- {onnxslim-0.1.73.dist-info → onnxslim-0.1.75.dist-info}/WHEEL +0 -0
- {onnxslim-0.1.73.dist-info → onnxslim-0.1.75.dist-info}/entry_points.txt +0 -0
- {onnxslim-0.1.73.dist-info → onnxslim-0.1.75.dist-info}/licenses/LICENSE +0 -0
- {onnxslim-0.1.73.dist-info → onnxslim-0.1.75.dist-info}/top_level.txt +0 -0
- {onnxslim-0.1.73.dist-info → onnxslim-0.1.75.dist-info}/zip-safe +0 -0
|
@@ -36,21 +36,21 @@ class ConvBatchNormMatcher(PatternMatcher):
|
|
|
36
36
|
bn_bias = bn_node.inputs[2].values
|
|
37
37
|
bn_running_mean = bn_node.inputs[3].values
|
|
38
38
|
bn_running_var = bn_node.inputs[4].values
|
|
39
|
-
bn_eps = bn_node.attrs
|
|
39
|
+
bn_eps = bn_node.attrs.get("epsilon", 1.0e-5)
|
|
40
40
|
|
|
41
41
|
if len(conv_transpose_node.inputs) == 2:
|
|
42
42
|
conv_transpose_bias = np.zeros_like(bn_running_mean)
|
|
43
43
|
else:
|
|
44
44
|
conv_transpose_bias = conv_transpose_node.inputs[2].values
|
|
45
45
|
|
|
46
|
-
bn_var_rsqrt =
|
|
46
|
+
bn_var_rsqrt = bn_scale / np.sqrt(bn_running_var + bn_eps)
|
|
47
47
|
shape = [1] * len(conv_transpose_weight.shape)
|
|
48
48
|
if bn_node.i(0).op == "Conv":
|
|
49
49
|
shape[0] = -1
|
|
50
50
|
else:
|
|
51
51
|
shape[1] = -1
|
|
52
|
-
conv_w = conv_transpose_weight *
|
|
53
|
-
conv_b = (conv_transpose_bias - bn_running_mean) * bn_var_rsqrt
|
|
52
|
+
conv_w = conv_transpose_weight * bn_var_rsqrt.reshape(shape)
|
|
53
|
+
conv_b = (conv_transpose_bias - bn_running_mean) * bn_var_rsqrt + bn_bias
|
|
54
54
|
|
|
55
55
|
inputs = []
|
|
56
56
|
inputs.append(next(iter(conv_transpose_node.inputs)))
|
|
@@ -68,9 +68,10 @@ class PadConvMatcher(PatternMatcher):
|
|
|
68
68
|
pad_node.inputs.clear()
|
|
69
69
|
pad_node.outputs.clear()
|
|
70
70
|
|
|
71
|
-
conv_pads = attrs["pads"]
|
|
72
71
|
pads = pad_value[2:conv_weight_dim] + pad_value[conv_weight_dim + 2 :]
|
|
73
|
-
|
|
72
|
+
if hasattr(attrs, "pads"):
|
|
73
|
+
conv_pads = attrs["pads"]
|
|
74
|
+
pads = [pad + conv_pad for pad, conv_pad in zip(pads, conv_pads)]
|
|
74
75
|
|
|
75
76
|
attrs["pads"] = pads
|
|
76
77
|
match_case[conv_node.name] = {
|
|
@@ -359,6 +359,7 @@ class SymbolicShapeInference:
|
|
|
359
359
|
for i in self.out_mp_.graph.initializer
|
|
360
360
|
}
|
|
361
361
|
)
|
|
362
|
+
self.known_vi_.update({i.name: i for i in list(self.out_mp_.graph.output)})
|
|
362
363
|
|
|
363
364
|
def _merge_symbols(self, dims):
|
|
364
365
|
"""Merge dimension symbols, handling automatic merging and validation of symbolic dimensions."""
|
|
@@ -532,6 +533,7 @@ class SymbolicShapeInference:
|
|
|
532
533
|
initializers = []
|
|
533
534
|
if (get_opset(self.out_mp_) >= 9) and (
|
|
534
535
|
node.op_type == "Unsqueeze" or node.op_type == "ReduceMax" or node.op_type == "ReduceMean"
|
|
536
|
+
or node.op_type == "DFT" or node.op_type == "ReduceL2" or node.op_type == "ReduceMin"
|
|
535
537
|
):
|
|
536
538
|
initializers = [
|
|
537
539
|
self.initializers_[name]
|
|
@@ -581,9 +583,13 @@ class SymbolicShapeInference:
|
|
|
581
583
|
for i_o in range(len(node.output)):
|
|
582
584
|
o = node.output[i_o]
|
|
583
585
|
if o: # skip optional output
|
|
586
|
+
out = model.graph.output[i_o]
|
|
587
|
+
if not out.type.WhichOneof("value") and o in self.known_vi_: # if empty and already had
|
|
588
|
+
continue
|
|
589
|
+
|
|
584
590
|
vi = self.out_mp_.graph.value_info.add()
|
|
585
591
|
if not skip_infer:
|
|
586
|
-
vi.CopyFrom(
|
|
592
|
+
vi.CopyFrom(out)
|
|
587
593
|
else:
|
|
588
594
|
vi.name = o
|
|
589
595
|
self.known_vi_[o] = vi
|
|
@@ -1843,7 +1849,7 @@ class SymbolicShapeInference:
|
|
|
1843
1849
|
scales = self._try_get_value(node, 2)
|
|
1844
1850
|
sizes = self._try_get_value(node, 3)
|
|
1845
1851
|
if sizes is not None:
|
|
1846
|
-
new_sympy_shape = [sympy.simplify(
|
|
1852
|
+
new_sympy_shape = [sympy.simplify(round(s)) for s in sizes]
|
|
1847
1853
|
self._update_computed_dims(new_sympy_shape)
|
|
1848
1854
|
elif scales is not None:
|
|
1849
1855
|
rank = len(scales)
|
|
@@ -1859,7 +1865,7 @@ class SymbolicShapeInference:
|
|
|
1859
1865
|
else:
|
|
1860
1866
|
scales = list(scales)
|
|
1861
1867
|
new_sympy_shape = [
|
|
1862
|
-
(
|
|
1868
|
+
(round(d * (end - start) * scale))
|
|
1863
1869
|
for d, start, end, scale in zip(input_sympy_shape, roi_start, roi_end, scales)
|
|
1864
1870
|
]
|
|
1865
1871
|
self._update_computed_dims(new_sympy_shape)
|
onnxslim/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.1.
|
|
1
|
+
__version__ = "0.1.75"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: onnxslim
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.75
|
|
4
4
|
Summary: OnnxSlim: A Toolkit to Help Optimize Onnx Model
|
|
5
5
|
Home-page: https://github.com/inisis/OnnxSlim
|
|
6
6
|
Author: inisis
|
|
@@ -36,7 +36,7 @@ Dynamic: summary
|
|
|
36
36
|
|
|
37
37
|
<p align="center">
|
|
38
38
|
<a href="https://pypi.org/project/onnxslim">
|
|
39
|
-
<img src="https://
|
|
39
|
+
<img src="https://img.shields.io/pypi/v/onnxslim?color=blue" />
|
|
40
40
|
</a>
|
|
41
41
|
<a href="https://pypi.org/project/onnxslim">
|
|
42
42
|
<img src="https://static.pepy.tech/badge/onnxslim/week" />
|
|
@@ -131,6 +131,7 @@ For more usage, see onnxslim -h or refer to our [examples](./examples)
|
|
|
131
131
|
- <img src="https://avatars.githubusercontent.com/u/126587470?s=48&v=4" width="22" height="22"/>[deepghs/imgutils](https://github.com/deepghs/imgutils)
|
|
132
132
|
- <img src="https://avatars.githubusercontent.com/u/48153283?s=48&v=4" width="22" height="22"/>[sunsmarterjie/yolov12](https://github.com/sunsmarterjie/yolov12)
|
|
133
133
|
- <img src="https://avatars.githubusercontent.com/u/147458884?s=48&v=4" width="22" height="22"/>[nndeploy/nndeploy](https://github.com/nndeploy/nndeploy)
|
|
134
|
+
- <img src="https://avatars.githubusercontent.com/u/111754012?s=48&v=4" width="22" height="22"/>[CVCUDA/CV-CUDA](https://github.com/CVCUDA/CV-CUDA)
|
|
134
135
|
|
|
135
136
|
# References
|
|
136
137
|
|
|
@@ -2,7 +2,7 @@ onnxslim/__init__.py,sha256=ECHGdxzg4b-4SZaPhxM_KulBi-xDbVcVUbpJc8i6a60,571
|
|
|
2
2
|
onnxslim/__main__.py,sha256=FgDcl6xX8kV_52rB-jPVsmGqidlVhkpe_YhXK75-nFU,75
|
|
3
3
|
onnxslim/argparser.py,sha256=pFv3nEZH2BiHO9ejS4Iq5ZuZ3GrpdyRQJypAyR0xF7w,8942
|
|
4
4
|
onnxslim/utils.py,sha256=Z39vRKAtD7o18NFbf3Qrws9xDg81uBJ9F-RYEFAfqM8,28095
|
|
5
|
-
onnxslim/version.py,sha256=
|
|
5
|
+
onnxslim/version.py,sha256=FJWQjdyjCSq1G0xvL-leZBsVKT8Trwi_Y3BZDT0-Bus,23
|
|
6
6
|
onnxslim/cli/__init__.py,sha256=kxK27cDgWotBOWRs86rbRQf_dtmniKr1GZJeasxfESE,42
|
|
7
7
|
onnxslim/cli/_main.py,sha256=jEKv9q7y_y9g0GsrfXcnk_wyMVej6jhe9QNPChE7yTs,5550
|
|
8
8
|
onnxslim/core/__init__.py,sha256=uDg-Eu29Ezb3txwZf5mN0zQRVuqF-K9BvktE8WBYS4E,8825
|
|
@@ -21,16 +21,16 @@ onnxslim/core/pattern/elimination/unsqueeze.py,sha256=v7Rin3qB6F49ETrxXWEQQxUgtl
|
|
|
21
21
|
onnxslim/core/pattern/fusion/__init__.py,sha256=3ajHvRurL7WHL4tfNsBoLQh6Sq2fyiqH-VsPuftYMGg,183
|
|
22
22
|
onnxslim/core/pattern/fusion/concat_reshape.py,sha256=LvknixTAsSUqUkGSuoEA1QpC-TmBrsx6AHZoeT0gTbI,1615
|
|
23
23
|
onnxslim/core/pattern/fusion/convadd.py,sha256=P1GI7hJAHgDBO17aDDghNxMEhWkFIcqGLIfnpTMGhWk,2432
|
|
24
|
-
onnxslim/core/pattern/fusion/convbn.py,sha256=
|
|
24
|
+
onnxslim/core/pattern/fusion/convbn.py,sha256=696Ev3X9-G2eQbnSqpqkQQeWG8Lrb-3elpQiOQ6MAXE,3333
|
|
25
25
|
onnxslim/core/pattern/fusion/convmul.py,sha256=W2C6H3kWSDUg0he0jfR4tXI5GMi7gsyylQR4aSh-rik,2581
|
|
26
26
|
onnxslim/core/pattern/fusion/gelu.py,sha256=uR67AJ_tL1gboY6VsTdqajHxW3Pbu656UMhCe1mQZDY,1469
|
|
27
27
|
onnxslim/core/pattern/fusion/gemm.py,sha256=Ti9yZAfEprFRvW1FiAD0zvewELOJbRjposIk3yjjXfQ,12928
|
|
28
|
-
onnxslim/core/pattern/fusion/padconv.py,sha256=
|
|
28
|
+
onnxslim/core/pattern/fusion/padconv.py,sha256=eOutev5rOrHuyyw-BRIFzMjcvu9MxXj73kY215GaeG8,3652
|
|
29
29
|
onnxslim/core/pattern/fusion/reduce.py,sha256=dMC7CPlFglrJxugsJWjcc-jQCIa_GIbW1y9K2FRvvcE,2755
|
|
30
30
|
onnxslim/misc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
31
|
onnxslim/misc/tabulate.py,sha256=Pg5uU0UP18HbwG-c8LlA82LbIb_5JWQeuIB1AnturbM,99695
|
|
32
32
|
onnxslim/third_party/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
33
|
-
onnxslim/third_party/symbolic_shape_infer.py,sha256=
|
|
33
|
+
onnxslim/third_party/symbolic_shape_infer.py,sha256=lMqHUSC1c6J3j_cLC5264RxvJrhV8rrephsxE4d-4Zc,152724
|
|
34
34
|
onnxslim/third_party/_sympy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
35
|
onnxslim/third_party/_sympy/functions.py,sha256=s3pKzyjYCKnvlddLFR_H8UmbbcdMB51PRxqhe9zGI9E,8876
|
|
36
36
|
onnxslim/third_party/_sympy/numbers.py,sha256=w1dJJcQkKRzLDCJMn70YTwPtrEWPFrhCJpAsZhukJOk,11383
|
|
@@ -56,10 +56,10 @@ onnxslim/third_party/onnx_graphsurgeon/logger/logger.py,sha256=L12rrwn33RHH-2WLv
|
|
|
56
56
|
onnxslim/third_party/onnx_graphsurgeon/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
57
57
|
onnxslim/third_party/onnx_graphsurgeon/util/exception.py,sha256=KrsHbKEQ4237UbjlODsUzvkXoAY72LZi23ApBeFANWg,786
|
|
58
58
|
onnxslim/third_party/onnx_graphsurgeon/util/misc.py,sha256=kyxInD2SCRLU4wHMeiDEYEHB3871fGks6kQTuF9uATY,8960
|
|
59
|
-
onnxslim-0.1.
|
|
60
|
-
onnxslim-0.1.
|
|
61
|
-
onnxslim-0.1.
|
|
62
|
-
onnxslim-0.1.
|
|
63
|
-
onnxslim-0.1.
|
|
64
|
-
onnxslim-0.1.
|
|
65
|
-
onnxslim-0.1.
|
|
59
|
+
onnxslim-0.1.75.dist-info/licenses/LICENSE,sha256=oHZXw-yrBwdNVGu4JtlZhMgmQHKIZ7BJJlJdhu1HKvI,1062
|
|
60
|
+
onnxslim-0.1.75.dist-info/METADATA,sha256=g6eZ9ALOW_kVXS-7OHcD_DDIpAWYClDye_oNQdRazM8,7773
|
|
61
|
+
onnxslim-0.1.75.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
62
|
+
onnxslim-0.1.75.dist-info/entry_points.txt,sha256=O2QgceCVeGeRhnxRSDRcGiFd0ZNfElwrTiRo1W2V7KA,47
|
|
63
|
+
onnxslim-0.1.75.dist-info/top_level.txt,sha256=EWFTb99i0kc6cC9akqNKp88ipzg17_VZzYN7z1kQNlA,9
|
|
64
|
+
onnxslim-0.1.75.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
65
|
+
onnxslim-0.1.75.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|