bitorch.quantizations.dorefa.InputDoReFaFunction¶
- class bitorch.quantizations.dorefa.InputDoReFaFunction(*args, **kwargs)[source]¶
Methods
just passes the unchanged output gradient as input gradient (i.e.
quantizes input tensor and forwards it.
Attributes
- static backward(ctx: Any, output_gradient: Tensor) Tuple[Tensor, None] [source]¶
just passes the unchanged output gradient as input gradient (i.e. applies straight through estimator)
- Parameters:
ctx (Any) – autograd context
output_gradient (torch.Tensor) – output gradient
- Returns:
the unchanged output gradient
- Return type:
torch.Tensor
- static forward(ctx: BackwardCFunction, input_tensor: Tensor, bits: int) Tensor [source]¶
quantizes input tensor and forwards it.
- Parameters:
ctx (Any) – autograd context
input_tensor (torch.Tensor) – input tensor
bits (int) – number of bits to round the input tensor to
- Returns:
the quantized input tensor
- Return type:
torch.Tensor