Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/cells.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This page documents all custom recurrent cells provided in the `torchrecurrent.c
torchrecurrent.LightRUCell
torchrecurrent.LiGRUCell
torchrecurrent.MGUCell
torchrecurrent.MinimalRNNCell
torchrecurrent.MiRU1Cell
torchrecurrent.MiRU2Cell
torchrecurrent.MultiplicativeLSTMCell
Expand Down
1 change: 1 addition & 0 deletions docs/api/layers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This page documents all custom recurrent layers provided in the `torchrecurrent`
torchrecurrent.LightRU
torchrecurrent.LiGRU
torchrecurrent.MGU
torchrecurrent.MinimalRNN
torchrecurrent.MiRU1
torchrecurrent.MiRU2
torchrecurrent.MultiplicativeLSTM
Expand Down
86 changes: 86 additions & 0 deletions docs/generated/torchrecurrent.MinimalRNN.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
torchrecurrent.MinimalRNN
==========================

.. currentmodule:: torchrecurrent

.. autoclass:: MinimalRNN


.. automethod:: __init__


.. rubric:: Methods

.. autosummary::

~MinimalRNN.__init__
~MinimalRNN.add_module
~MinimalRNN.apply
~MinimalRNN.bfloat16
~MinimalRNN.buffers
~MinimalRNN.children
~MinimalRNN.compile
~MinimalRNN.cpu
~MinimalRNN.cuda
~MinimalRNN.double
~MinimalRNN.eval
~MinimalRNN.extra_repr
~MinimalRNN.float
~MinimalRNN.forward
~MinimalRNN.get_buffer
~MinimalRNN.get_extra_state
~MinimalRNN.get_parameter
~MinimalRNN.get_submodule
~MinimalRNN.half
~MinimalRNN.initialize_cells
~MinimalRNN.ipu
~MinimalRNN.load_state_dict
~MinimalRNN.modules
~MinimalRNN.mtia
~MinimalRNN.named_buffers
~MinimalRNN.named_children
~MinimalRNN.named_modules
~MinimalRNN.named_parameters
~MinimalRNN.parameters
~MinimalRNN.register_backward_hook
~MinimalRNN.register_buffer
~MinimalRNN.register_forward_hook
~MinimalRNN.register_forward_pre_hook
~MinimalRNN.register_full_backward_hook
~MinimalRNN.register_full_backward_pre_hook
~MinimalRNN.register_load_state_dict_post_hook
~MinimalRNN.register_load_state_dict_pre_hook
~MinimalRNN.register_module
~MinimalRNN.register_parameter
~MinimalRNN.register_state_dict_post_hook
~MinimalRNN.register_state_dict_pre_hook
~MinimalRNN.requires_grad_
~MinimalRNN.set_extra_state
~MinimalRNN.set_submodule
~MinimalRNN.share_memory
~MinimalRNN.state_dict
~MinimalRNN.to
~MinimalRNN.to_empty
~MinimalRNN.train
~MinimalRNN.type
~MinimalRNN.xpu
~MinimalRNN.zero_grad





.. rubric:: Attributes

.. autosummary::

~MinimalRNN.T_destination
~MinimalRNN.call_super_init
~MinimalRNN.dump_patches
~MinimalRNN.input_size
~MinimalRNN.hidden_size
~MinimalRNN.bias
~MinimalRNN.dropout
~MinimalRNN.batch_first
~MinimalRNN.training

91 changes: 91 additions & 0 deletions docs/generated/torchrecurrent.MinimalRNNCell.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
torchrecurrent.MinimalRNNCell
==============================

.. currentmodule:: torchrecurrent

.. autoclass:: MinimalRNNCell


.. automethod:: __init__


.. rubric:: Methods

.. autosummary::

~MinimalRNNCell.__init__
~MinimalRNNCell.add_module
~MinimalRNNCell.apply
~MinimalRNNCell.bfloat16
~MinimalRNNCell.buffers
~MinimalRNNCell.children
~MinimalRNNCell.compile
~MinimalRNNCell.cpu
~MinimalRNNCell.cuda
~MinimalRNNCell.double
~MinimalRNNCell.eval
~MinimalRNNCell.extra_repr
~MinimalRNNCell.float
~MinimalRNNCell.forward
~MinimalRNNCell.get_buffer
~MinimalRNNCell.get_extra_state
~MinimalRNNCell.get_parameter
~MinimalRNNCell.get_submodule
~MinimalRNNCell.half
~MinimalRNNCell.ipu
~MinimalRNNCell.load_state_dict
~MinimalRNNCell.modules
~MinimalRNNCell.mtia
~MinimalRNNCell.named_buffers
~MinimalRNNCell.named_children
~MinimalRNNCell.named_modules
~MinimalRNNCell.named_parameters
~MinimalRNNCell.parameters
~MinimalRNNCell.register_backward_hook
~MinimalRNNCell.register_buffer
~MinimalRNNCell.register_forward_hook
~MinimalRNNCell.register_forward_pre_hook
~MinimalRNNCell.register_full_backward_hook
~MinimalRNNCell.register_full_backward_pre_hook
~MinimalRNNCell.register_load_state_dict_post_hook
~MinimalRNNCell.register_load_state_dict_pre_hook
~MinimalRNNCell.register_module
~MinimalRNNCell.register_parameter
~MinimalRNNCell.register_state_dict_post_hook
~MinimalRNNCell.register_state_dict_pre_hook
~MinimalRNNCell.requires_grad_
~MinimalRNNCell.reset_parameters
~MinimalRNNCell.set_extra_state
~MinimalRNNCell.set_submodule
~MinimalRNNCell.share_memory
~MinimalRNNCell.state_dict
~MinimalRNNCell.to
~MinimalRNNCell.to_empty
~MinimalRNNCell.train
~MinimalRNNCell.type
~MinimalRNNCell.uses_double_state
~MinimalRNNCell.xpu
~MinimalRNNCell.zero_grad





.. rubric:: Attributes

.. autosummary::

~MinimalRNNCell.T_destination
~MinimalRNNCell.call_super_init
~MinimalRNNCell.dump_patches
~MinimalRNNCell.weight_ih
~MinimalRNNCell.weight_hh
~MinimalRNNCell.weight_mm
~MinimalRNNCell.bias_ih
~MinimalRNNCell.bias_hh
~MinimalRNNCell.input_size
~MinimalRNNCell.hidden_size
~MinimalRNNCell.bias
~MinimalRNNCell.recurrent_bias
~MinimalRNNCell.training

3 changes: 3 additions & 0 deletions docs/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ references and official implementations where available.
* - :doc:`MGU <generated/torchrecurrent.MGU>`
- `IJAC 2016 <https://arxiv.org/abs/1603.09420>`__
- –
* - :doc:`MinimalRNN <generated/torchrecurrent.MinimalRNN>`
- `NeurIPS 2017 Workshop <https://arxiv.org/abs/1711.06788>`__
- –
* - :doc:`MiRU1 <generated/torchrecurrent.MiRU1>`
- `Neurocomputing 2026 <https://doi.org/10.1016/j.neucom.2026.132847>`__
- –
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "torchrecurrent"
version = "0.2.3"
version = "0.2.4"
description = "A package for recurrent neural networks in PyTorch"
readme = "README.md"
authors = [
Expand Down
18 changes: 14 additions & 4 deletions tests/test_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
import torch
from torch import Tensor

skip_windows = pytest.mark.skipif(
sys.platform == "win32",
reason="torch.compile requires Triton, which is not supported on Windows",
)
from torchrecurrent import (
AntisymmetricRNNCell,
ATRCell,
Expand All @@ -22,6 +18,7 @@
LEMCell,
GatedAntisymmetricRNNCell,
MGUCell,
MinimalRNNCell,
IndRNNCell,
LiGRUCell,
LightRUCell,
Expand All @@ -44,6 +41,11 @@
WMCLSTMCell,
)

skip_windows = pytest.mark.skipif(
sys.platform == "win32",
reason="torch.compile requires Triton, which is not supported on Windows",
)

CELL_CASES = [
# (CellClass, input_size, hidden_size, uses_double_state)
(AntisymmetricRNNCell, 3, 5, False),
Expand All @@ -59,6 +61,7 @@
(JANETCell, 3, 5, True),
(LEMCell, 3, 5, True),
(MGUCell, 4, 8, False),
(MinimalRNNCell, 3, 5, False),
(IndRNNCell, 3, 5, False),
(LiGRUCell, 6, 12, False),
(LightRUCell, 3, 5, False),
Expand Down Expand Up @@ -124,6 +127,13 @@ def test_cell_output_and_state_shapes(Cell, in_size, hid_size, double):
assert h3.shape == (B, hid_size)


@pytest.mark.parametrize("Cell, in_size, hid_size, double", CELL_CASES)
def test_cell_reset_parameters_after_construction(Cell, in_size, hid_size, double):
"""reset_parameters() must remain callable after __init__, not just during it."""
cell = Cell(in_size, hid_size)
cell.reset_parameters()


def test_reslstm_cell_parameter_shapes():
cell = ResLSTMCell(4, 9)

Expand Down
3 changes: 3 additions & 0 deletions tests/test_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
LiGRU,
LightRU,
MGU,
MinimalRNN,
MultiplicativeLSTM,
MUT1,
MUT2,
Expand Down Expand Up @@ -51,6 +52,7 @@
LiGRU,
LightRU,
MGU,
MinimalRNN,
MultiplicativeLSTM,
MUT1,
MUT2,
Expand Down Expand Up @@ -86,6 +88,7 @@
(LiGRU, False),
(LightRU, False),
(MGU, False),
(MinimalRNN, False),
(MultiplicativeLSTM, True),
(MUT1, False),
(MUT2, False),
Expand Down
4 changes: 4 additions & 0 deletions torchrecurrent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
LiGRUCell,
LightRUCell,
MGUCell,
MinimalRNNCell,
MiRU1Cell,
MiRU2Cell,
MultiplicativeLSTMCell,
Expand Down Expand Up @@ -56,6 +57,7 @@
LiGRU,
LightRU,
MGU,
MinimalRNN,
MiRU1,
MiRU2,
MultiplicativeLSTM,
Expand Down Expand Up @@ -95,6 +97,8 @@
"DSGUCell",
"MGU",
"MGUCell",
"MinimalRNN",
"MinimalRNNCell",
"MiRU1",
"MiRU1Cell",
"MiRU2",
Expand Down
4 changes: 2 additions & 2 deletions torchrecurrent/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from __future__ import annotations

import warnings
from typing import Dict, Optional, Tuple, List, Any

import torch
Expand Down Expand Up @@ -236,9 +235,10 @@ def reset_parameters(self) -> None:
apply_init_(p, self.init_cfg["recurrent_bias"])

def _cleanup_non_scriptable(self) -> None:
# init_cfg is kept: reset_parameters() must remain callable after
# construction, and a Dict[str, str] is TorchScript-compatible.
del self._init_device
del self._init_dtype
del self.init_cfg


class SingleStateCellBase(RecurrentCellBase):
Expand Down
3 changes: 3 additions & 0 deletions torchrecurrent/cells/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .br_cell import BR, BRCell, NBR, NBRCell
from .cfn_cell import CFN, CFNCell
from .mgu_cell import MGU, MGUCell
from .minimalrnn_cell import MinimalRNN, MinimalRNNCell
from .miru_cell import MiRU1, MiRU1Cell, MiRU2, MiRU2Cell
from .cornn_cell import coRNN, coRNNCell
from .fastrnn_cell import FastRNN, FastRNNCell, FastGRNN, FastGRNNCell
Expand Down Expand Up @@ -52,6 +53,8 @@
"CFNCell",
"MGU",
"MGUCell",
"MinimalRNN",
"MinimalRNNCell",
"MiRU1",
"MiRU1Cell",
"MiRU2",
Expand Down
Loading
Loading