MCPcopy Create free account
hub / github.com/OpenGVLab/EfficientQAT / round_ste

Function round_ste

quantize/quantizer.py:10–14  ·  view source on GitHub ↗

Implement Straight-Through Estimator for rounding operation.

(x: torch.Tensor)

Source from the content-addressed store, hash-verified

8
9
10def round_ste(x: torch.Tensor):
11 """
12 Implement Straight-Through Estimator for rounding operation.
13 """
14 return (x.round() - x).detach() + x
15
16def clamp_ste(x: torch.Tensor, min, max):
17 return (x.clamp(min,max) - x).detach() + x

Callers 1

fake_quantMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected