Some supportive functions


class pytorch_quantization.nn.functional.ClipFunction(*args, **kwargs)[source]

An universal tensor clip function

Pytorch’s clamp() only supports scalar range and doesn’t support broadcast. This implementation uses min/max which is more genaral. The gradient is defined according to IBM’s PACT paper, which is also the behavior of Tensorflow’s clip_by_value()

clip is alias of ClipFunction.apply