analogvnn.nn.precision.ReducePrecision#

Module Contents#

Classes#

ReducePrecision

Implements the reduce precision function.

class analogvnn.nn.precision.ReducePrecision.ReducePrecision(precision: int = None, divide: float = 0.5)[source]#

Bases: analogvnn.nn.precision.Precision.Precision, analogvnn.backward.BackwardIdentity.BackwardIdentity

Implements the reduce precision function.

Variables:
  • precision (nn.Parameter) – the precision of the output tensor.

  • divide (nn.Parameter) – the rounding value that is if divide is 0.5, then 0.6 will be rounded to 1.0 and 0.4 will be rounded to 0.0.

property precision_width: torch.Tensor[source]#

The precision width.

Returns:

the precision width

Return type:

Tensor

property bit_precision: torch.Tensor[source]#

The bit precision of the ReducePrecision module.

Returns:

the bit precision of the ReducePrecision module.

Return type:

Tensor

__constants__ = ['precision', 'divide'][source]#
precision: torch.nn.Parameter[source]#
divide: torch.nn.Parameter[source]#
static convert_to_precision(bit_precision: analogvnn.utils.common_types.TENSOR_OPERABLE) analogvnn.utils.common_types.TENSOR_OPERABLE[source]#

Convert the bit precision to the precision.

Parameters:

bit_precision (TENSOR_OPERABLE) – the bit precision.

Returns:

the precision.

Return type:

TENSOR_OPERABLE

extra_repr() str[source]#

The extra __repr__ string of the ReducePrecision module.

Returns:

string

Return type:

str

forward(x: torch.Tensor) torch.Tensor[source]#

Forward function of the ReducePrecision module.

Parameters:

x (Tensor) – the input tensor.

Returns:

the output tensor.

Return type:

Tensor