MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / set_qconfig

Method set_qconfig

imperative/python/megengine/module/qat/module.py:37–50  ·  view source on GitHub ↗

r"""Set quantization related configs with ``qconfig``, including observer and fake_quant for weight and activation.

(self, qconfig: QConfig)

Source from the content-addressed store, hash-verified

35 return "QAT." + super().__repr__()
36
37 def set_qconfig(self, qconfig: QConfig):
38 r"""Set quantization related configs with ``qconfig``, including
39 observer and fake_quant for weight and activation.
40 """
41
42 def safe_call(func):
43 return func() if func is not None else None
44
45 if self.with_act:
46 self.act_observer = safe_call(qconfig.act_observer)
47 self.act_fake_quant = safe_call(qconfig.act_fake_quant)
48 if self.with_weight:
49 self.weight_observer = safe_call(qconfig.weight_observer)
50 self.weight_fake_quant = safe_call(qconfig.weight_fake_quant)
51
52 def _enable_exec(self, with_module, func, enable):
53 if not with_module or not func:

Callers

nothing calls this directly

Calls 1

safe_callFunction · 0.85

Tested by

no test coverage detected