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

Method remove_quantize_delegate

ppq/executor/torch.py:325–348  ·  view source on GitHub ↗

Since PPQ 0.6.2, Interface TorchQuantizeDelegate is introduced to customize quantization logic: To be specific, you are suppose to inherit this class, and define your own computation logic within function __call__. Pass your Delegate to TorchExecutor by TorchExec

(
        self, config: TensorQuantizationConfig)

Source from the content-addressed store, hash-verified

323 self._delegates[config] = delegator
324
325 def remove_quantize_delegate(
326 self, config: TensorQuantizationConfig):
327 """Since PPQ 0.6.2, Interface TorchQuantizeDelegate is introduced to
328 customize quantization logic: To be specific, you are suppose to
329 inherit this class, and define your own computation logic within
330 function __call__.
331
332 Pass your Delegate to TorchExecutor by TorchExecutor.register_quantize_delegate(c, d)
333 Where c is the target quantization config, d is your delegator class.
334 Once you invoke this function, PPQ execution system will hand the quantization
335 computation of config c over to your delegate. PPQ execution system will no
336 longer quantize variable related with config c anymore.
337
338 Notice that a delegate replaces quantization computation only, it still under the control of PPQ quantization
339 System, so to say if your config has an invalid state like DEQUANTIZED, PPQ execution system will never been
340 required to quantize related tensor and so your delegate class will take no effects on config c.
341
342 Remove delegate function by TorchExecutor.remove_quantize_delegate(c)
343 """
344 if not isinstance(config, TensorQuantizationConfig):
345 raise TypeError(
346 f'Except a TensorQuantizationConfig instance, however {type(config)} was passed.')
347 if config in self._delegates:
348 self._delegates.pop(config)
349
350 def deploy(self):
351 """Deploy graph parameters towards target device.

Callers 4

calib_blockMethod · 0.80
finetuneMethod · 0.80
finetuneMethod · 0.80

Calls 1

popMethod · 0.45

Tested by

no test coverage detected