Skip to content

Commit

Permalink
fix seq_length in rnn, added test for rnn
Browse files Browse the repository at this point in the history
  • Loading branch information
zinccat committed Oct 8, 2024
1 parent 8cd87ee commit d94b5a3
Show file tree
Hide file tree
Showing 2 changed files with 358 additions and 47 deletions.
18 changes: 17 additions & 1 deletion flax/nnx/nn/recurrent.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2024 The Flax Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""RNN modules for Flax."""

from typing import (
Any,
TypeVar,
Expand Down Expand Up @@ -665,7 +681,7 @@ def scan_fn(carry: Carry, x: Array) -> tuple[Carry, Array]:
scan = nnx.scan(
scan_fn,
in_axes=(Carry, time_axis),
out_axes=(Carry, (Carry, time_axis)) if slice_carry else (Carry, time_axis),
out_axes=(Carry, (0, time_axis)) if slice_carry else (Carry, time_axis),
unroll=self.unroll,
)

Expand Down
Loading

0 comments on commit d94b5a3

Please sign in to comment.