aihwkit.nn.modules.linear_mapped module
Analog mapped linear layer.
- class aihwkit.nn.modules.linear_mapped.AnalogLinearMapped(in_features, out_features, bias=True, rpu_config=None, tile_module_class=<class 'aihwkit.simulator.tiles.array.TileModuleArray'>)[source]
Bases:
AnalogLinearLinear layer that uses one or several analog tiles.
Linear layer that uses an analog tile during its forward, backward and update passes. In contrast to
Linearthe maximal in and/or out dimension can be restricted, in which case the linear layer is split into multiple parts and computed on multiple tiles of given max sizes.In contrast to
Linear, the bias vector (if requested) is always handled in digital (floating point).Internally the
TileModuleArrayis used for the logical tiling process.Note
Mapping is controlled by the
MappingParameter.Note
The tensor parameters of this layer (
.weightand.bias) are not guaranteed to contain the same values as the internal weights and biases stored in the analog tile. Please useset_weightsandget_weightswhen attempting to read or modify the weight/bias.- Parameters:
in_features (int) – input vector size (number of columns).
out_features (int) – output vector size (number of rows).
rpu_config (MappableRPU | None) – resistive processing unit configuration.
bias (bool) – whether to use a bias row on the analog tile or not
tile_module_class (Type | None)
- classmethod from_digital(module, rpu_config, tile_module_class=<class 'aihwkit.simulator.tiles.array.TileModuleArray'>)[source]
Return an AnalogLinear layer from a torch Linear layer.
- Parameters:
module (Linear) – The torch module to convert. All layers that are defined in the
conversion_map.rpu_config (RPUConfigBase) – RPU config to apply to all converted tiles. Applied to all converted tiles.
tile_module_class (Type | None) – Class of the underlying TileModule. If not given, will select based on the MappingParameter setting either
TileModuleBaseorTileModuleArray
- Returns:
an AnalogLinear layer based on the digital Linear
module.- Raises:
ConfigError – In case the
RPUConfigis not of typeMappableRPU- Return type: