Skip to content

Commit 13717ca

Browse files
committed
rm redundant
1 parent 70b4918 commit 13717ca

File tree

5 files changed

+2
-6
lines changed

5 files changed

+2
-6
lines changed

sparsebit/quantization/observers/aciq.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ def __init__(self, config, qdesc):
6161
8: 11.16,
6262
}
6363
self.gaus_const = (0.5 * 0.35) * (1 + (math.pi * math.log(4)) ** 0.5)
64-
self.distribution = config.OBSERVER.ACIQ.DISTRIBUTION.lower()
65-
assert self.distribution in ["gaus", "laplace"]
6664

6765
def calc_laplace_minmax(self):
6866
if self.is_perchannel:

sparsebit/quantization/observers/mse.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ def __init__(self, config, qdesc):
1717

1818
def calc_minmax(self, data_c_first):
1919
if self.is_perchannel:
20-
data_c_first = self.get_calibration_data(c_first=True)
2120
max_val = data_c_first.max(axis=1).values
2221
min_val = data_c_first.min(axis=1).values
2322
else:
24-
data_c_first = self.get_calibration_data(c_first=False)
2523
min_val, max_val = data_c_first.min(), data_c_first.max()
2624
self.min_val = min_val.to(self.device)
2725
self.max_val = max_val.to(self.device)

sparsebit/quantization/observers/percentile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def __init__(self, config, qdesc):
1414
self.alpha = config.OBSERVER.PERCENTILE.ALPHA
1515

1616
def calc_minmax(self):
17+
1718
if self.is_perchannel:
1819
data = self.data_cache.get_data_for_calibration(Granularity.CHANNELWISE)
1920
else:

sparsebit/quantization/quant_model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ def export_onnx(
246246
extra_info=False,
247247
):
248248
self.eval()
249+
self.set_quant(w_quant=True, a_quant=True) # quant must prepared before export
249250
for n, m in self.model.named_modules():
250251
if isinstance(m, Quantizer):
251252
m.enable_export_onnx()

sparsebit/quantization/quantizers/lsq.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ def calc_qparams(self):
4242
)
4343
self.qdesc.set_symmetric(True)
4444
if self.is_perchannel:
45-
x_oc = self.observer.get_calibration_data(c_first=True)
4645
scale = 2 * x_oc.abs().mean(axis=1) / math.sqrt(self.qdesc.qmax)
4746
else:
48-
x_oc = self.observer.get_calibration_data(c_first=False)
4947
scale = 2 * x_oc.abs().mean() / math.sqrt(self.qdesc.qmax)
5048
self.scale = nn.Parameter(self._broadcast_qparams(scale.to(self.device)))
5149
self.zero_point = self._broadcast_qparams(torch.zeros_like(self.scale))

0 commit comments

Comments
 (0)