tico 0.1.0.dev251123__py3-none-any.whl → 0.2.0.dev260122__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.
- tico/__init__.py +2 -2
- tico/_version.py +1 -0
- tico/passes/convert_conv3d_to_conv2d.py +435 -0
- tico/passes/convert_sym_size_to_circle_shape.py +99 -0
- tico/passes/decompose_batch_norm.py +9 -5
- tico/passes/lower_copy.py +95 -0
- tico/passes/ops.py +4 -0
- tico/quantization/algorithm/fpi_gptq/fpi_gptq.py +87 -12
- tico/quantization/algorithm/fpi_gptq/quantizer.py +9 -8
- tico/quantization/algorithm/gptq/gptq.py +211 -12
- tico/quantization/algorithm/gptq/quantizer.py +18 -12
- tico/quantization/config/fpi_gptq.py +3 -0
- tico/quantization/config/gptq.py +27 -4
- tico/quantization/public_interface.py +0 -10
- tico/quantization/wrapq/quantizer.py +2 -0
- tico/serialize/operators/adapters/onert/llama_attention.py +51 -0
- tico/serialize/operators/op_attention.py +58 -0
- tico/serialize/operators/op_circle_shape.py +64 -0
- tico/serialize/operators/op_dequantize_per_channel.py +1 -0
- tico/serialize/operators/op_dequantize_per_tensor.py +1 -0
- tico/serialize/operators/op_transpose_conv.py +66 -50
- tico/utils/convert.py +16 -1
- tico/utils/padding.py +13 -5
- tico/utils/record_input.py +2 -2
- tico/utils/register_custom_op.py +63 -0
- tico/utils/validate_args_kwargs.py +49 -4
- tico-0.2.0.dev260122.dist-info/METADATA +631 -0
- {tico-0.1.0.dev251123.dist-info → tico-0.2.0.dev260122.dist-info}/RECORD +33 -48
- {tico-0.1.0.dev251123.dist-info → tico-0.2.0.dev260122.dist-info}/WHEEL +1 -1
- {tico-0.1.0.dev251123.dist-info → tico-0.2.0.dev260122.dist-info}/entry_points.txt +0 -1
- tico/quantization/algorithm/pt2e/annotation/__init__.py +0 -1
- tico/quantization/algorithm/pt2e/annotation/annotator.py +0 -208
- tico/quantization/algorithm/pt2e/annotation/config.py +0 -26
- tico/quantization/algorithm/pt2e/annotation/op/__init__.py +0 -21
- tico/quantization/algorithm/pt2e/annotation/op/adaptive_avg_pool2d.py +0 -63
- tico/quantization/algorithm/pt2e/annotation/op/add.py +0 -55
- tico/quantization/algorithm/pt2e/annotation/op/conv2d.py +0 -90
- tico/quantization/algorithm/pt2e/annotation/op/div.py +0 -55
- tico/quantization/algorithm/pt2e/annotation/op/linear.py +0 -92
- tico/quantization/algorithm/pt2e/annotation/op/mean.py +0 -51
- tico/quantization/algorithm/pt2e/annotation/op/mul.py +0 -55
- tico/quantization/algorithm/pt2e/annotation/op/relu6.py +0 -51
- tico/quantization/algorithm/pt2e/annotation/op/rsqrt.py +0 -51
- tico/quantization/algorithm/pt2e/annotation/op/sub.py +0 -55
- tico/quantization/algorithm/pt2e/annotation/spec.py +0 -45
- tico/quantization/algorithm/pt2e/annotation/utils.py +0 -88
- tico/quantization/algorithm/pt2e/quantizer.py +0 -81
- tico/quantization/algorithm/pt2e/transformation/__init__.py +0 -1
- tico/quantization/algorithm/pt2e/transformation/convert_scalars_to_attrs.py +0 -58
- tico/quantization/algorithm/pt2e/utils.py +0 -135
- tico/quantization/config/pt2e.py +0 -25
- tico/serialize/operators/op_copy.py +0 -187
- tico-0.1.0.dev251123.dist-info/METADATA +0 -392
- /tico/{quantization/algorithm/pt2e → serialize/operators/adapters/onert}/__init__.py +0 -0
- {tico-0.1.0.dev251123.dist-info → tico-0.2.0.dev260122.dist-info/licenses}/LICENSE +0 -0
- {tico-0.1.0.dev251123.dist-info → tico-0.2.0.dev260122.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
tico/__init__.py,sha256=
|
|
1
|
+
tico/__init__.py,sha256=6avfcofxPPv7HMPOr8C-r79A9KoVIhHNZUXhZVulEhM,1861
|
|
2
|
+
tico/_version.py,sha256=98m_MDqJurV2D6AnSpzIp5i8c1hXtGO-yyjGtMnGWbs,32
|
|
2
3
|
tico/pt2_to_circle.py,sha256=gu3MD4Iqc0zMZcCZ2IT8oGbyj21CTSbT3Rgd9s2B_9A,2767
|
|
3
4
|
tico/config/__init__.py,sha256=xZzCXjZ84qE-CsBi-dfaL05bqpQ3stKKfTXhnrJRyVs,142
|
|
4
5
|
tico/config/base.py,sha256=q5xMqGxTUZs4mFqt5c7i_y9U00fYgdMGl9nUqIVMlCo,1248
|
|
@@ -14,13 +15,15 @@ tico/passes/cast_clamp_mixed_type_args.py,sha256=m3_HpXLywWmWERfE5lM5PgvjBod7C4B
|
|
|
14
15
|
tico/passes/cast_mixed_type_args.py,sha256=Wd3sCDKJZwdb8GiMWKljm8X5CLFRd8eCz-dmWks15Hc,7763
|
|
15
16
|
tico/passes/const_prop_pass.py,sha256=hDxGgJNiRjsgOArdaoeAOcOOA-nKBvA1W1zcMZQA5yg,11531
|
|
16
17
|
tico/passes/convert_conv1d_to_conv2d.py,sha256=ktS3h158y9rg1sQiW8BZZbflV_dk_UdjBPQnuiOKyzg,5303
|
|
18
|
+
tico/passes/convert_conv3d_to_conv2d.py,sha256=mv6G-e18PBBJIanaQs4QwH4dK0agaQabQzNLlh3cV4c,22755
|
|
17
19
|
tico/passes/convert_expand_to_slice_cat.py,sha256=Fa6b5pqiQNq-QBiEC0e3WkQYf2UEhMgzSTIt4hlzdjc,5470
|
|
18
20
|
tico/passes/convert_layout_op_to_reshape.py,sha256=sCAFjkmVtiKjvDQSAgnjNBHl3_hWXJZElGDXQiTH-7s,2963
|
|
19
21
|
tico/passes/convert_matmul_to_linear.py,sha256=WATtsHk_GzsU0HYovc3UMyEj8ApF2qLbInAsNlQj0nE,9759
|
|
20
22
|
tico/passes/convert_repeat_to_expand_copy.py,sha256=JbtFTmWyfJS2SSd_higP1IEhQeh7wHdN5dmTbbiFVCs,3237
|
|
23
|
+
tico/passes/convert_sym_size_to_circle_shape.py,sha256=ItWD9eJ-Ia-sFg8HNHrwd0ar058ouLF9FgcTNGdu1sI,3845
|
|
21
24
|
tico/passes/convert_to_relu6.py,sha256=9B6OLyF72tMvD-ugV7aBx6l1szwERufNBUaX34pkZ4c,6445
|
|
22
25
|
tico/passes/decompose_addmm.py,sha256=KjnpZjSuA0uvNmKaTN_EMwobcOi3CAB81buORzTDxro,3979
|
|
23
|
-
tico/passes/decompose_batch_norm.py,sha256=
|
|
26
|
+
tico/passes/decompose_batch_norm.py,sha256=fuYX-Z3jrKwYrvgD5pxh3QHjf3uob9DtMl3N7bqJggQ,6610
|
|
24
27
|
tico/passes/decompose_fake_quantize.py,sha256=736srs8SM8K_mLR0WG10LVMMLRkYkBM9OF0k1GCkAW0,5218
|
|
25
28
|
tico/passes/decompose_fake_quantize_tensor_qparams.py,sha256=CalubQ1OYC2l59_TNPOcAnl4VxvameYWIQcy57Z6yjI,13985
|
|
26
29
|
tico/passes/decompose_group_norm.py,sha256=6BqvYtMTPzeIgp8cPA8OFMwEBvb7odcg04IUgwtp7NQ,10120
|
|
@@ -32,11 +35,12 @@ tico/passes/fuse_leading_unsqueeze_reshape.py,sha256=88jwTP35yRyXOk9xdO6YW2OEfdK
|
|
|
32
35
|
tico/passes/fuse_redundant_reshape_to_mean.py,sha256=GhJS1ZKB6Ns4AhwcW3uUQ6q-0N-AzlD32B2EwusUJHg,3761
|
|
33
36
|
tico/passes/legalize_causal_mask_value.py,sha256=0nfUKGd7XSe9Hg5TAi4dUi6Nn6-JRTWCwhULR5AEgqs,4079
|
|
34
37
|
tico/passes/legalize_predefined_layout_operators.py,sha256=3gILn38jzIMDXtMTWpjdROgwmavDC64w115W171encg,18641
|
|
38
|
+
tico/passes/lower_copy.py,sha256=TaeDnztjv9ZfxeOTEUuuFKQNXc676ou1YGNRMbTMDa0,3198
|
|
35
39
|
tico/passes/lower_pow2_to_mul.py,sha256=nfJXa9ZTZMiLg6ownSyvkM4KF2z9tZW34Q3CCWI_vmQ,2402
|
|
36
40
|
tico/passes/lower_to_resize_nearest_neighbor.py,sha256=gbrvTmWSXDPdJ1XJtWGI5mo-uEiauXEG3ELwbKYVPLI,9013
|
|
37
41
|
tico/passes/lower_to_slice.py,sha256=OzlFzK3lBYyYwC3WThsWd94Ob4JINIJF8UaLAtnumzU,7262
|
|
38
42
|
tico/passes/merge_consecutive_cat.py,sha256=ayZNLDA1DFM7Fxxi2Dmk1CujkgUuaVCH1rhQgLrvvOQ,2701
|
|
39
|
-
tico/passes/ops.py,sha256=
|
|
43
|
+
tico/passes/ops.py,sha256=902FF_GjJH9DTXjIL1DWHPqSfkTMrVlWfUDFkTE_LII,3054
|
|
40
44
|
tico/passes/remove_nop.py,sha256=Hf91p_EJAOC6DyWNthash0_UWtEcNc_M7znamQfYQ5Y,2686
|
|
41
45
|
tico/passes/remove_redundant_assert_nodes.py,sha256=rYbTCyuNIXIC-2NreHKBVCuaSUkEQvB_iSRzb26P_EA,1821
|
|
42
46
|
tico/passes/remove_redundant_expand.py,sha256=8yhlMnbog-T9gIK6LKIU0tu0__gfhZzO36g_fJIVVP4,2162
|
|
@@ -47,48 +51,26 @@ tico/passes/remove_redundant_to_copy.py,sha256=tKy4XKkO2l33fMxVPQ_iFkUeFvP15kbPv
|
|
|
47
51
|
tico/passes/restore_linear.py,sha256=xGJdNb-1CrkOKS9BnLbcblkZc6P2vVjKIi-7lRcs7Bk,4111
|
|
48
52
|
tico/passes/segment_index_select.py,sha256=VVCKNLtYRkr9n5lGnlzEuQsQ0WVxEYXGchFrDnB1C40,5189
|
|
49
53
|
tico/quantization/__init__.py,sha256=xYeYEQWeJ6Le7vZVxV208XtukAW68nNQqX9bbjCrBaM,109
|
|
50
|
-
tico/quantization/public_interface.py,sha256=
|
|
54
|
+
tico/quantization/public_interface.py,sha256=eZEe7LUs7CxlaM-UjJsgQTtPdDNDlw37WD-9gmhdvUs,3595
|
|
51
55
|
tico/quantization/quantizer.py,sha256=FYNiqUqoH9vz1bda0I6yuKqJi2KdIfLEBd4EgeC-_t4,2357
|
|
52
56
|
tico/quantization/quantizer_registry.py,sha256=MxVE1_hj1p8FjdAqkLzUhdez3Cqc-V25k6XKOcTkei0,2414
|
|
53
57
|
tico/quantization/algorithm/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
54
58
|
tico/quantization/algorithm/fpi_gptq/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
55
|
-
tico/quantization/algorithm/fpi_gptq/fpi_gptq.py,sha256=
|
|
56
|
-
tico/quantization/algorithm/fpi_gptq/quantizer.py,sha256=
|
|
59
|
+
tico/quantization/algorithm/fpi_gptq/fpi_gptq.py,sha256=FIqfz0a9LklRs3DH66NmWbobiDLW-4GzzwVVq4iH9FI,9502
|
|
60
|
+
tico/quantization/algorithm/fpi_gptq/quantizer.py,sha256=pXrkm8mfdDvY-mgQh4svgAUaiqY82M1ZhcVRV-aRpSk,6811
|
|
57
61
|
tico/quantization/algorithm/gptq/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
58
|
-
tico/quantization/algorithm/gptq/gptq.py,sha256=
|
|
62
|
+
tico/quantization/algorithm/gptq/gptq.py,sha256=OWWXvvYvt-j3iBTQJT4_1pJpxvG4goUOrDJJCxQrhBc,16035
|
|
59
63
|
tico/quantization/algorithm/gptq/quant.py,sha256=Rl4wAOCmlE0U09BtNCDbccaSNohRHCNLwFi3zCqZfNo,5127
|
|
60
|
-
tico/quantization/algorithm/gptq/quantizer.py,sha256=
|
|
64
|
+
tico/quantization/algorithm/gptq/quantizer.py,sha256=dOlaej5vPuNitgDP_cK-gPaoNKkpht7rRfjyyPSiSzc,12189
|
|
61
65
|
tico/quantization/algorithm/gptq/utils.py,sha256=leGKayf-xbSjVwwAGTA5RsxUKrhDiklOQdlsLifjdrs,1811
|
|
62
|
-
tico/quantization/algorithm/pt2e/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
63
|
-
tico/quantization/algorithm/pt2e/quantizer.py,sha256=9K8SGwxi67DA8Hdwc_25ResJiSGLIMDkNyAwtQu3PGM,2673
|
|
64
|
-
tico/quantization/algorithm/pt2e/utils.py,sha256=U9kf3J-1IJdlmFr5EQRcgWKX7AI8Z-tt_H0edKQ0ctQ,4784
|
|
65
|
-
tico/quantization/algorithm/pt2e/annotation/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
66
|
-
tico/quantization/algorithm/pt2e/annotation/annotator.py,sha256=_elaNHBM_7IZdMlhqH_BElJpNijV6AHQU-1MeK8KQ9g,7464
|
|
67
|
-
tico/quantization/algorithm/pt2e/annotation/config.py,sha256=8x6YvixIogXh_PwqhKNb3L6lJyBDFQ_OHotonG_hWD0,977
|
|
68
|
-
tico/quantization/algorithm/pt2e/annotation/spec.py,sha256=76cEij6xFNp51ZO5DOeYbRyWonhgHJO8mi47Q43ll8s,1415
|
|
69
|
-
tico/quantization/algorithm/pt2e/annotation/utils.py,sha256=W6_p_EWPDKbvzfqktZfMm1NqiQeeQME5Pr6bzRPqXuo,3148
|
|
70
|
-
tico/quantization/algorithm/pt2e/annotation/op/__init__.py,sha256=IlBNBqXeopMqHRkR-TPiuN_IkwXaSMXlSVO_9vKceB0,834
|
|
71
|
-
tico/quantization/algorithm/pt2e/annotation/op/adaptive_avg_pool2d.py,sha256=ThDTMHFmGp-sFc4YMMTvNwrZtt2R7RNGaaWxVSZV-Yo,2408
|
|
72
|
-
tico/quantization/algorithm/pt2e/annotation/op/add.py,sha256=-glHoBh49e6RM6W1L3raVjtZ_fLhsmOuzHsoBJUFcY8,2153
|
|
73
|
-
tico/quantization/algorithm/pt2e/annotation/op/conv2d.py,sha256=hYE0R6ZrFwp4GABnsFac_F-gPgfG22G56S8fhSAnorM,3631
|
|
74
|
-
tico/quantization/algorithm/pt2e/annotation/op/div.py,sha256=KKh5C30kCpMIpLV94CE7R8yh51K0hb7t4Owa9yeZ4TU,2135
|
|
75
|
-
tico/quantization/algorithm/pt2e/annotation/op/linear.py,sha256=fOr8Ow0Y61xVQg4IZYSmYFG7CT28UAs1dXP0YQ1498M,3430
|
|
76
|
-
tico/quantization/algorithm/pt2e/annotation/op/mean.py,sha256=ZLfCh3wFftV4gBYe5FeCo0tC8JOZ-5Hde64Sw2gfU_8,1959
|
|
77
|
-
tico/quantization/algorithm/pt2e/annotation/op/mul.py,sha256=_R9dngri5wLsxqeLLeNYaJnTcuPQXtXBkfl23to_0Zs,2150
|
|
78
|
-
tico/quantization/algorithm/pt2e/annotation/op/relu6.py,sha256=1Us4pBf2BSD3ICCWZPNGiBmaiRn_vnKopV_To7bpL7A,1956
|
|
79
|
-
tico/quantization/algorithm/pt2e/annotation/op/rsqrt.py,sha256=Y2Z0mB-8Gk9tkvR4wNGnY0sM6q19YidZd5idbN8ZXTo,1966
|
|
80
|
-
tico/quantization/algorithm/pt2e/annotation/op/sub.py,sha256=u4hg47dVCOCUqJbZV0GFZ5EKDUNu7NV1TMhxUnW_1vA,2135
|
|
81
|
-
tico/quantization/algorithm/pt2e/transformation/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
82
|
-
tico/quantization/algorithm/pt2e/transformation/convert_scalars_to_attrs.py,sha256=Idtoya2RcGKlgUJgC9WqNz0jH3gf6ViuPmsD9ySHbls,2253
|
|
83
66
|
tico/quantization/algorithm/smoothquant/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
84
67
|
tico/quantization/algorithm/smoothquant/observer.py,sha256=OWBKQ3ox6PqeqgevxOjpXvb7uApoqE4YbUBelGhVSN8,3435
|
|
85
68
|
tico/quantization/algorithm/smoothquant/quantizer.py,sha256=pvf6HwW7VzyNFhfEDGwG-YPdPaEoGQfo4nfaeS9Qg_E,3686
|
|
86
69
|
tico/quantization/algorithm/smoothquant/smooth_quant.py,sha256=fxCy4m-BsSjraciSVPFlPhgsOT46RjrOgczQGb7B9TA,11561
|
|
87
70
|
tico/quantization/config/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
88
71
|
tico/quantization/config/base.py,sha256=xg_HCDSuMgYvMd6ENZe4Sm2SYJgMaCBj4cmqaz_lhAs,816
|
|
89
|
-
tico/quantization/config/fpi_gptq.py,sha256=
|
|
90
|
-
tico/quantization/config/gptq.py,sha256=
|
|
91
|
-
tico/quantization/config/pt2e.py,sha256=vSfULljHEnypadUyo-zjVoPSbP8Y2eDzSD_kRTcv6bk,837
|
|
72
|
+
tico/quantization/config/fpi_gptq.py,sha256=s3IqGG_9KGFvSI4vUOdBlsqfHlJ-0OpEKoBzm2WLdGY,1040
|
|
73
|
+
tico/quantization/config/gptq.py,sha256=H9aCm7QsP0_Gwc_aC3ZkFjitbDMe87WWj9gs5L7urGQ,1700
|
|
92
74
|
tico/quantization/config/ptq.py,sha256=zbLQbuiEpO-qlDgyUYTZ3hkVxr3boq5TX0n0QTBHic4,4540
|
|
93
75
|
tico/quantization/config/smoothquant.py,sha256=ntrqjYf6EbO4AE2IA5zn1A_f0AQgU6UqTtVkw6IiUsw,1401
|
|
94
76
|
tico/quantization/evaluation/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
@@ -111,7 +93,7 @@ tico/quantization/wrapq/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9d
|
|
|
111
93
|
tico/quantization/wrapq/dtypes.py,sha256=xfCBtq6mQmUYRwsoFgII6gvRl1raQi0Inj9pznDuKwQ,2236
|
|
112
94
|
tico/quantization/wrapq/mode.py,sha256=lT-T8vIv8YWcwrjT7xXVhOw1g7aoAdh_3PWB-ptPKaI,1052
|
|
113
95
|
tico/quantization/wrapq/qscheme.py,sha256=uwhv7bCxOOXB3I-IKlRyr_u4eXOq48uIqGy4TLDqGxY,1301
|
|
114
|
-
tico/quantization/wrapq/quantizer.py,sha256=
|
|
96
|
+
tico/quantization/wrapq/quantizer.py,sha256=5RtggN1lTnA1a7-TEvcq2KVEPhzv4Ec2idQHJDgSxBI,6625
|
|
115
97
|
tico/quantization/wrapq/examples/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
116
98
|
tico/quantization/wrapq/examples/compare_ppl.py,sha256=iJJEWC7IJpfBHwX0MEiKXBTbxqLHsNQ3Bq9Hh0R57lg,7737
|
|
117
99
|
tico/quantization/wrapq/examples/debug_quant_outputs.py,sha256=kVp_nf9tr4wM5w18ILtYxVueY5bjYl_Mb4v0Em_M3Aw,7665
|
|
@@ -166,19 +148,20 @@ tico/serialize/operators/op_alias_copy.py,sha256=Xu9OiILbGf8oddh8yTqovvLfgVs8XYV
|
|
|
166
148
|
tico/serialize/operators/op_any.py,sha256=wrTXFQ1TWl-2ET2NGXAXI1dzfDDJsYtA71pyj2numPE,4968
|
|
167
149
|
tico/serialize/operators/op_arange_start_step.py,sha256=0T5lWwh3TfsFStmVv0v5qG03KENRDBmMix08RXQ4D-U,2132
|
|
168
150
|
tico/serialize/operators/op_argmax.py,sha256=ARyGHlmWVmzwCct93V5x1-VyKqhxMOvV8GuM8yQWXdo,2290
|
|
151
|
+
tico/serialize/operators/op_attention.py,sha256=h9kEaW7w5tDPqPmWb3w5WbjhlCwQGEinhr-NaQ3iXi8,2090
|
|
169
152
|
tico/serialize/operators/op_avg_pool2d.py,sha256=eZl232FqYQsn2jUN_XjombHq_lzp2hf_AKwCLbZBxh8,7720
|
|
170
153
|
tico/serialize/operators/op_bmm.py,sha256=AELjHC9ISFPIzEEl5Kr1s4GSNLZElwZmVZJWkEyCEoA,2189
|
|
171
154
|
tico/serialize/operators/op_cat.py,sha256=XDYOh0XAyrM0TlxVm6Sa0OFFGrKk7aSDcGXC-hYX4gs,2204
|
|
155
|
+
tico/serialize/operators/op_circle_shape.py,sha256=6rvFvz7zw0hqW8jvUoBkOBW54nMmsE9KOmLtrnQaxhM,2220
|
|
172
156
|
tico/serialize/operators/op_clamp.py,sha256=RRQVrzayDfN3PioCVJqa_yYOtcYwb5HHwkMe4E_YPmE,4408
|
|
173
157
|
tico/serialize/operators/op_clone.py,sha256=vzDYJ8TS3tc2BAyd_z8nt5VqT1inpymSseMEhd9dva0,2394
|
|
174
158
|
tico/serialize/operators/op_constant_pad_nd.py,sha256=nGWqYWNbj2E9ChQuoHsN-d8AO7UyVexnPil7qTqWZp8,3444
|
|
175
159
|
tico/serialize/operators/op_conv2d.py,sha256=1_vouWXaF51gDLYg8z5Zlup0Tecq_ggAzvguiHzFffw,6828
|
|
176
|
-
tico/serialize/operators/op_copy.py,sha256=boXHfl0bcvdBVl0tpzPMA_KBonh80vVqv61N3H5-PRU,6941
|
|
177
160
|
tico/serialize/operators/op_cos.py,sha256=N12bNyuTQIxRnD0eHRPdFVzRQPMy1NFM4iM8oQ4lYzw,2034
|
|
178
161
|
tico/serialize/operators/op_cumsum.py,sha256=px9ZGUDDsdWjrql8Z1FdXfF-7CJhditxyNz5QRZbLiM,3948
|
|
179
162
|
tico/serialize/operators/op_depthwise_conv2d.py,sha256=U6_nX2V31Evm-HLN9b3RKIVg-m8jyD-Nw1GdePUPPjY,7284
|
|
180
|
-
tico/serialize/operators/op_dequantize_per_channel.py,sha256=
|
|
181
|
-
tico/serialize/operators/op_dequantize_per_tensor.py,sha256=
|
|
163
|
+
tico/serialize/operators/op_dequantize_per_channel.py,sha256=ugXpZQl0qEGJ2mgwzD_T5WoZwaVvXgs4qCgmKlpF9zk,3214
|
|
164
|
+
tico/serialize/operators/op_dequantize_per_tensor.py,sha256=Rqz7KQY0pQ_QffLn4gxiV2iJY4asRs6BxvLm38hxciY,2384
|
|
182
165
|
tico/serialize/operators/op_div.py,sha256=WjeM2Ux7TyGlSNx2aVC783JvcL0xnY6FBYo1Q_kdb5Q,2201
|
|
183
166
|
tico/serialize/operators/op_embedding.py,sha256=OL5E5kIUbVPd9ihvBh8CNxGPj7GPGA-up2VRrYYlqeY,2262
|
|
184
167
|
tico/serialize/operators/op_eq.py,sha256=g17_K6IkWvnop_LaiUJzcGPUSFElz6UUrf7T0bor5Bo,2133
|
|
@@ -235,15 +218,17 @@ tico/serialize/operators/op_sub.py,sha256=yZskQJF0ylXVk02Uid8djPNIWDJ-0uHJar4UYh
|
|
|
235
218
|
tico/serialize/operators/op_sum.py,sha256=B5aSwQMhyoBe2JYdE5nVQ3QeVDSzL-yuZZujsG08OdQ,2294
|
|
236
219
|
tico/serialize/operators/op_tanh.py,sha256=rs7FsbQeUQ7Ak8RoQV9ymNGXHXRObojfY_SiqJiyqdA,1846
|
|
237
220
|
tico/serialize/operators/op_to_copy.py,sha256=a8T0uPMavMO_md1a-4_0dlvDHyZS_xew0qB6xjf69rI,3934
|
|
238
|
-
tico/serialize/operators/op_transpose_conv.py,sha256=
|
|
221
|
+
tico/serialize/operators/op_transpose_conv.py,sha256=N5AuAUuh9BA4M2Y2-ZSkV1q82P0j7yYpB6g3qiaDmLk,6542
|
|
239
222
|
tico/serialize/operators/op_unsqueeze.py,sha256=ZHhfVXSWEiwb2VDYX5uhxbGQyzZjKT7CrbBpVGxVHBU,2310
|
|
240
223
|
tico/serialize/operators/op_view.py,sha256=xxE-GvTJ1UpcHst5KXYz3qKY-eJQvXKKrSZiA2O7E40,2593
|
|
241
224
|
tico/serialize/operators/op_where.py,sha256=doE81GSwygrPBm3JIfN9w7kKXxeIYKxgk0eoY22QIcg,2845
|
|
242
225
|
tico/serialize/operators/utils.py,sha256=lXGpEJW1h8U_-gfc6EWjvvSiq3yJ9P-v1v3EMRT_pSk,2954
|
|
243
226
|
tico/serialize/operators/adapters/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
244
227
|
tico/serialize/operators/adapters/llama_rmsnorm.py,sha256=6t3dhfNpR03eIjsmhymF2JKd6lCf7PvInqMf77c_BOE,1139
|
|
228
|
+
tico/serialize/operators/adapters/onert/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
229
|
+
tico/serialize/operators/adapters/onert/llama_attention.py,sha256=jPA6n1lwln1pf8PHkqpNa71W8BQaC6yWwP8xbcVw77w,1827
|
|
245
230
|
tico/utils/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
246
|
-
tico/utils/convert.py,sha256=
|
|
231
|
+
tico/utils/convert.py,sha256=ejTuKlTw2fnngcPw-3gLcrmy4nTu2fn-FiwPKeofgNE,14405
|
|
247
232
|
tico/utils/define.py,sha256=Ypgp7YffM4pgPl4Zh6TmogSn1OxGBMRw_e09qYGflZk,1467
|
|
248
233
|
tico/utils/diff_graph.py,sha256=_eDGGPDPYQD4b--MXX0DLoVgSt_wLfNPt47UlolLLR4,5272
|
|
249
234
|
tico/utils/dtype.py,sha256=L5Qb7qgbt0eQ5frUTvHYrRtTJb1dg4-JNEopcxCNg1U,1389
|
|
@@ -252,24 +237,24 @@ tico/utils/graph.py,sha256=jD6m58m5JmN9mPfaROA9CW3406iJxmnukke00AuwRqI,9131
|
|
|
252
237
|
tico/utils/installed_packages.py,sha256=J0FTwnkCGs0MxRWoCMYAqiwH7Z0GWFDLV--x-IndSp4,1017
|
|
253
238
|
tico/utils/logging.py,sha256=IlbBWscsaHidI0dNqro1HEXAbIcbkR3BD5ukLy2m95k,1286
|
|
254
239
|
tico/utils/model.py,sha256=pPOIjD0qjQirLibiRxxfjOR6efimOcDAd9R-74eus-k,1282
|
|
255
|
-
tico/utils/padding.py,sha256=
|
|
240
|
+
tico/utils/padding.py,sha256=Yz9D1VaSYdxWVCgPCzkH1Ip1UIQoUSIxPJUf2IEd8pE,3656
|
|
256
241
|
tico/utils/passes.py,sha256=kGmDe__5cPaO6i5EDAoXSVe6yXEoX9hAny4ROb3ZEmQ,2409
|
|
257
242
|
tico/utils/pytree_utils.py,sha256=jrk3N6X6LiUnBCX_gM1K9nywbVAJBVnszlTAgeIeDUc,5219
|
|
258
|
-
tico/utils/record_input.py,sha256=
|
|
259
|
-
tico/utils/register_custom_op.py,sha256=
|
|
243
|
+
tico/utils/record_input.py,sha256=qPJ7RljVfPy-y9cb9AwP-8OmIiYLxCzTzbKJWQB5slk,3914
|
|
244
|
+
tico/utils/register_custom_op.py,sha256=NKzHIALhWX0DQqjFAfTPWTnO7I1WQClrGFCPh8J1e9o,30115
|
|
260
245
|
tico/utils/serialize.py,sha256=mEuusEzi82WFsz3AkowgWwxSLeo50JDxyOj6yYDQhEI,1914
|
|
261
246
|
tico/utils/signature.py,sha256=3OOwyVJzfcGcgC0LiVmOcUIzfqSk27qoNHhkoCI7zPY,9530
|
|
262
247
|
tico/utils/torch_compat.py,sha256=oc6PztVsXdHcQ3iaVR90wLLxrGaj6zFHWZ8K9rRS6q8,1795
|
|
263
248
|
tico/utils/trace_decorators.py,sha256=ddLIiKQfSaQrxgF1kNpwjFTQnXENzeSfcr1kuAW4jGI,3221
|
|
264
249
|
tico/utils/utils.py,sha256=aySftYnNTsqVAMcGs_3uX3-hz577a2cj4p1aVV-1XeQ,12747
|
|
265
|
-
tico/utils/validate_args_kwargs.py,sha256=
|
|
250
|
+
tico/utils/validate_args_kwargs.py,sha256=qq_VUVSepl-Lmt-jdZuFwcqxbXnxu2_CL2TLyj39OSU,29069
|
|
266
251
|
tico/utils/mx/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
267
252
|
tico/utils/mx/elemwise_ops.py,sha256=V6glyAHsVR1joqpsgnNytatCD_ew92xNWZ19UFDoMTA,10281
|
|
268
253
|
tico/utils/mx/formats.py,sha256=uzNWyu-1onUlwQfX5cZ6fZSUfHMRqorper7_T1k3jfk,3404
|
|
269
254
|
tico/utils/mx/mx_ops.py,sha256=RcfUTYVi-wilGB2sC35OeARdwDqnixv7dG5iyZ-fQT8,8555
|
|
270
|
-
tico-0.
|
|
271
|
-
tico-0.
|
|
272
|
-
tico-0.
|
|
273
|
-
tico-0.
|
|
274
|
-
tico-0.
|
|
275
|
-
tico-0.
|
|
255
|
+
tico-0.2.0.dev260122.dist-info/licenses/LICENSE,sha256=kp4JLII7bzRhPb0CPD5XTDZMh22BQ7h3k3B7t8TiSbw,12644
|
|
256
|
+
tico-0.2.0.dev260122.dist-info/METADATA,sha256=xP5llEHZwROmzeBKNy2sYOEXpp6OVYM-_tiJwambEO4,24279
|
|
257
|
+
tico-0.2.0.dev260122.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
258
|
+
tico-0.2.0.dev260122.dist-info/entry_points.txt,sha256=y6XCEOgx67ShUIDNeFluVkrQDYx1Sa59pN-lRCSmulk,58
|
|
259
|
+
tico-0.2.0.dev260122.dist-info/top_level.txt,sha256=oqs7UPoNSKZEwqsX8B-KAWdQwfAa7i60pbxW_Jk7P3w,5
|
|
260
|
+
tico-0.2.0.dev260122.dist-info/RECORD,,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# DO NOT REMOVE THIS FILE
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
from __future__ import annotations
|
|
16
|
-
|
|
17
|
-
import functools
|
|
18
|
-
from typing import Any, Callable, Dict, Optional, TYPE_CHECKING
|
|
19
|
-
|
|
20
|
-
if TYPE_CHECKING:
|
|
21
|
-
import torch.fx
|
|
22
|
-
from torch.ao.quantization.qconfig import _ObserverOrFakeQuantizeConstructor
|
|
23
|
-
import torch
|
|
24
|
-
from torch.ao.quantization.observer import MinMaxObserver, PerChannelMinMaxObserver
|
|
25
|
-
from torch.ao.quantization.quantizer import QuantizationSpec, Quantizer
|
|
26
|
-
from torch.ao.quantization.quantizer.utils import _get_module_name_filter
|
|
27
|
-
|
|
28
|
-
from tico.quantization.algorithm.pt2e.annotation.op import *
|
|
29
|
-
import tico.quantization.algorithm.pt2e.annotation.spec as annot_spec
|
|
30
|
-
import tico.quantization.algorithm.pt2e.annotation.utils as annot_utils
|
|
31
|
-
import tico.quantization.algorithm.pt2e.utils as quant_utils
|
|
32
|
-
from tico.quantization.algorithm.pt2e.annotation.config import QuantizationConfig
|
|
33
|
-
from tico.quantization.algorithm.pt2e.transformation.convert_scalars_to_attrs import (
|
|
34
|
-
convert_scalars_to_attrs,
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
class PT2EAnnotator(Quantizer):
|
|
39
|
-
"""
|
|
40
|
-
The class annotates quantization configurations on each nodes.
|
|
41
|
-
|
|
42
|
-
Observers would be attached according to those configurations in
|
|
43
|
-
'torch.prepare_pt2e'.
|
|
44
|
-
"""
|
|
45
|
-
|
|
46
|
-
def __init__(self):
|
|
47
|
-
super().__init__()
|
|
48
|
-
self.global_config: Optional[QuantizationConfig] = None
|
|
49
|
-
self.operator_type_config: Dict[
|
|
50
|
-
torch._ops.OpOverloadPacket, QuantizationConfig
|
|
51
|
-
] = {}
|
|
52
|
-
self.module_type_config: Dict[Callable, QuantizationConfig] = {}
|
|
53
|
-
self.module_name_config: Dict[str, QuantizationConfig] = {}
|
|
54
|
-
|
|
55
|
-
def set_global(self, quantization_config: QuantizationConfig) -> PT2EAnnotator:
|
|
56
|
-
"""
|
|
57
|
-
Set quantization config globally.
|
|
58
|
-
"""
|
|
59
|
-
assert quantization_config is not None
|
|
60
|
-
self.global_config = quantization_config
|
|
61
|
-
return self
|
|
62
|
-
|
|
63
|
-
def set_operator_type(
|
|
64
|
-
self,
|
|
65
|
-
operator_type: torch._ops.OpOverloadPacket,
|
|
66
|
-
quantization_config: QuantizationConfig,
|
|
67
|
-
) -> PT2EAnnotator:
|
|
68
|
-
"""
|
|
69
|
-
Set quantization config for given operator type.
|
|
70
|
-
"""
|
|
71
|
-
assert quantization_config is not None
|
|
72
|
-
self.operator_type_config[operator_type] = quantization_config
|
|
73
|
-
return self
|
|
74
|
-
|
|
75
|
-
def set_module_type(
|
|
76
|
-
self, module_type: Callable, quantization_config: QuantizationConfig
|
|
77
|
-
):
|
|
78
|
-
"""
|
|
79
|
-
Set quantization config for given module type.
|
|
80
|
-
|
|
81
|
-
For example, let's say quantizer.set_module_type(nn.Linear).
|
|
82
|
-
It will quantize all 'nn.Linear' modules with the `quantization_config`.
|
|
83
|
-
"""
|
|
84
|
-
assert quantization_config is not None
|
|
85
|
-
self.module_type_config[module_type] = quantization_config
|
|
86
|
-
return self
|
|
87
|
-
|
|
88
|
-
def set_module_name(
|
|
89
|
-
self, module_name: str, quantization_config: QuantizationConfig
|
|
90
|
-
):
|
|
91
|
-
"""
|
|
92
|
-
Set quantization config for given module name.
|
|
93
|
-
|
|
94
|
-
For example, let's say quantizer.set_module_name("blocks.sub").
|
|
95
|
-
It will quantize all nodes that come from a module whose name is "blocks.sub"
|
|
96
|
-
with the `quantization_config`.
|
|
97
|
-
"""
|
|
98
|
-
assert quantization_config is not None
|
|
99
|
-
self.module_name_config[module_name] = quantization_config
|
|
100
|
-
return self
|
|
101
|
-
|
|
102
|
-
def transform_for_annotation(
|
|
103
|
-
self, model: torch.fx.GraphModule
|
|
104
|
-
) -> torch.fx.GraphModule:
|
|
105
|
-
"""Allows for user defined transforms to run before annotating the graph."""
|
|
106
|
-
model = convert_scalars_to_attrs(model)
|
|
107
|
-
return model
|
|
108
|
-
|
|
109
|
-
def annotate(self, model: torch.fx.GraphModule) -> torch.fx.GraphModule:
|
|
110
|
-
model = self._annotate_for_quantization(model)
|
|
111
|
-
annot_utils.propagate_annotation_forward(model)
|
|
112
|
-
return model
|
|
113
|
-
|
|
114
|
-
def validate(self, model: torch.fx.GraphModule) -> None:
|
|
115
|
-
# TODO Consider this method.
|
|
116
|
-
pass
|
|
117
|
-
|
|
118
|
-
def _annotate_by_config_and_filter(
|
|
119
|
-
self,
|
|
120
|
-
model: torch.fx.GraphModule,
|
|
121
|
-
quantization_config: Optional[QuantizationConfig],
|
|
122
|
-
filter_fn: Optional[Callable[[torch.fx.Node], bool]] = None,
|
|
123
|
-
) -> torch.fx.GraphModule:
|
|
124
|
-
assert quantization_config is not None
|
|
125
|
-
|
|
126
|
-
for node in model.graph.nodes:
|
|
127
|
-
if node.target not in annot_spec.OP_TO_ANNOTATOR:
|
|
128
|
-
continue
|
|
129
|
-
annot_spec.OP_TO_ANNOTATOR[node.target](
|
|
130
|
-
model, node, quantization_config, filter_fn
|
|
131
|
-
)
|
|
132
|
-
return model
|
|
133
|
-
|
|
134
|
-
def _annotate_for_quantization(
|
|
135
|
-
self, model: torch.fx.GraphModule
|
|
136
|
-
) -> torch.fx.GraphModule:
|
|
137
|
-
# Annotate according to the given module names.
|
|
138
|
-
module_name_list = list(self.module_name_config.keys())
|
|
139
|
-
for module_name, config in self.module_name_config.items():
|
|
140
|
-
self._annotate_by_config_and_filter(
|
|
141
|
-
model, config, _get_module_name_filter(module_name)
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
# Annotate according to the given module types.
|
|
145
|
-
tp_list = list(self.module_type_config.keys())
|
|
146
|
-
for module_type, config in self.module_type_config.items():
|
|
147
|
-
self._annotate_by_config_and_filter(
|
|
148
|
-
model, config, quant_utils.get_module_type_filter(module_type)
|
|
149
|
-
)
|
|
150
|
-
|
|
151
|
-
# TODO Annotate according to the given operator types.
|
|
152
|
-
|
|
153
|
-
self._annotate_by_config_and_filter(
|
|
154
|
-
model,
|
|
155
|
-
self.global_config,
|
|
156
|
-
quant_utils.get_not_module_type_or_name_filter(tp_list, module_name_list),
|
|
157
|
-
)
|
|
158
|
-
return model
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
@functools.lru_cache
|
|
162
|
-
def get_asymmetric_quantization_config(
|
|
163
|
-
weight_is_per_channel: bool = True,
|
|
164
|
-
act_qmin: int = 0,
|
|
165
|
-
act_qmax: int = 255,
|
|
166
|
-
weight_qmin: int = 0,
|
|
167
|
-
weight_qmax: int = 255,
|
|
168
|
-
) -> QuantizationConfig:
|
|
169
|
-
# activation
|
|
170
|
-
act_extra_args: Dict[str, Any] = {"eps": 2**-12}
|
|
171
|
-
act_observer = MinMaxObserver
|
|
172
|
-
act_qspec = QuantizationSpec(
|
|
173
|
-
dtype=torch.uint8,
|
|
174
|
-
quant_min=act_qmin,
|
|
175
|
-
quant_max=act_qmax,
|
|
176
|
-
qscheme=torch.per_tensor_affine,
|
|
177
|
-
is_dynamic=False,
|
|
178
|
-
observer_or_fake_quant_ctr=act_observer.with_args(
|
|
179
|
-
**act_extra_args,
|
|
180
|
-
),
|
|
181
|
-
)
|
|
182
|
-
# weight
|
|
183
|
-
weight_extra_args: Dict[str, Any] = {"eps": 2**-12}
|
|
184
|
-
weight_qscheme = (
|
|
185
|
-
torch.per_channel_affine if weight_is_per_channel else torch.per_tensor_affine
|
|
186
|
-
)
|
|
187
|
-
weight_observer: _ObserverOrFakeQuantizeConstructor = (
|
|
188
|
-
PerChannelMinMaxObserver if weight_is_per_channel else MinMaxObserver
|
|
189
|
-
)
|
|
190
|
-
weight_qspec = QuantizationSpec(
|
|
191
|
-
dtype=torch.uint8,
|
|
192
|
-
quant_min=weight_qmin,
|
|
193
|
-
quant_max=weight_qmax,
|
|
194
|
-
qscheme=weight_qscheme,
|
|
195
|
-
ch_axis=0,
|
|
196
|
-
is_dynamic=False,
|
|
197
|
-
observer_or_fake_quant_ctr=weight_observer.with_args(**weight_extra_args),
|
|
198
|
-
)
|
|
199
|
-
|
|
200
|
-
# Set bias qspec in each annotation functions.
|
|
201
|
-
bias_qspec = None
|
|
202
|
-
quantization_config = QuantizationConfig(
|
|
203
|
-
act_qspec,
|
|
204
|
-
act_qspec,
|
|
205
|
-
weight_qspec,
|
|
206
|
-
bias_qspec,
|
|
207
|
-
)
|
|
208
|
-
return quantization_config
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
from dataclasses import dataclass
|
|
16
|
-
from typing import Optional
|
|
17
|
-
|
|
18
|
-
from torch.ao.quantization.quantizer import QuantizationSpec
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
@dataclass(eq=True, frozen=True)
|
|
22
|
-
class QuantizationConfig:
|
|
23
|
-
input_activation: Optional[QuantizationSpec]
|
|
24
|
-
output_activation: Optional[QuantizationSpec]
|
|
25
|
-
weight: Optional[QuantizationSpec]
|
|
26
|
-
bias: Optional[QuantizationSpec]
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
import glob
|
|
16
|
-
from os.path import basename, dirname, isfile, join
|
|
17
|
-
|
|
18
|
-
modules = glob.glob(join(dirname(__file__), "*.py"))
|
|
19
|
-
__all__ = [
|
|
20
|
-
basename(f)[:-3] for f in modules if isfile(f) and not f.endswith("__init__.py")
|
|
21
|
-
]
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
from typing import Callable, Optional, TYPE_CHECKING
|
|
16
|
-
|
|
17
|
-
if TYPE_CHECKING:
|
|
18
|
-
import torch.fx
|
|
19
|
-
import torch
|
|
20
|
-
from torch.ao.quantization.quantizer import SharedQuantizationSpec
|
|
21
|
-
|
|
22
|
-
import tico.quantization.algorithm.pt2e.annotation.spec as annot_spec
|
|
23
|
-
import tico.quantization.algorithm.pt2e.annotation.utils as annot_utils
|
|
24
|
-
import tico.quantization.algorithm.pt2e.utils as quant_utils
|
|
25
|
-
from tico.quantization.algorithm.pt2e.annotation.config import QuantizationConfig
|
|
26
|
-
from tico.utils.validate_args_kwargs import AdaptiveAvgPool2dArgs
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
@annot_spec.register_annotator([torch.ops.aten.adaptive_avg_pool2d.default])
|
|
30
|
-
def _annotate_adaptive_avg_pool2d(
|
|
31
|
-
gm: torch.fx.GraphModule,
|
|
32
|
-
node: torch.fx.Node,
|
|
33
|
-
quantization_config: Optional[QuantizationConfig],
|
|
34
|
-
filter_fn: Optional[Callable[[torch.fx.Node], bool]] = None,
|
|
35
|
-
):
|
|
36
|
-
if (
|
|
37
|
-
node.op != "call_function"
|
|
38
|
-
or node.target != torch.ops.aten.adaptive_avg_pool2d.default
|
|
39
|
-
):
|
|
40
|
-
return
|
|
41
|
-
if filter_fn and not filter_fn(node):
|
|
42
|
-
return
|
|
43
|
-
if quant_utils.is_annotated(node):
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
args = AdaptiveAvgPool2dArgs(*node.args) # type: ignore[arg-type]
|
|
47
|
-
input = args.input
|
|
48
|
-
|
|
49
|
-
assert isinstance(input, torch.fx.Node)
|
|
50
|
-
if (
|
|
51
|
-
"quantization_annotation" not in input.meta
|
|
52
|
-
or not input.meta["quantization_annotation"]._annotated
|
|
53
|
-
or input.meta["quantization_annotation"].output_qspec is None
|
|
54
|
-
):
|
|
55
|
-
input_act_qspec = quant_utils.get_input_act_qspec(quantization_config)
|
|
56
|
-
else:
|
|
57
|
-
input_act_qspec = SharedQuantizationSpec(input)
|
|
58
|
-
annot_utils.annotate_input_qspec_map(node, input, input_act_qspec)
|
|
59
|
-
|
|
60
|
-
output_act_qspec = SharedQuantizationSpec((input, node))
|
|
61
|
-
annot_utils.annotate_output_qspec(node, output_act_qspec)
|
|
62
|
-
|
|
63
|
-
annot_utils.mark_nodes_as_annotated(node)
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
from typing import Callable, Optional, TYPE_CHECKING
|
|
16
|
-
|
|
17
|
-
if TYPE_CHECKING:
|
|
18
|
-
import torch.fx
|
|
19
|
-
import torch
|
|
20
|
-
|
|
21
|
-
import tico.quantization.algorithm.pt2e.annotation.spec as annot_spec
|
|
22
|
-
import tico.quantization.algorithm.pt2e.annotation.utils as annot_utils
|
|
23
|
-
import tico.quantization.algorithm.pt2e.utils as quant_utils
|
|
24
|
-
from tico.quantization.algorithm.pt2e.annotation.config import QuantizationConfig
|
|
25
|
-
from tico.utils.validate_args_kwargs import AddTensorArgs
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
@annot_spec.register_annotator([torch.ops.aten.add.Tensor])
|
|
29
|
-
def _annotate_add(
|
|
30
|
-
gm: torch.fx.GraphModule,
|
|
31
|
-
node: torch.fx.Node,
|
|
32
|
-
quantization_config: Optional[QuantizationConfig],
|
|
33
|
-
filter_fn: Optional[Callable[[torch.fx.Node], bool]] = None,
|
|
34
|
-
):
|
|
35
|
-
if node.op != "call_function" or node.target != torch.ops.aten.add.Tensor:
|
|
36
|
-
return
|
|
37
|
-
if filter_fn and not filter_fn(node):
|
|
38
|
-
return
|
|
39
|
-
if quant_utils.is_annotated(node):
|
|
40
|
-
return
|
|
41
|
-
|
|
42
|
-
args = AddTensorArgs(*node.args, **node.kwargs) # type: ignore[arg-type]
|
|
43
|
-
input_ = args.input
|
|
44
|
-
other = args.other
|
|
45
|
-
|
|
46
|
-
input_act_qspec = quant_utils.get_input_act_qspec(quantization_config)
|
|
47
|
-
if isinstance(input_, torch.fx.Node):
|
|
48
|
-
annot_utils.annotate_input_qspec_map(node, input_, input_act_qspec)
|
|
49
|
-
if isinstance(other, torch.fx.Node):
|
|
50
|
-
annot_utils.annotate_input_qspec_map(node, other, input_act_qspec)
|
|
51
|
-
|
|
52
|
-
output_act_qspec = quant_utils.get_output_act_qspec(quantization_config)
|
|
53
|
-
annot_utils.annotate_output_qspec(node, output_act_qspec)
|
|
54
|
-
|
|
55
|
-
annot_utils.mark_nodes_as_annotated(node)
|