tico 0.1.0.dev251106__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.
Files changed (56) hide show
  1. tico/__init__.py +2 -2
  2. tico/_version.py +1 -0
  3. tico/passes/convert_conv3d_to_conv2d.py +435 -0
  4. tico/passes/convert_sym_size_to_circle_shape.py +99 -0
  5. tico/passes/decompose_batch_norm.py +9 -5
  6. tico/passes/lower_copy.py +95 -0
  7. tico/passes/ops.py +4 -0
  8. tico/quantization/algorithm/fpi_gptq/fpi_gptq.py +251 -0
  9. tico/quantization/algorithm/fpi_gptq/quantizer.py +180 -0
  10. tico/quantization/algorithm/gptq/gptq.py +231 -11
  11. tico/quantization/algorithm/gptq/quantizer.py +18 -6
  12. tico/quantization/config/{pt2e.py → fpi_gptq.py} +11 -4
  13. tico/quantization/config/gptq.py +27 -4
  14. tico/quantization/public_interface.py +0 -10
  15. tico/quantization/wrapq/quantizer.py +2 -0
  16. tico/quantization/wrapq/wrappers/quant_elementwise.py +51 -11
  17. tico/serialize/operators/adapters/onert/llama_attention.py +51 -0
  18. tico/serialize/operators/op_attention.py +58 -0
  19. tico/serialize/operators/op_circle_shape.py +64 -0
  20. tico/serialize/operators/op_dequantize_per_channel.py +1 -0
  21. tico/serialize/operators/op_dequantize_per_tensor.py +1 -0
  22. tico/serialize/operators/op_transpose_conv.py +66 -50
  23. tico/utils/convert.py +16 -1
  24. tico/utils/padding.py +13 -5
  25. tico/utils/record_input.py +2 -2
  26. tico/utils/register_custom_op.py +63 -0
  27. tico/utils/validate_args_kwargs.py +49 -4
  28. tico-0.2.0.dev260122.dist-info/METADATA +631 -0
  29. {tico-0.1.0.dev251106.dist-info → tico-0.2.0.dev260122.dist-info}/RECORD +35 -46
  30. {tico-0.1.0.dev251106.dist-info → tico-0.2.0.dev260122.dist-info}/WHEEL +1 -1
  31. {tico-0.1.0.dev251106.dist-info → tico-0.2.0.dev260122.dist-info}/entry_points.txt +0 -1
  32. tico/quantization/algorithm/pt2e/annotation/annotator.py +0 -208
  33. tico/quantization/algorithm/pt2e/annotation/config.py +0 -26
  34. tico/quantization/algorithm/pt2e/annotation/op/__init__.py +0 -21
  35. tico/quantization/algorithm/pt2e/annotation/op/adaptive_avg_pool2d.py +0 -63
  36. tico/quantization/algorithm/pt2e/annotation/op/add.py +0 -55
  37. tico/quantization/algorithm/pt2e/annotation/op/conv2d.py +0 -90
  38. tico/quantization/algorithm/pt2e/annotation/op/div.py +0 -55
  39. tico/quantization/algorithm/pt2e/annotation/op/linear.py +0 -92
  40. tico/quantization/algorithm/pt2e/annotation/op/mean.py +0 -51
  41. tico/quantization/algorithm/pt2e/annotation/op/mul.py +0 -55
  42. tico/quantization/algorithm/pt2e/annotation/op/relu6.py +0 -51
  43. tico/quantization/algorithm/pt2e/annotation/op/rsqrt.py +0 -51
  44. tico/quantization/algorithm/pt2e/annotation/op/sub.py +0 -55
  45. tico/quantization/algorithm/pt2e/annotation/spec.py +0 -45
  46. tico/quantization/algorithm/pt2e/annotation/utils.py +0 -88
  47. tico/quantization/algorithm/pt2e/quantizer.py +0 -81
  48. tico/quantization/algorithm/pt2e/transformation/__init__.py +0 -1
  49. tico/quantization/algorithm/pt2e/transformation/convert_scalars_to_attrs.py +0 -58
  50. tico/quantization/algorithm/pt2e/utils.py +0 -135
  51. tico/serialize/operators/op_copy.py +0 -187
  52. tico-0.1.0.dev251106.dist-info/METADATA +0 -392
  53. /tico/quantization/algorithm/{pt2e → fpi_gptq}/__init__.py +0 -0
  54. /tico/{quantization/algorithm/pt2e/annotation → serialize/operators/adapters/onert}/__init__.py +0 -0
  55. {tico-0.1.0.dev251106.dist-info → tico-0.2.0.dev260122.dist-info/licenses}/LICENSE +0 -0
  56. {tico-0.1.0.dev251106.dist-info → tico-0.2.0.dev260122.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,5 @@
1
- tico/__init__.py,sha256=zFizlBKVmXPeQuRPHlpsmWOePEoPowkPdrlRwoxPs4k,1883
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=06LAxhSmpTxFZJmUelwB3I_GipNWrLoM7PfM6ZkxOZY,6512
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=7IGRnxIJl-nLO4huVk_mgBfD4VGUNQRyeuM8K1L2u1U,2934
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,44 +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=YlE4re0HkkEDcq8IeXhPJUtveLIiDjAlChLvS_-254k,4153
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
58
+ tico/quantization/algorithm/fpi_gptq/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
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
54
61
  tico/quantization/algorithm/gptq/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
55
- tico/quantization/algorithm/gptq/gptq.py,sha256=x7wM9_OgOrcs6WmkVCDLn2bF7YuUAR_k6vLG2l593sk,6235
62
+ tico/quantization/algorithm/gptq/gptq.py,sha256=OWWXvvYvt-j3iBTQJT4_1pJpxvG4goUOrDJJCxQrhBc,16035
56
63
  tico/quantization/algorithm/gptq/quant.py,sha256=Rl4wAOCmlE0U09BtNCDbccaSNohRHCNLwFi3zCqZfNo,5127
57
- tico/quantization/algorithm/gptq/quantizer.py,sha256=OvR9sHgosGYofwYcDhye84FBl55cNY7-UlfBt9gXbDY,11734
64
+ tico/quantization/algorithm/gptq/quantizer.py,sha256=dOlaej5vPuNitgDP_cK-gPaoNKkpht7rRfjyyPSiSzc,12189
58
65
  tico/quantization/algorithm/gptq/utils.py,sha256=leGKayf-xbSjVwwAGTA5RsxUKrhDiklOQdlsLifjdrs,1811
59
- tico/quantization/algorithm/pt2e/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
60
- tico/quantization/algorithm/pt2e/quantizer.py,sha256=9K8SGwxi67DA8Hdwc_25ResJiSGLIMDkNyAwtQu3PGM,2673
61
- tico/quantization/algorithm/pt2e/utils.py,sha256=U9kf3J-1IJdlmFr5EQRcgWKX7AI8Z-tt_H0edKQ0ctQ,4784
62
- tico/quantization/algorithm/pt2e/annotation/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
63
- tico/quantization/algorithm/pt2e/annotation/annotator.py,sha256=_elaNHBM_7IZdMlhqH_BElJpNijV6AHQU-1MeK8KQ9g,7464
64
- tico/quantization/algorithm/pt2e/annotation/config.py,sha256=8x6YvixIogXh_PwqhKNb3L6lJyBDFQ_OHotonG_hWD0,977
65
- tico/quantization/algorithm/pt2e/annotation/spec.py,sha256=76cEij6xFNp51ZO5DOeYbRyWonhgHJO8mi47Q43ll8s,1415
66
- tico/quantization/algorithm/pt2e/annotation/utils.py,sha256=W6_p_EWPDKbvzfqktZfMm1NqiQeeQME5Pr6bzRPqXuo,3148
67
- tico/quantization/algorithm/pt2e/annotation/op/__init__.py,sha256=IlBNBqXeopMqHRkR-TPiuN_IkwXaSMXlSVO_9vKceB0,834
68
- tico/quantization/algorithm/pt2e/annotation/op/adaptive_avg_pool2d.py,sha256=ThDTMHFmGp-sFc4YMMTvNwrZtt2R7RNGaaWxVSZV-Yo,2408
69
- tico/quantization/algorithm/pt2e/annotation/op/add.py,sha256=-glHoBh49e6RM6W1L3raVjtZ_fLhsmOuzHsoBJUFcY8,2153
70
- tico/quantization/algorithm/pt2e/annotation/op/conv2d.py,sha256=hYE0R6ZrFwp4GABnsFac_F-gPgfG22G56S8fhSAnorM,3631
71
- tico/quantization/algorithm/pt2e/annotation/op/div.py,sha256=KKh5C30kCpMIpLV94CE7R8yh51K0hb7t4Owa9yeZ4TU,2135
72
- tico/quantization/algorithm/pt2e/annotation/op/linear.py,sha256=fOr8Ow0Y61xVQg4IZYSmYFG7CT28UAs1dXP0YQ1498M,3430
73
- tico/quantization/algorithm/pt2e/annotation/op/mean.py,sha256=ZLfCh3wFftV4gBYe5FeCo0tC8JOZ-5Hde64Sw2gfU_8,1959
74
- tico/quantization/algorithm/pt2e/annotation/op/mul.py,sha256=_R9dngri5wLsxqeLLeNYaJnTcuPQXtXBkfl23to_0Zs,2150
75
- tico/quantization/algorithm/pt2e/annotation/op/relu6.py,sha256=1Us4pBf2BSD3ICCWZPNGiBmaiRn_vnKopV_To7bpL7A,1956
76
- tico/quantization/algorithm/pt2e/annotation/op/rsqrt.py,sha256=Y2Z0mB-8Gk9tkvR4wNGnY0sM6q19YidZd5idbN8ZXTo,1966
77
- tico/quantization/algorithm/pt2e/annotation/op/sub.py,sha256=u4hg47dVCOCUqJbZV0GFZ5EKDUNu7NV1TMhxUnW_1vA,2135
78
- tico/quantization/algorithm/pt2e/transformation/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
79
- tico/quantization/algorithm/pt2e/transformation/convert_scalars_to_attrs.py,sha256=Idtoya2RcGKlgUJgC9WqNz0jH3gf6ViuPmsD9ySHbls,2253
80
66
  tico/quantization/algorithm/smoothquant/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
81
67
  tico/quantization/algorithm/smoothquant/observer.py,sha256=OWBKQ3ox6PqeqgevxOjpXvb7uApoqE4YbUBelGhVSN8,3435
82
68
  tico/quantization/algorithm/smoothquant/quantizer.py,sha256=pvf6HwW7VzyNFhfEDGwG-YPdPaEoGQfo4nfaeS9Qg_E,3686
83
69
  tico/quantization/algorithm/smoothquant/smooth_quant.py,sha256=fxCy4m-BsSjraciSVPFlPhgsOT46RjrOgczQGb7B9TA,11561
84
70
  tico/quantization/config/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
85
71
  tico/quantization/config/base.py,sha256=xg_HCDSuMgYvMd6ENZe4Sm2SYJgMaCBj4cmqaz_lhAs,816
86
- tico/quantization/config/gptq.py,sha256=O3NEPYMJdgMJQB--blw3WI8FGbK9nDlSqSo2ZHvNwb8,960
87
- 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
88
74
  tico/quantization/config/ptq.py,sha256=zbLQbuiEpO-qlDgyUYTZ3hkVxr3boq5TX0n0QTBHic4,4540
89
75
  tico/quantization/config/smoothquant.py,sha256=ntrqjYf6EbO4AE2IA5zn1A_f0AQgU6UqTtVkw6IiUsw,1401
90
76
  tico/quantization/evaluation/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
@@ -107,7 +93,7 @@ tico/quantization/wrapq/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9d
107
93
  tico/quantization/wrapq/dtypes.py,sha256=xfCBtq6mQmUYRwsoFgII6gvRl1raQi0Inj9pznDuKwQ,2236
108
94
  tico/quantization/wrapq/mode.py,sha256=lT-T8vIv8YWcwrjT7xXVhOw1g7aoAdh_3PWB-ptPKaI,1052
109
95
  tico/quantization/wrapq/qscheme.py,sha256=uwhv7bCxOOXB3I-IKlRyr_u4eXOq48uIqGy4TLDqGxY,1301
110
- tico/quantization/wrapq/quantizer.py,sha256=J1nH5FfJ_sKOAKmYjHAZ9zgnitPJ7fcOhO09E2CBIbw,6577
96
+ tico/quantization/wrapq/quantizer.py,sha256=5RtggN1lTnA1a7-TEvcq2KVEPhzv4Ec2idQHJDgSxBI,6625
111
97
  tico/quantization/wrapq/examples/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
112
98
  tico/quantization/wrapq/examples/compare_ppl.py,sha256=iJJEWC7IJpfBHwX0MEiKXBTbxqLHsNQ3Bq9Hh0R57lg,7737
113
99
  tico/quantization/wrapq/examples/debug_quant_outputs.py,sha256=kVp_nf9tr4wM5w18ILtYxVueY5bjYl_Mb4v0Em_M3Aw,7665
@@ -129,7 +115,7 @@ tico/quantization/wrapq/utils/metrics.py,sha256=ZnEQOd9fzDDxdXl32PFl3jMQv5ycz9nF
129
115
  tico/quantization/wrapq/utils/reduce_utils.py,sha256=3kWawLB91EcvvHlCrNqqfZF7tpgr22htBSA049mKw_4,973
130
116
  tico/quantization/wrapq/wrappers/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
131
117
  tico/quantization/wrapq/wrappers/ptq_wrapper.py,sha256=6zcVZ-vVhPCvFHQw6UlN7iizElrIHNkpAraeMaA0DDU,2388
132
- tico/quantization/wrapq/wrappers/quant_elementwise.py,sha256=trchhUknmZTcoCwVA62uzBP_mWuCjjuZjF0jb7TZpfA,3550
118
+ tico/quantization/wrapq/wrappers/quant_elementwise.py,sha256=2mpDljmROSIG3DI4TpNuy6gVEZ294aT1rKww-ZSI96o,4880
133
119
  tico/quantization/wrapq/wrappers/quant_module_base.py,sha256=SgyUlFYxDx39CAvcN2q4lsTedbEVPmetIigrllmvvD4,5915
134
120
  tico/quantization/wrapq/wrappers/registry.py,sha256=QJcOD9gEGB_DJowdTTqemcRDcYxQa4tHv2CDFgZDnA0,5168
135
121
  tico/quantization/wrapq/wrappers/fairseq/__init__.py,sha256=K4R7rbxHosx9LBLk2WKlL8gFuZTYTws41TW47AsSUPM,149
@@ -162,19 +148,20 @@ tico/serialize/operators/op_alias_copy.py,sha256=Xu9OiILbGf8oddh8yTqovvLfgVs8XYV
162
148
  tico/serialize/operators/op_any.py,sha256=wrTXFQ1TWl-2ET2NGXAXI1dzfDDJsYtA71pyj2numPE,4968
163
149
  tico/serialize/operators/op_arange_start_step.py,sha256=0T5lWwh3TfsFStmVv0v5qG03KENRDBmMix08RXQ4D-U,2132
164
150
  tico/serialize/operators/op_argmax.py,sha256=ARyGHlmWVmzwCct93V5x1-VyKqhxMOvV8GuM8yQWXdo,2290
151
+ tico/serialize/operators/op_attention.py,sha256=h9kEaW7w5tDPqPmWb3w5WbjhlCwQGEinhr-NaQ3iXi8,2090
165
152
  tico/serialize/operators/op_avg_pool2d.py,sha256=eZl232FqYQsn2jUN_XjombHq_lzp2hf_AKwCLbZBxh8,7720
166
153
  tico/serialize/operators/op_bmm.py,sha256=AELjHC9ISFPIzEEl5Kr1s4GSNLZElwZmVZJWkEyCEoA,2189
167
154
  tico/serialize/operators/op_cat.py,sha256=XDYOh0XAyrM0TlxVm6Sa0OFFGrKk7aSDcGXC-hYX4gs,2204
155
+ tico/serialize/operators/op_circle_shape.py,sha256=6rvFvz7zw0hqW8jvUoBkOBW54nMmsE9KOmLtrnQaxhM,2220
168
156
  tico/serialize/operators/op_clamp.py,sha256=RRQVrzayDfN3PioCVJqa_yYOtcYwb5HHwkMe4E_YPmE,4408
169
157
  tico/serialize/operators/op_clone.py,sha256=vzDYJ8TS3tc2BAyd_z8nt5VqT1inpymSseMEhd9dva0,2394
170
158
  tico/serialize/operators/op_constant_pad_nd.py,sha256=nGWqYWNbj2E9ChQuoHsN-d8AO7UyVexnPil7qTqWZp8,3444
171
159
  tico/serialize/operators/op_conv2d.py,sha256=1_vouWXaF51gDLYg8z5Zlup0Tecq_ggAzvguiHzFffw,6828
172
- tico/serialize/operators/op_copy.py,sha256=boXHfl0bcvdBVl0tpzPMA_KBonh80vVqv61N3H5-PRU,6941
173
160
  tico/serialize/operators/op_cos.py,sha256=N12bNyuTQIxRnD0eHRPdFVzRQPMy1NFM4iM8oQ4lYzw,2034
174
161
  tico/serialize/operators/op_cumsum.py,sha256=px9ZGUDDsdWjrql8Z1FdXfF-7CJhditxyNz5QRZbLiM,3948
175
162
  tico/serialize/operators/op_depthwise_conv2d.py,sha256=U6_nX2V31Evm-HLN9b3RKIVg-m8jyD-Nw1GdePUPPjY,7284
176
- tico/serialize/operators/op_dequantize_per_channel.py,sha256=aPcVxjdgvfSFoLnv9NL-RxO5vZYj8ulqriMP5LHIWs0,3133
177
- tico/serialize/operators/op_dequantize_per_tensor.py,sha256=u9aK_Xle9rDN0EHLE0YrCTlXY4Q53Ch9Di4qmx7ynps,2304
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
178
165
  tico/serialize/operators/op_div.py,sha256=WjeM2Ux7TyGlSNx2aVC783JvcL0xnY6FBYo1Q_kdb5Q,2201
179
166
  tico/serialize/operators/op_embedding.py,sha256=OL5E5kIUbVPd9ihvBh8CNxGPj7GPGA-up2VRrYYlqeY,2262
180
167
  tico/serialize/operators/op_eq.py,sha256=g17_K6IkWvnop_LaiUJzcGPUSFElz6UUrf7T0bor5Bo,2133
@@ -231,15 +218,17 @@ tico/serialize/operators/op_sub.py,sha256=yZskQJF0ylXVk02Uid8djPNIWDJ-0uHJar4UYh
231
218
  tico/serialize/operators/op_sum.py,sha256=B5aSwQMhyoBe2JYdE5nVQ3QeVDSzL-yuZZujsG08OdQ,2294
232
219
  tico/serialize/operators/op_tanh.py,sha256=rs7FsbQeUQ7Ak8RoQV9ymNGXHXRObojfY_SiqJiyqdA,1846
233
220
  tico/serialize/operators/op_to_copy.py,sha256=a8T0uPMavMO_md1a-4_0dlvDHyZS_xew0qB6xjf69rI,3934
234
- tico/serialize/operators/op_transpose_conv.py,sha256=9NLnWpitfQzSDF-iAgw2fBA3YHL5y2Y8DQipeo8OvYA,5826
221
+ tico/serialize/operators/op_transpose_conv.py,sha256=N5AuAUuh9BA4M2Y2-ZSkV1q82P0j7yYpB6g3qiaDmLk,6542
235
222
  tico/serialize/operators/op_unsqueeze.py,sha256=ZHhfVXSWEiwb2VDYX5uhxbGQyzZjKT7CrbBpVGxVHBU,2310
236
223
  tico/serialize/operators/op_view.py,sha256=xxE-GvTJ1UpcHst5KXYz3qKY-eJQvXKKrSZiA2O7E40,2593
237
224
  tico/serialize/operators/op_where.py,sha256=doE81GSwygrPBm3JIfN9w7kKXxeIYKxgk0eoY22QIcg,2845
238
225
  tico/serialize/operators/utils.py,sha256=lXGpEJW1h8U_-gfc6EWjvvSiq3yJ9P-v1v3EMRT_pSk,2954
239
226
  tico/serialize/operators/adapters/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
240
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
241
230
  tico/utils/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
242
- tico/utils/convert.py,sha256=wdamhQQPyiipL9vb_E_txDR9kmUyXmevYuYXcTeTAWE,13752
231
+ tico/utils/convert.py,sha256=ejTuKlTw2fnngcPw-3gLcrmy4nTu2fn-FiwPKeofgNE,14405
243
232
  tico/utils/define.py,sha256=Ypgp7YffM4pgPl4Zh6TmogSn1OxGBMRw_e09qYGflZk,1467
244
233
  tico/utils/diff_graph.py,sha256=_eDGGPDPYQD4b--MXX0DLoVgSt_wLfNPt47UlolLLR4,5272
245
234
  tico/utils/dtype.py,sha256=L5Qb7qgbt0eQ5frUTvHYrRtTJb1dg4-JNEopcxCNg1U,1389
@@ -248,24 +237,24 @@ tico/utils/graph.py,sha256=jD6m58m5JmN9mPfaROA9CW3406iJxmnukke00AuwRqI,9131
248
237
  tico/utils/installed_packages.py,sha256=J0FTwnkCGs0MxRWoCMYAqiwH7Z0GWFDLV--x-IndSp4,1017
249
238
  tico/utils/logging.py,sha256=IlbBWscsaHidI0dNqro1HEXAbIcbkR3BD5ukLy2m95k,1286
250
239
  tico/utils/model.py,sha256=pPOIjD0qjQirLibiRxxfjOR6efimOcDAd9R-74eus-k,1282
251
- tico/utils/padding.py,sha256=qKke-dJeeLHiRaePjDS66txrGyiYuipLVQeqLYad8uk,3349
240
+ tico/utils/padding.py,sha256=Yz9D1VaSYdxWVCgPCzkH1Ip1UIQoUSIxPJUf2IEd8pE,3656
252
241
  tico/utils/passes.py,sha256=kGmDe__5cPaO6i5EDAoXSVe6yXEoX9hAny4ROb3ZEmQ,2409
253
242
  tico/utils/pytree_utils.py,sha256=jrk3N6X6LiUnBCX_gM1K9nywbVAJBVnszlTAgeIeDUc,5219
254
- tico/utils/record_input.py,sha256=QN-8D71G_WAX3QQQ5CIwbEfFJZTQ3CvL4wCMiVddua4,3894
255
- tico/utils/register_custom_op.py,sha256=895SKZeXQzolK-mPG38cQC37Be76xUV_Ujw1k1ts9_w,28218
243
+ tico/utils/record_input.py,sha256=qPJ7RljVfPy-y9cb9AwP-8OmIiYLxCzTzbKJWQB5slk,3914
244
+ tico/utils/register_custom_op.py,sha256=NKzHIALhWX0DQqjFAfTPWTnO7I1WQClrGFCPh8J1e9o,30115
256
245
  tico/utils/serialize.py,sha256=mEuusEzi82WFsz3AkowgWwxSLeo50JDxyOj6yYDQhEI,1914
257
246
  tico/utils/signature.py,sha256=3OOwyVJzfcGcgC0LiVmOcUIzfqSk27qoNHhkoCI7zPY,9530
258
247
  tico/utils/torch_compat.py,sha256=oc6PztVsXdHcQ3iaVR90wLLxrGaj6zFHWZ8K9rRS6q8,1795
259
248
  tico/utils/trace_decorators.py,sha256=ddLIiKQfSaQrxgF1kNpwjFTQnXENzeSfcr1kuAW4jGI,3221
260
249
  tico/utils/utils.py,sha256=aySftYnNTsqVAMcGs_3uX3-hz577a2cj4p1aVV-1XeQ,12747
261
- tico/utils/validate_args_kwargs.py,sha256=RhBOHShi7DRHpCV_j4UcACk6wz4b1SUTWKj494_6zCQ,27439
250
+ tico/utils/validate_args_kwargs.py,sha256=qq_VUVSepl-Lmt-jdZuFwcqxbXnxu2_CL2TLyj39OSU,29069
262
251
  tico/utils/mx/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
263
252
  tico/utils/mx/elemwise_ops.py,sha256=V6glyAHsVR1joqpsgnNytatCD_ew92xNWZ19UFDoMTA,10281
264
253
  tico/utils/mx/formats.py,sha256=uzNWyu-1onUlwQfX5cZ6fZSUfHMRqorper7_T1k3jfk,3404
265
254
  tico/utils/mx/mx_ops.py,sha256=RcfUTYVi-wilGB2sC35OeARdwDqnixv7dG5iyZ-fQT8,8555
266
- tico-0.1.0.dev251106.dist-info/LICENSE,sha256=kp4JLII7bzRhPb0CPD5XTDZMh22BQ7h3k3B7t8TiSbw,12644
267
- tico-0.1.0.dev251106.dist-info/METADATA,sha256=cH9ZYH9ysDRREwJcSjMV1VkLFpNjoOSxPBChSzab-A0,9730
268
- tico-0.1.0.dev251106.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
269
- tico-0.1.0.dev251106.dist-info/entry_points.txt,sha256=kBKYSS_IYrSXmUYevmmepqIVPScq5vF8ulQRu3I_Zf0,59
270
- tico-0.1.0.dev251106.dist-info/top_level.txt,sha256=oqs7UPoNSKZEwqsX8B-KAWdQwfAa7i60pbxW_Jk7P3w,5
271
- tico-0.1.0.dev251106.dist-info/RECORD,,
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,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.37.1)
2
+ Generator: setuptools (80.10.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,3 +1,2 @@
1
1
  [console_scripts]
2
2
  pt2-to-circle = tico.pt2_to_circle:main
3
-
@@ -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)