Skip to content

RNNCell, LSTMCell and GRUCell are implemented as mutable structs, but never do mutation #1089

@AzamatB

Description

@AzamatB

It seems like RNNCell, LSTMCell and GRUCell that are defined as mutable structs in src/layers/recurrent.jl never actually use any mutation in the forward pass. Instead, it looks like state mutation is handled in the Recur struct, which copies over the hidden state of its cell during construction and then never reads or writes the cell's hidden state onwards.

Given this, what is the reason these recurrent cells are defined as mutable structs?
Should we change them to be immutable to reap the performance benefits that come with this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions