tico 0.1.0.dev250806__py3-none-any.whl → 0.1.0.dev250807__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 +1 -1
- tico/experimental/quantization/evaluation/metric.py +17 -0
- tico/experimental/quantization/ptq/__init__.py +13 -0
- tico/experimental/quantization/ptq/dtypes.py +70 -0
- tico/experimental/quantization/ptq/mode.py +32 -0
- tico/experimental/quantization/ptq/qscheme.py +40 -0
- {tico-0.1.0.dev250806.dist-info → tico-0.1.0.dev250807.dist-info}/METADATA +1 -1
- {tico-0.1.0.dev250806.dist-info → tico-0.1.0.dev250807.dist-info}/RECORD +12 -8
- {tico-0.1.0.dev250806.dist-info → tico-0.1.0.dev250807.dist-info}/LICENSE +0 -0
- {tico-0.1.0.dev250806.dist-info → tico-0.1.0.dev250807.dist-info}/WHEEL +0 -0
- {tico-0.1.0.dev250806.dist-info → tico-0.1.0.dev250807.dist-info}/entry_points.txt +0 -0
- {tico-0.1.0.dev250806.dist-info → tico-0.1.0.dev250807.dist-info}/top_level.txt +0 -0
tico/__init__.py
CHANGED
@@ -42,6 +42,22 @@ def compute_peir(base: torch.Tensor, target: torch.Tensor) -> float:
|
|
42
42
|
return peak_error / interval
|
43
43
|
|
44
44
|
|
45
|
+
def mse(base: torch.Tensor, target: torch.Tensor) -> float:
|
46
|
+
"""
|
47
|
+
Mean Squared Error (MSE).
|
48
|
+
Penalizes **larger** deviations more heavily than MAE by squaring each
|
49
|
+
difference — helpful to expose occasional large spikes.
|
50
|
+
Formula
|
51
|
+
-------
|
52
|
+
MSE = mean((base - target)²)
|
53
|
+
Returns
|
54
|
+
-------
|
55
|
+
float
|
56
|
+
Mean squared error. *Lower is better*.
|
57
|
+
"""
|
58
|
+
return torch.mean((base.detach() - target.detach()) ** 2).item()
|
59
|
+
|
60
|
+
|
45
61
|
class MetricCalculator:
|
46
62
|
"""
|
47
63
|
Lightweight registry-and-dispatcher for **pair-wise tensor comparison metrics**.
|
@@ -83,6 +99,7 @@ class MetricCalculator:
|
|
83
99
|
"diff": compute_max_abs_diff,
|
84
100
|
"max_abs_diff": compute_max_abs_diff,
|
85
101
|
"peir": compute_peir,
|
102
|
+
"mse": mse,
|
86
103
|
}
|
87
104
|
|
88
105
|
def __init__(
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"""
|
2
|
+
Public PTQ API — re-export the most common symbols.
|
3
|
+
"""
|
4
|
+
|
5
|
+
from tico.experimental.quantization.ptq.dtypes import DType
|
6
|
+
from tico.experimental.quantization.ptq.mode import Mode
|
7
|
+
from tico.experimental.quantization.ptq.qscheme import QScheme
|
8
|
+
|
9
|
+
__all__ = [
|
10
|
+
"DType",
|
11
|
+
"Mode",
|
12
|
+
"QScheme",
|
13
|
+
]
|
@@ -0,0 +1,70 @@
|
|
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
|
+
|
17
|
+
|
18
|
+
@dataclass(frozen=True)
|
19
|
+
class DType:
|
20
|
+
"""
|
21
|
+
Self-contained integer dtypes for quantization.
|
22
|
+
|
23
|
+
A DType is just an immutable value-object with two fields:
|
24
|
+
- bits
|
25
|
+
- signed
|
26
|
+
|
27
|
+
Common presets (INT8, UINT4, ..) are provided as constants for convenience.
|
28
|
+
"""
|
29
|
+
|
30
|
+
bits: int # pylint: disable=used-before-assignment
|
31
|
+
signed: bool = False # False -> unsigned
|
32
|
+
|
33
|
+
@property
|
34
|
+
def qmin(self) -> int:
|
35
|
+
assert self.bits is not None
|
36
|
+
if self.signed:
|
37
|
+
return -(1 << (self.bits - 1))
|
38
|
+
return 0
|
39
|
+
|
40
|
+
@property
|
41
|
+
def qmax(self) -> int:
|
42
|
+
assert self.bits is not None
|
43
|
+
if self.signed:
|
44
|
+
return (1 << (self.bits - 1)) - 1
|
45
|
+
return (1 << self.bits) - 1
|
46
|
+
|
47
|
+
def __str__(self) -> str:
|
48
|
+
prefix = "int" if self.signed else "uint"
|
49
|
+
return f"{prefix}{self.bits}"
|
50
|
+
|
51
|
+
# ────────────────────────────────
|
52
|
+
# Factory helpers
|
53
|
+
# ────────────────────────────────
|
54
|
+
@staticmethod
|
55
|
+
def int(bits: int): # type: ignore[valid-type]
|
56
|
+
return DType(bits, signed=True)
|
57
|
+
|
58
|
+
@staticmethod
|
59
|
+
def uint(bits: int): # type: ignore[valid-type]
|
60
|
+
return DType(bits, signed=False)
|
61
|
+
|
62
|
+
|
63
|
+
# ---------------------------------------------------------------------
|
64
|
+
# Convenient canned versions
|
65
|
+
# ---------------------------------------------------------------------
|
66
|
+
UINT4 = DType.uint(4)
|
67
|
+
INT4 = DType.int(4)
|
68
|
+
INT8 = DType.int(8)
|
69
|
+
UINT8 = DType.uint(8)
|
70
|
+
INT16 = DType.int(16)
|
@@ -0,0 +1,32 @@
|
|
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 enum import auto, Enum
|
16
|
+
|
17
|
+
|
18
|
+
class Mode(Enum):
|
19
|
+
"""
|
20
|
+
Mode — global FSM for PTQWrapper & Handlers.
|
21
|
+
|
22
|
+
• NO_QUANT : pure pass-through (no stats, no fake-quant)
|
23
|
+
• CALIB : collect observer statistics only
|
24
|
+
• QUANT : use cached (scale, zero-point) → fake-quant enabled
|
25
|
+
"""
|
26
|
+
|
27
|
+
NO_QUANT = auto()
|
28
|
+
CALIB = auto()
|
29
|
+
QUANT = auto()
|
30
|
+
|
31
|
+
def __str__(self) -> str:
|
32
|
+
return self.name.lower()
|
@@ -0,0 +1,40 @@
|
|
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 enum import auto, Enum
|
16
|
+
|
17
|
+
|
18
|
+
class QScheme(Enum):
|
19
|
+
# ───── Per-tensor ────────────
|
20
|
+
PER_TENSOR_ASYMM = auto()
|
21
|
+
PER_TENSOR_SYMM = auto()
|
22
|
+
# ───── Per-channel ───────────
|
23
|
+
PER_CHANNEL_ASYMM = auto()
|
24
|
+
PER_CHANNEL_SYMM = auto()
|
25
|
+
|
26
|
+
# helper
|
27
|
+
def is_per_channel(self) -> bool:
|
28
|
+
return self in {
|
29
|
+
QScheme.PER_CHANNEL_ASYMM,
|
30
|
+
QScheme.PER_CHANNEL_SYMM,
|
31
|
+
}
|
32
|
+
|
33
|
+
def is_symmetric(self) -> bool:
|
34
|
+
return self in {
|
35
|
+
QScheme.PER_TENSOR_SYMM,
|
36
|
+
QScheme.PER_CHANNEL_SYMM,
|
37
|
+
}
|
38
|
+
|
39
|
+
def __str__(self) -> str:
|
40
|
+
return self.name.lower()
|
@@ -1,4 +1,4 @@
|
|
1
|
-
tico/__init__.py,sha256=
|
1
|
+
tico/__init__.py,sha256=xXynWlns6HYdl6Zf9xwJtdTnFkscm8b49vqhn8FYJZg,1883
|
2
2
|
tico/pt2_to_circle.py,sha256=gu3MD4Iqc0zMZcCZ2IT8oGbyj21CTSbT3Rgd9s2B_9A,2767
|
3
3
|
tico/config/__init__.py,sha256=xZzCXjZ84qE-CsBi-dfaL05bqpQ3stKKfTXhnrJRyVs,142
|
4
4
|
tico/config/base.py,sha256=q5xMqGxTUZs4mFqt5c7i_y9U00fYgdMGl9nUqIVMlCo,1248
|
@@ -43,7 +43,7 @@ tico/experimental/quantization/algorithm/smoothquant/smooth_quant.py,sha256=O1h7
|
|
43
43
|
tico/experimental/quantization/evaluation/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
44
44
|
tico/experimental/quantization/evaluation/backend.py,sha256=CZL9rZOA0t8cH7PHp6u9l7dGqWNvTj9bKOvwo0PVul0,692
|
45
45
|
tico/experimental/quantization/evaluation/evaluate.py,sha256=kfa_GvFaX6DoSTAmuCImMJqF2jgqtnor5UpC7wVmGPI,7877
|
46
|
-
tico/experimental/quantization/evaluation/metric.py,sha256=
|
46
|
+
tico/experimental/quantization/evaluation/metric.py,sha256=t9M058dOQ8iy_2PcrbNMAebBNJs8TU8USZw_nbi2iWI,5488
|
47
47
|
tico/experimental/quantization/evaluation/utils.py,sha256=82RG_e5LuKfWo786wEZUVwXY93nNl901n04fB7D0Z6k,5909
|
48
48
|
tico/experimental/quantization/evaluation/executor/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
49
49
|
tico/experimental/quantization/evaluation/executor/backend_executor.py,sha256=3kLu3_rcsreA_NK42yRgRgubPtZmVp7QCRvaqLNw10E,1522
|
@@ -56,6 +56,10 @@ tico/experimental/quantization/passes/propagate_qparam_backward.py,sha256=TGtyW0
|
|
56
56
|
tico/experimental/quantization/passes/propagate_qparam_forward.py,sha256=RhUHGCR2RpBO5KYkQ7Z8U5u7HEwDq2wdKHLKAJCi-5c,5138
|
57
57
|
tico/experimental/quantization/passes/quantize_bias.py,sha256=T7YxJ70N0tSK0FF9VJZA5iP0sHdnnsX9GX4AT4JDFSk,4325
|
58
58
|
tico/experimental/quantization/passes/remove_weight_dequant_op.py,sha256=gI1MtrHazWpdNfys7f1ngTTWplzluF7SA-uX0HMR5Mc,6592
|
59
|
+
tico/experimental/quantization/ptq/__init__.py,sha256=ZoPdEwZ1i1n5pBFChx8GuUrkfRP2vsSoLPNILQjNBaA,298
|
60
|
+
tico/experimental/quantization/ptq/dtypes.py,sha256=xfCBtq6mQmUYRwsoFgII6gvRl1raQi0Inj9pznDuKwQ,2236
|
61
|
+
tico/experimental/quantization/ptq/mode.py,sha256=lT-T8vIv8YWcwrjT7xXVhOw1g7aoAdh_3PWB-ptPKaI,1052
|
62
|
+
tico/experimental/quantization/ptq/qscheme.py,sha256=uwhv7bCxOOXB3I-IKlRyr_u4eXOq48uIqGy4TLDqGxY,1301
|
59
63
|
tico/interpreter/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
60
64
|
tico/interpreter/infer.py,sha256=1ZFe3DVMR2mlwBosoedqoL0-CGN_01CKLgMgxuw62KA,4861
|
61
65
|
tico/interpreter/interpreter.py,sha256=tGbluCbrehTCqBu8mtGDNzby_ieJ2ry8_RH_eC0CQxk,3828
|
@@ -206,9 +210,9 @@ tico/utils/mx/__init__.py,sha256=IO6FP_xYbGy0dW0HL26GXD3ouxARaxCK7bz9dn4blPQ,26
|
|
206
210
|
tico/utils/mx/elemwise_ops.py,sha256=V6glyAHsVR1joqpsgnNytatCD_ew92xNWZ19UFDoMTA,10281
|
207
211
|
tico/utils/mx/formats.py,sha256=uzNWyu-1onUlwQfX5cZ6fZSUfHMRqorper7_T1k3jfk,3404
|
208
212
|
tico/utils/mx/mx_ops.py,sha256=RcfUTYVi-wilGB2sC35OeARdwDqnixv7dG5iyZ-fQT8,8555
|
209
|
-
tico-0.1.0.
|
210
|
-
tico-0.1.0.
|
211
|
-
tico-0.1.0.
|
212
|
-
tico-0.1.0.
|
213
|
-
tico-0.1.0.
|
214
|
-
tico-0.1.0.
|
213
|
+
tico-0.1.0.dev250807.dist-info/LICENSE,sha256=kp4JLII7bzRhPb0CPD5XTDZMh22BQ7h3k3B7t8TiSbw,12644
|
214
|
+
tico-0.1.0.dev250807.dist-info/METADATA,sha256=ATnzGR44gSRsXtSTjRBwY0DOQK512GtszXrNo3r3rD4,8450
|
215
|
+
tico-0.1.0.dev250807.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
216
|
+
tico-0.1.0.dev250807.dist-info/entry_points.txt,sha256=kBKYSS_IYrSXmUYevmmepqIVPScq5vF8ulQRu3I_Zf0,59
|
217
|
+
tico-0.1.0.dev250807.dist-info/top_level.txt,sha256=oqs7UPoNSKZEwqsX8B-KAWdQwfAa7i60pbxW_Jk7P3w,5
|
218
|
+
tico-0.1.0.dev250807.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|