MCPcopy
hub / github.com/OpenPPL/ppq / update

Method update

ppq/quantization/analyse/util/__init__.py:32–47  ·  view source on GitHub ↗
(self, y_pred: torch.Tensor, y_real: torch.Tensor)

Source from the content-addressed store, hash-verified

30 self.reduce = reduce
31
32 def update(self, y_pred: torch.Tensor, y_real: torch.Tensor):
33 elements = y_pred.shape[0]
34 if elements != y_real.shape[0]:
35 raise Exception(
36 'Can not update measurement, cause your input data do not share a same batchsize. '
37 f'Shape of y_pred {y_pred.shape} - against shape of y_real {y_real.shape}')
38 result = self.measure_fn(y_pred=y_pred, y_real=y_real).item()
39
40 if self.reduce == 'mean':
41 self.measure = self.measure * self.num_of_elements + result * elements
42 self.num_of_elements += elements
43 self.measure /= self.num_of_elements
44
45 if self.reduce == 'max':
46 self.measure = max(self.measure, result)
47 self.num_of_elements += elements
48
49class MeasurePrinter():
50 """Helper class for print top-k record."""

Callers 15

dispatchMethod · 0.80
dispatchMethod · 0.80
dispatchMethod · 0.80
calib_blockMethod · 0.80
calibrateMethod · 0.80
optimizeMethod · 0.80
quant_operation_typesMethod · 0.80
quant_operation_typesMethod · 0.80
quant_operation_typesMethod · 0.80
layerwise_error_analyseFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected