Browse Source

fix(mge/quantization): fix lsq init format error

GitOrigin-RevId: 032de9c773
tags/v1.6.0-rc1
Megvii Engine Team 3 years ago
parent
commit
3e58cbb8d2
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      imperative/python/megengine/quantization/fake_quant.py

+ 4
- 1
imperative/python/megengine/quantization/fake_quant.py View File

@@ -132,7 +132,7 @@ class LSQ(_FakeQuantize, QParamsModuleMixin):
:param eps:a small value to avoid division by zero. Default: 1e-5
"""

def init(
def __init__(
self,
dtype: Union[str, QuantDtypeMeta],
enable: bool = True,
@@ -142,6 +142,9 @@ class LSQ(_FakeQuantize, QParamsModuleMixin):
super().__init__(dtype=dtype, enable=enable, **kwargs)
self.eps = Tensor(eps, dtype="float32")
self.step_size = Parameter(1.0, dtype="float32")
self.mode = None
self.zero_point = Tensor(0.0, dtype="float32")
self.grad_scale = Tensor(1.0, dtype="float32")

def set_qparams(self, qparams: LSQParams):
self.mode = qparams.mode


Loading…
Cancel
Save