aihwkit.nn.modules.rnn.layers module¶
Analog RNN layers
- class aihwkit.nn.modules.rnn.layers.AnalogBidirRNNLayer(cell, *cell_args)[source]¶
Bases:
aihwkit.nn.modules.container.AnalogSequential
Bi-directional analog RNN layer.
- Parameters
cell (Type) – RNNCell type (AnalogLSTMCell/AnalogGRUCell/AnalogVanillaRNNCell)
cell_args (Any) – arguments to RNNCell (e.g. input_size, hidden_size, rpu_configs)
- forward(input_, states)[source]¶
Defines 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.- Parameters
input_ (torch.Tensor) –
states (List[Union[Tuple[torch.Tensor, torch.Tensor], torch.Tensor]]) –
- Return type
Tuple[torch.Tensor, List[Union[Tuple[torch.Tensor, torch.Tensor], torch.Tensor]]]
- class aihwkit.nn.modules.rnn.layers.AnalogRNNLayer(cell, *cell_args)[source]¶
Bases:
aihwkit.nn.modules.container.AnalogSequential
Analog RNN Layer.
- Parameters
cell (Type) – RNNCell type (AnalogLSTMCell/AnalogGRUCell/AnalogVanillaRNNCell)
cell_args (Any) – arguments to RNNCell (e.g. input_size, hidden_size, rpu_configs)
- forward(input_, state)[source]¶
Defines 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.- Parameters
input_ (torch.Tensor) –
state (Union[Tuple[torch.Tensor, torch.Tensor], torch.Tensor]) –
- Return type
Tuple[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]
- class aihwkit.nn.modules.rnn.layers.AnalogReverseRNNLayer(cell, *cell_args)[source]¶
Bases:
aihwkit.nn.modules.container.AnalogSequential
Analog RNN layer for direction.
- Parameters
cell (Type) – RNNCell type (AnalogLSTMCell/AnalogGRUCell/AnalogVanillaRNNCell)
cell_args (Any) – arguments to RNNCell (e.g. input_size, hidden_size, rpu_configs)
- forward(input_, state)[source]¶
Defines 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.- Parameters
input_ (torch.Tensor) –
state (Union[Tuple[torch.Tensor, torch.Tensor], torch.Tensor]) –
- Return type
Tuple[torch.Tensor, Union[Tuple[torch.Tensor, torch.Tensor], torch.Tensor]]
- aihwkit.nn.modules.rnn.layers.stack(tensors, dim=0, *, out=None) → Tensor¶
Concatenates a sequence of tensors along a new dimension.
All tensors need to be of the same size.
- Parameters
tensors (sequence of Tensors) – sequence of tensors to concatenate
dim (int) – dimension to insert. Has to be between 0 and the number of dimensions of concatenated tensors (inclusive)
- Keyword Arguments
out (Tensor, optional) – the output tensor.