tico 0.1.0.dev250527__py3-none-any.whl → 0.1.0.dev250529__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 +15 -4
- tico/experimental/quantization/passes/fold_quant_ops.py +2 -2
- tico/experimental/quantization/passes/remove_weight_dequant_op.py +2 -2
- tico/passes/decompose_fake_quantize.py +5 -1
- tico/passes/decompose_fake_quantize_tensor_qparams.py +5 -1
- tico/serialize/circle_serializer.py +4 -0
- tico/utils/utils.py +29 -0
- {tico-0.1.0.dev250527.dist-info → tico-0.1.0.dev250529.dist-info}/METADATA +1 -1
- {tico-0.1.0.dev250527.dist-info → tico-0.1.0.dev250529.dist-info}/RECORD +13 -13
- {tico-0.1.0.dev250527.dist-info → tico-0.1.0.dev250529.dist-info}/LICENSE +0 -0
- {tico-0.1.0.dev250527.dist-info → tico-0.1.0.dev250529.dist-info}/WHEEL +0 -0
- {tico-0.1.0.dev250527.dist-info → tico-0.1.0.dev250529.dist-info}/entry_points.txt +0 -0
- {tico-0.1.0.dev250527.dist-info → tico-0.1.0.dev250529.dist-info}/top_level.txt +0 -0
tico/__init__.py
CHANGED
@@ -18,14 +18,25 @@ import torch
|
|
18
18
|
from packaging.version import Version
|
19
19
|
|
20
20
|
from tico.config import CompileConfigV1, get_default_config
|
21
|
-
|
22
21
|
from tico.utils.convert import convert, convert_from_exported_program, convert_from_pt2
|
23
22
|
|
24
23
|
# THIS LINE IS AUTOMATICALLY GENERATED BY setup.py
|
25
|
-
__version__ = "0.1.0.
|
24
|
+
__version__ = "0.1.0.dev250529"
|
25
|
+
|
26
|
+
MINIMUM_SUPPORTED_VERSION = "2.5.0"
|
27
|
+
SECURE_TORCH_VERSION = "2.6.0"
|
26
28
|
|
29
|
+
if Version(torch.__version__) < Version(MINIMUM_SUPPORTED_VERSION):
|
30
|
+
warnings.warn(
|
31
|
+
f"TICO officially supports torch>={MINIMUM_SUPPORTED_VERSION}. "
|
32
|
+
f"You are using a lower version of torch ({torch.__version__}). "
|
33
|
+
f"We highly recommend to upgrade torch>={MINIMUM_SUPPORTED_VERSION} to avoid unexpected behaviors."
|
34
|
+
)
|
27
35
|
|
28
|
-
if Version(torch.__version__) < Version(
|
36
|
+
if Version(torch.__version__) < Version(SECURE_TORCH_VERSION):
|
29
37
|
warnings.warn(
|
30
|
-
f"
|
38
|
+
f"Detected PyTorch version {torch.__version__}, which may include known security vulnerabilities. "
|
39
|
+
f"We recommend upgrading to {SECURE_TORCH_VERSION} or later for better security.\n"
|
40
|
+
"Upgrade command: pip install --upgrade torch\n"
|
41
|
+
"For more details, see: https://pytorch.org/security"
|
31
42
|
)
|
@@ -23,6 +23,7 @@ from tico.serialize.quant_param import QPARAM_KEY, QuantParam, to_qparam_dtype
|
|
23
23
|
from tico.utils import logging
|
24
24
|
from tico.utils.passes import PassBase, PassResult
|
25
25
|
from tico.utils.trace_decorators import trace_graph_diff_on_pass
|
26
|
+
from tico.utils.utils import get_quant_dtype
|
26
27
|
from tico.utils.validate_args_kwargs import (
|
27
28
|
DequantizePerTensorArgs,
|
28
29
|
QuantizePerTensorArgs,
|
@@ -81,8 +82,7 @@ class FoldQuantOps(PassBase):
|
|
81
82
|
qparam = QuantParam()
|
82
83
|
qparam.scale = [q_args.scale]
|
83
84
|
qparam.zero_point = [q_args.zero_p]
|
84
|
-
|
85
|
-
qparam.dtype = to_qparam_dtype(q.meta["val"].dtype)
|
85
|
+
qparam.dtype = get_quant_dtype(q_args.quant_min, q_args.quant_max)
|
86
86
|
op.meta[QPARAM_KEY] = qparam
|
87
87
|
|
88
88
|
dq.replace_all_uses_with(op, propagate_meta=False)
|
@@ -116,12 +116,12 @@ class RemoveWeightDequantOp(PassBase):
|
|
116
116
|
dq.target
|
117
117
|
== torch.ops.quantized_decomposed.dequantize_per_channel.default
|
118
118
|
):
|
119
|
-
dq_args = DequantizePerChannelArgs(*dq.args,
|
119
|
+
dq_args = DequantizePerChannelArgs(*dq.args, **dq.kwargs)
|
120
120
|
elif (
|
121
121
|
dq.target
|
122
122
|
== torch.ops.quantized_decomposed.dequantize_per_tensor.default
|
123
123
|
):
|
124
|
-
dq_args = DequantizePerTensorArgs(*dq.args,
|
124
|
+
dq_args = DequantizePerTensorArgs(*dq.args, **dq.kwargs)
|
125
125
|
else:
|
126
126
|
raise RuntimeError(f"Invalid DQ target: {dq.target}")
|
127
127
|
|
@@ -29,6 +29,10 @@ from tico.utils.validate_args_kwargs import FakeQuantizePerChannelArgs
|
|
29
29
|
|
30
30
|
|
31
31
|
def get_quant_type(min: int, max: int) -> torch.dtype:
|
32
|
+
if min == 0 and max == 15:
|
33
|
+
# torch can't represent "uint4".
|
34
|
+
# Let's set torch.uint8 and infer dtype with quant_min/quant_max instead.
|
35
|
+
return torch.uint8
|
32
36
|
if min == 0 and max == 255:
|
33
37
|
return torch.uint8
|
34
38
|
if min == -32768 and max == 32767:
|
@@ -36,7 +40,7 @@ def get_quant_type(min: int, max: int) -> torch.dtype:
|
|
36
40
|
if min == -32767 and max == 32767:
|
37
41
|
return torch.int16
|
38
42
|
|
39
|
-
raise RuntimeError("Not supported min/max values")
|
43
|
+
raise RuntimeError(f"Not supported min/max values: {min}/{max}")
|
40
44
|
|
41
45
|
|
42
46
|
@trace_graph_diff_on_pass
|
@@ -39,6 +39,10 @@ from tico.utils.validate_args_kwargs import FakeQuantizePerTensorTQParamArgs
|
|
39
39
|
|
40
40
|
|
41
41
|
def get_quant_type(min: int, max: int) -> torch.dtype:
|
42
|
+
if min == 0 and max == 15:
|
43
|
+
# torch can't represent "uint4".
|
44
|
+
# Let's set torch.uint8 and infer dtype with quant_min/quant_max instead.
|
45
|
+
return torch.uint8
|
42
46
|
if min == 0 and max == 255:
|
43
47
|
return torch.uint8
|
44
48
|
if min == -32768 and max == 32767:
|
@@ -98,7 +102,7 @@ def get_constant_from_tensor(
|
|
98
102
|
lifted_tensor_constants = ep.graph_signature.inputs_to_lifted_tensor_constants
|
99
103
|
assert lifted_tensor.name in lifted_tensor_constants
|
100
104
|
tensor_name = lifted_tensor_constants[lifted_tensor.name]
|
101
|
-
value = ep.constants[tensor_name].
|
105
|
+
value = ep.constants[tensor_name].item()
|
102
106
|
return value
|
103
107
|
if node.target.__name__ in ["detach.default", "detach_.default"]:
|
104
108
|
assert len(node.args) == 1
|
@@ -190,6 +190,10 @@ def build_circle(edge_program: ExportedProgram) -> bytes:
|
|
190
190
|
# Register outputs
|
191
191
|
logger.debug("---------------Register outputs--------------")
|
192
192
|
for user_output in edge_program.graph_signature.user_outputs:
|
193
|
+
if user_output == None:
|
194
|
+
logger.debug(f"Ignore 'None' output")
|
195
|
+
continue
|
196
|
+
|
193
197
|
graph.add_output(user_output)
|
194
198
|
logger.debug(f"Registered output: {user_output}")
|
195
199
|
|
tico/utils/utils.py
CHANGED
@@ -312,3 +312,32 @@ def quant_min_max(dtype: str):
|
|
312
312
|
return (-32768, 32767)
|
313
313
|
else:
|
314
314
|
raise NotImplementedError(f"NYI dtype: {dtype}")
|
315
|
+
|
316
|
+
|
317
|
+
def get_quant_dtype(qmin: int, qmax: int):
|
318
|
+
"""
|
319
|
+
Returns the string representation of the quantized data type based on qmin and qmax.
|
320
|
+
|
321
|
+
Args:
|
322
|
+
qmin (int): Minimum quantized value.
|
323
|
+
qmax (int): Maximum quantized value.
|
324
|
+
|
325
|
+
Returns:
|
326
|
+
str: A string representing the quantized data type, such as "int8", "uint4", etc.
|
327
|
+
|
328
|
+
Raises:
|
329
|
+
ValueError: If the (qmin, qmax) pair is not supported.
|
330
|
+
"""
|
331
|
+
known_ranges = {
|
332
|
+
(-32768, 32767): "int16",
|
333
|
+
(0, 65535): "uint16",
|
334
|
+
(-128, 127): "int8",
|
335
|
+
(0, 255): "uint8",
|
336
|
+
(-8, 7): "int4",
|
337
|
+
(0, 15): "uint4",
|
338
|
+
}
|
339
|
+
|
340
|
+
if (qmin, qmax) in known_ranges:
|
341
|
+
return known_ranges[(qmin, qmax)]
|
342
|
+
else:
|
343
|
+
raise ValueError(f"Unsupported quantization range: ({qmin}, {qmax})")
|
@@ -1,4 +1,4 @@
|
|
1
|
-
tico/__init__.py,sha256=
|
1
|
+
tico/__init__.py,sha256=Kb5IbIgf231eEaTOQPwejW7YylbiTAvFDd422yMVae0,1743
|
2
2
|
tico/pt2_to_circle.py,sha256=PPmFNw20jw2Z2VyM3ln9pX__jTzBOAZiv0gT5a-p-Y8,2666
|
3
3
|
tico/config/__init__.py,sha256=xZzCXjZ84qE-CsBi-dfaL05bqpQ3stKKfTXhnrJRyVs,142
|
4
4
|
tico/config/base.py,sha256=anwOiJFkUxUi7Cef573JgQcjk6S-FSi6O_TLjYASW-g,1244
|
@@ -50,11 +50,11 @@ tico/experimental/quantization/evaluation/executor/backend_executor.py,sha256=3k
|
|
50
50
|
tico/experimental/quantization/evaluation/executor/circle_executor.py,sha256=eCCJ9wTwR0vUJ0oN7jxtQxZ9598GRw6P6KUxiuGsIIM,2685
|
51
51
|
tico/experimental/quantization/evaluation/executor/triv24_executor.py,sha256=sUoXl6oOO2arAKaNjOBg7HiQja145_Jv6qgY7XtR7A8,5159
|
52
52
|
tico/experimental/quantization/passes/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
53
|
-
tico/experimental/quantization/passes/fold_quant_ops.py,sha256=
|
53
|
+
tico/experimental/quantization/passes/fold_quant_ops.py,sha256=OYUndHaSL3GiL8koIG9_pqavW-hghrs0kkpvounsh1g,3312
|
54
54
|
tico/experimental/quantization/passes/insert_quantize_on_dtype_mismatch.py,sha256=i4rkM1vlN85fXA9oOrU25o8KWAaqA65NKngTX6MgctQ,12960
|
55
55
|
tico/experimental/quantization/passes/propagate_qparam_backward.py,sha256=TGtyW0Z2qOTgVIasBdGRgbwH31YYd6ek7OvLTmCV614,3118
|
56
56
|
tico/experimental/quantization/passes/propagate_qparam_forward.py,sha256=RhUHGCR2RpBO5KYkQ7Z8U5u7HEwDq2wdKHLKAJCi-5c,5138
|
57
|
-
tico/experimental/quantization/passes/remove_weight_dequant_op.py,sha256=
|
57
|
+
tico/experimental/quantization/passes/remove_weight_dequant_op.py,sha256=ZIwzuRXyCg6xN5pEUVV1LXsZpu0NkTcTUI6gc1VTuXs,6452
|
58
58
|
tico/interpreter/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
59
59
|
tico/interpreter/infer.py,sha256=vJ3b69ce9HrxNT0gFwbEhHpAyvVyuiunTgAeiqn5t64,4350
|
60
60
|
tico/interpreter/interpreter.py,sha256=tGbluCbrehTCqBu8mtGDNzby_ieJ2ry8_RH_eC0CQxk,3828
|
@@ -68,8 +68,8 @@ tico/passes/convert_repeat_to_expand_copy.py,sha256=fRUETNuFB2p-RLhe844pldm0l5oy
|
|
68
68
|
tico/passes/convert_to_relu6.py,sha256=3sfKfggvjbl9N73pLOwgUTNyoecODsy367nwoX2S-EE,6404
|
69
69
|
tico/passes/decompose_addmm.py,sha256=_yNX7wx1Y9HJI5ksUJI-UQLHpoNawbUbF8kcm2zGHw0,4221
|
70
70
|
tico/passes/decompose_batch_norm.py,sha256=d1V9UOkm_5BV0NGLyuQfz4I9NpO7I3ZrRugt7EXM-XM,7016
|
71
|
-
tico/passes/decompose_fake_quantize.py,sha256
|
72
|
-
tico/passes/decompose_fake_quantize_tensor_qparams.py,sha256=
|
71
|
+
tico/passes/decompose_fake_quantize.py,sha256=-OFOf0WSyRQ8ikS8KQm2mWXp-tHQDGWOFu3mn6pFfBs,5370
|
72
|
+
tico/passes/decompose_fake_quantize_tensor_qparams.py,sha256=R0hLlKdRXnAsOrbXOErfZEkSC7nv8_TdklNlI76TRMo,13988
|
73
73
|
tico/passes/decompose_group_norm.py,sha256=xn1xnT-2e6BvelRAzX8O7wg9kBWURmPldkRvpfYFXHQ,9407
|
74
74
|
tico/passes/decompose_grouped_conv2d.py,sha256=KJhH6PX7l9k9T8KBV8JDAvaSfJuUnRo_jtvGF2aM-LA,8277
|
75
75
|
tico/passes/decompose_slice_scatter.py,sha256=ko9p8v-zY5rOx4aSpWomwSdSWb1lIF32gnU7ik5xgII,5604
|
@@ -95,7 +95,7 @@ tico/passes/segment_index_select.py,sha256=ifXOIFC12lNwsB-s3k1cJcMHP3UEijPpkMAbw
|
|
95
95
|
tico/serialize/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
96
96
|
tico/serialize/circle_graph.py,sha256=l9fcvV4x3L5Bh2WmEseo--0KFjSVTrlSBaBrqbrmXgg,9498
|
97
97
|
tico/serialize/circle_mapping.py,sha256=C9C3ORACQOdvBdnt5KRzlT8zao_TvzQklIxH794OhP0,5719
|
98
|
-
tico/serialize/circle_serializer.py,sha256=
|
98
|
+
tico/serialize/circle_serializer.py,sha256=gJP2QEY7hFrlP_I4JRnnMehThr9ay9SUyoOQ2ppJBl0,8859
|
99
99
|
tico/serialize/pack.py,sha256=5HZ9kX3x6C6CyT_FWS6FRmvx_P7Dx21orjUNQxJ2xlo,1297
|
100
100
|
tico/serialize/quant_param.py,sha256=s97GJyDOZULnqFUWPakHais31G_qqPuO0awPHCkZDvI,1342
|
101
101
|
tico/serialize/operators/__init__.py,sha256=LIvXsNnN4yUCS2CGNQ5XW8p8oXDTV_WHWuOEAw1t6WY,990
|
@@ -188,15 +188,15 @@ tico/utils/padding.py,sha256=GGO27VbaOvtaMYLDrSaKv7uxjeet566aMJD0PyYeMvQ,1484
|
|
188
188
|
tico/utils/passes.py,sha256=kGmDe__5cPaO6i5EDAoXSVe6yXEoX9hAny4ROb3ZEmQ,2409
|
189
189
|
tico/utils/register_custom_op.py,sha256=iRQvdqlBqrJxq_pNkvJyDIJD_SYtCUl88wwbbuvSwlk,22952
|
190
190
|
tico/utils/trace_decorators.py,sha256=ddLIiKQfSaQrxgF1kNpwjFTQnXENzeSfcr1kuAW4jGI,3221
|
191
|
-
tico/utils/utils.py,sha256=
|
191
|
+
tico/utils/utils.py,sha256=NAa3ZX5G-UCQwmz5WnFl0iCEra24PMY5wC0MyX7smUg,11156
|
192
192
|
tico/utils/validate_args_kwargs.py,sha256=P4aMnr9EhNCtc_AgJPpuezfQbqFfDn0lhJSWqmumLZ8,25054
|
193
193
|
tico/utils/mx/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
194
194
|
tico/utils/mx/elemwise_ops.py,sha256=V6glyAHsVR1joqpsgnNytatCD_ew92xNWZ19UFDoMTA,10281
|
195
195
|
tico/utils/mx/formats.py,sha256=uzNWyu-1onUlwQfX5cZ6fZSUfHMRqorper7_T1k3jfk,3404
|
196
196
|
tico/utils/mx/mx_ops.py,sha256=RcfUTYVi-wilGB2sC35OeARdwDqnixv7dG5iyZ-fQT8,8555
|
197
|
-
tico-0.1.0.
|
198
|
-
tico-0.1.0.
|
199
|
-
tico-0.1.0.
|
200
|
-
tico-0.1.0.
|
201
|
-
tico-0.1.0.
|
202
|
-
tico-0.1.0.
|
197
|
+
tico-0.1.0.dev250529.dist-info/LICENSE,sha256=kp4JLII7bzRhPb0CPD5XTDZMh22BQ7h3k3B7t8TiSbw,12644
|
198
|
+
tico-0.1.0.dev250529.dist-info/METADATA,sha256=YO_KwNVCiSctvJUCj2KBt-D3DfPRQBv84EstPesXEmE,8633
|
199
|
+
tico-0.1.0.dev250529.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
200
|
+
tico-0.1.0.dev250529.dist-info/entry_points.txt,sha256=kBKYSS_IYrSXmUYevmmepqIVPScq5vF8ulQRu3I_Zf0,59
|
201
|
+
tico-0.1.0.dev250529.dist-info/top_level.txt,sha256=oqs7UPoNSKZEwqsX8B-KAWdQwfAa7i60pbxW_Jk7P3w,5
|
202
|
+
tico-0.1.0.dev250529.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|