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

Method set_qparams

imperative/python/megengine/quantization/fake_quant.py:87–93  ·  view source on GitHub ↗
(self, qparams: QParams)

Source from the content-addressed store, hash-verified

85 return tqt_forward(self.qmin, self.qmax, inp, self.scale)
86
87 def set_qparams(self, qparams: QParams):
88 assert (
89 qparams.mode == QuantMode.SYMMERTIC
90 ), "only symmetric quantization is supported by TQT"
91 if qparams.scale is None:
92 raise AssertionError("Can not get an initialized scale")
93 self.scale[...] = F.log(qparams.scale) / math.log(2)
94
95 def get_qparams(self):
96 return create_qparams(QuantMode.SYMMERTIC, self.dtype, scale=2 ** self.scale)

Callers 1

safe_callFunction · 0.45

Calls 2

AssertionErrorClass · 0.85
logMethod · 0.45

Tested by

no test coverage detected