aihwkit.nn.modules.linear module

Analog layers.

class aihwkit.nn.modules.linear.AnalogLinear(in_features, out_features, bias=True, rpu_config=None, realistic_read_write=False, weight_scaling_omega=None)[source]

Bases: aihwkit.nn.modules.base.AnalogModuleBase, torch.nn.modules.linear.Linear

Linear layer that uses an analog tile.

Linear layer that uses an analog tile during its forward, backward and update passes.

Note

The tensor parameters of this layer (.weight and .bias) are not guaranteed to contain the same values as the internal weights and biases stored in the analog tile. Please use set_weights and get_weights when attempting to read or modify the weight/bias. This read/write process can simulate the (noisy and inexact) analog writing and reading of the resistive elements.

Parameters
analog_bias: bool
digital_bias: bool
forward(x_input)[source]

Compute the forward pass.

Parameters

x_input (torch.Tensor) –

Return type

torch.Tensor

classmethod from_digital(module, rpu_config=None, realistic_read_write=False)[source]

Return an AnalogLinear layer from a torch Linear layer.

Parameters
Returns

an AnalogLinear layer based on the digital Linear module.

Return type

aihwkit.nn.modules.linear.AnalogLinear

in_features: int
out_features: int
realistic_read_write: bool
reset_parameters()[source]

Reset the parameters (weight and bias).

Return type

None

use_bias: bool
weight_scaling_omega: float