aihwkit.nn.modules.conv module¶
Convolution layers.
-
class
aihwkit.nn.modules.conv.
AnalogConv1d
(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros', rpu_config=None, realistic_read_write=False, weight_scaling_omega=0.0)¶ Bases:
aihwkit.nn.modules.conv._AnalogConvNd
1D convolution layer that uses an analog tile.
Applies a 1D convolution over an input signal composed of several input planes, using an analog tile for 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 useset_weights
andget_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
in_channels – number of channels in the input image.
out_channels – number of channels produced by the convolution.
kernel_size – size of the convolving kernel.
stride – stride of the convolution.
padding – zero-padding added to both sides of the input.
dilation – spacing between kernel elements.
groups – number of blocked connections from input channels to output channels.
bias – whether to use a bias row on the analog tile or not.
padding_mode – padding strategy. Only
'zeros'
is supported.rpu_config – resistive processing unit configuration.
realistic_read_write – whether to enable realistic read/write for setting initial weights and read out of weights.
weight_scaling_omega – the weight value where the max weight will be scaled to. If zero, no weight scaling will be performed.
-
dilation
¶
-
fold_indices
¶
-
get_tile_size
(in_channels, groups, kernel_size)¶ Calculate the tile size.
- Parameters
in_channels (int) –
groups (int) –
kernel_size (Tuple[int, ..]) –
- Return type
int
-
groups
¶
-
in_channels
¶
-
in_features
¶
-
input_size
¶
-
kernel_size
¶
-
out_channels
¶
-
out_features
¶
-
output_padding
¶
-
padding
¶
-
padding_mode
¶
-
realistic_read_write
¶
-
recalculate_indexes
(x_input)¶ Calculate and set the indexes of the analog tile.
- Parameters
x_input (torch.Tensor) –
- Return type
None
-
stride
¶
-
transposed
¶
-
weight_scaling_omega
¶
-
class
aihwkit.nn.modules.conv.
AnalogConv2d
(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros', rpu_config=None, realistic_read_write=False, weight_scaling_omega=0.0)¶ Bases:
aihwkit.nn.modules.conv._AnalogConvNd
2D convolution layer that uses an analog tile.
Applies a 2D convolution over an input signal composed of several input planes, using an analog tile for 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 useset_weights
andget_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
in_channels – number of channels in the input image.
out_channels – number of channels produced by the convolution.
kernel_size – size of the convolving kernel.
stride – stride of the convolution.
padding – zero-padding added to both sides of the input.
dilation – spacing between kernel elements.
groups – number of blocked connections from input channels to output channels.
bias – whether to use a bias row on the analog tile or not.
padding_mode – padding strategy. Only
'zeros'
is supported.rpu_config – resistive processing unit configuration.
realistic_read_write – whether to enable realistic read/write for setting initial weights and read out of weights.
weight_scaling_omega – the weight value where the max weight will be scaled to. If zero, no weight scaling will be performed.
-
dilation
¶
-
fold_indices
¶
-
get_tile_size
(in_channels, groups, kernel_size)¶ Calculate the tile size.
- Parameters
in_channels (int) –
groups (int) –
kernel_size (Tuple[int, ..]) –
- Return type
int
-
groups
¶
-
in_channels
¶
-
in_features
¶
-
input_size
¶
-
kernel_size
¶
-
out_channels
¶
-
out_features
¶
-
output_padding
¶
-
padding
¶
-
padding_mode
¶
-
realistic_read_write
¶
-
recalculate_indexes
(x_input)¶ Calculate and set the indexes of the analog tile.
- Parameters
x_input (torch.Tensor) –
- Return type
None
-
stride
¶
-
transposed
¶
-
weight_scaling_omega
¶
-
class
aihwkit.nn.modules.conv.
AnalogConv3d
(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros', rpu_config=None, realistic_read_write=False, weight_scaling_omega=0.0)¶ Bases:
aihwkit.nn.modules.conv._AnalogConvNd
3D convolution layer that uses an analog tile.
Applies a 3D convolution over an input signal composed of several input planes, using an analog tile for 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 useset_weights
andget_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
in_channels – number of channels in the input image.
out_channels – number of channels produced by the convolution.
kernel_size – size of the convolving kernel.
stride – stride of the convolution.
padding – zero-padding added to both sides of the input.
dilation – spacing between kernel elements.
groups – number of blocked connections from input channels to output channels.
bias – whether to use a bias row on the analog tile or not.
padding_mode – padding strategy. Only
'zeros'
is supported.rpu_config – resistive processing unit configuration.
realistic_read_write – whether to enable realistic read/write for setting initial weights and read out of weights.
weight_scaling_omega – the weight value where the max weight will be scaled to. If zero, no weight scaling will be performed.
-
dilation
¶
-
fold_indices
¶
-
get_tile_size
(in_channels, groups, kernel_size)¶ Calculate the tile size.
- Parameters
in_channels (int) –
groups (int) –
kernel_size (Tuple[int, ..]) –
- Return type
int
-
groups
¶
-
in_channels
¶
-
in_features
¶
-
input_size
¶
-
kernel_size
¶
-
out_channels
¶
-
out_features
¶
-
output_padding
¶
-
padding
¶
-
padding_mode
¶
-
realistic_read_write
¶
-
recalculate_indexes
(x_input)¶ Calculate and set the indexes of the analog tile.
- Parameters
x_input (torch.Tensor) –
- Return type
None
-
stride
¶
-
transposed
¶
-
weight_scaling_omega
¶