aihwkit.simulator.digital_low_precision.range_estimators module

class aihwkit.simulator.digital_low_precision.range_estimators.AllMinMaxEstimator(*args, **kwargs)[source]

Bases: RangeEstimatorBase

forward(x)[source]

Accepts an input tensor, updates the current estimates of x_min and x_max and retruns them. :param x: :type x: Input tensor

Returns:

  • self.current_xmin (tensor)

  • self.current_xmax (tensor)

class aihwkit.simulator.digital_low_precision.range_estimators.CrossEntropyEstimator(*args, **kwargs)[source]

Bases: MSE_Estimator

loss_fx(data, neg_thr, pos_thr, per_channel_loss=False)[source]
class aihwkit.simulator.digital_low_precision.range_estimators.CurrentMinMaxEstimator(percentile=None, *args, **kwargs)[source]

Bases: RangeEstimatorBase

forward(x)[source]

Accepts an input tensor, updates the current estimates of x_min and x_max and retruns them. :param x: :type x: Input tensor

Returns:

  • self.current_xmin (tensor)

  • self.current_xmax (tensor)

class aihwkit.simulator.digital_low_precision.range_estimators.MSE_Estimator(num_candidates=100, opt_method=OptMethod.grid, range_margin=0.5, *args, **kwargs)[source]

Bases: RangeEstimatorBase

forward(data)[source]

Accepts an input tensor, updates the current estimates of x_min and x_max and retruns them. :param x: :type x: Input tensor

Returns:

  • self.current_xmin (tensor)

  • self.current_xmax (tensor)

golden_asym_range_loss(range, data)[source]
Outer Loss function (range) passed to the golden section optimizer from scipy in case of

asymmetric quantization

golden_asym_shift_loss(shift, range, data)[source]

Inner Loss function (shift) passed to the golden section optimizer from scipy in case of asymmetric quantization

golden_sym_loss(range, data)[source]

Loss function passed to the golden section optimizer from scipy in case of symmetric quantization

loss_fx(data, neg_thr, pos_thr, per_channel_loss=False)[source]
property optimization_method
quantize(x_float, x_min=None, x_max=None)[source]
reset()[source]

Reset the range estimator.

property step_size
exception aihwkit.simulator.digital_low_precision.range_estimators.NoDataPassedError[source]

Bases: Exception

Raised data has been passed inot the Range Estimator.

class aihwkit.simulator.digital_low_precision.range_estimators.OptMethod(*values)[source]

Bases: Enum

golden_section = 2
grid = 1
classmethod list()[source]
class aihwkit.simulator.digital_low_precision.range_estimators.RangeEstimatorBase(per_channel=False, quantizer=None, axis=None, n_groups=None, *args, **kwargs)[source]

Bases: Module

forward(x)[source]

Accepts an input tensor, updates the current estimates of x_min and x_max and retruns them. :param x: :type x: Input tensor

Returns:

  • self.current_xmin (tensor)

  • self.current_xmax (tensor)

reset()[source]

Reset the range estimator.

class aihwkit.simulator.digital_low_precision.range_estimators.RangeEstimatorMap(value, cls)

Bases: tuple

cls

Alias for field number 1

value

Alias for field number 0

class aihwkit.simulator.digital_low_precision.range_estimators.RangeEstimators(*values)[source]

Bases: Enum

MSE = (3, <class 'aihwkit.simulator.digital_low_precision.range_estimators.MSE_Estimator'>)
allminmax = (1, <class 'aihwkit.simulator.digital_low_precision.range_estimators.AllMinMaxEstimator'>)
property cls
cross_entropy = (4, <class 'aihwkit.simulator.digital_low_precision.range_estimators.CrossEntropyEstimator'>)
current_minmax = (0, <class 'aihwkit.simulator.digital_low_precision.range_estimators.CurrentMinMaxEstimator'>)
classmethod list()[source]
running_minmax = (2, <class 'aihwkit.simulator.digital_low_precision.range_estimators.RunningMinMaxEstimator'>)
class aihwkit.simulator.digital_low_precision.range_estimators.RunningMinMaxEstimator(momentum=0.9, *args, **kwargs)[source]

Bases: RangeEstimatorBase

forward(x)[source]

Accepts an input tensor, updates the current estimates of x_min and x_max and retruns them. :param x: :type x: Input tensor

Returns:

  • self.current_xmin (tensor)

  • self.current_xmax (tensor)