aihwkit.simulator.digital_low_precision.base_quantized_classes module

class aihwkit.simulator.digital_low_precision.base_quantized_classes.FP32Acts(*args, **kwargs)[source]

Bases: Module

Parameters:
  • args (Any)

  • kwargs (Any)

forward(x)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

reset_ranges()[source]
class aihwkit.simulator.digital_low_precision.base_quantized_classes.QuantizedActivation(*args, **kwargs)[source]

Bases: QuantizedModule

forward(x)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

quantize_activations(x)[source]
class aihwkit.simulator.digital_low_precision.base_quantized_classes.QuantizedModule(*args, method=QMethods.asymmetric_uniform, act_method=None, n_bits=8, n_bits_act=None, per_channel_weights=False, per_channel_acts=False, percentile=None, weight_range_method=RangeEstimators.current_minmax, weight_range_options=None, act_range_method=RangeEstimators.running_minmax, act_range_options=None, scale_domain='linear', **kwargs)[source]

Bases: Module

Parent class for a quantized module. It adds the basic functionality of switching the module between quantized and full precision mode. It also defines the cached parameters and handles the reset of the cache properly.

property caching
estimate_ranges()[source]
estimate_ranges_train()[source]
extra_repr()[source]

Return the extra representation of the module.

To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.

fix_ranges()[source]
full_precision()[source]
full_precision_acts()[source]
full_precision_weights()[source]
learn_ranges()[source]
quantized()[source]
quantized_acts()[source]
quantized_weights()[source]
train(mode=True)[source]

Set the module in training mode.

This has an effect only on certain modules. See the documentation of particular modules for details of their behaviors in training/evaluation mode, i.e., whether they are affected, e.g. Dropout, BatchNorm, etc.

Parameters:

mode (bool) – whether to set training mode (True) or evaluation mode (False). Default: True.

Returns:

self

Return type:

Module