Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid scalar conversion of non-scalar arrays #693

Merged
merged 1 commit into from
Jan 12, 2024
Merged
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
6 changes: 3 additions & 3 deletions optax/_src/wrappers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,18 @@ def fn_update(params, opt_state, x):
for step in range(2):
params, opt_state = fn_update(params, opt_state, two)
self.assertFalse(bool(opt_state.last_finite))
self.assertEqual(step + 1, int(opt_state.notfinite_count))
self.assertEqual(step + 1, opt_state.notfinite_count.item())
# Next successful param update
params, opt_state = fn_update(params, opt_state, half)
self.assertTrue(bool(opt_state.last_finite))
# Again 2 rejected param updates
for step in range(2):
params, opt_state = fn_update(params, opt_state, two)
self.assertFalse(bool(opt_state.last_finite))
self.assertEqual(step + 1, int(opt_state.notfinite_count))
self.assertEqual(step + 1, opt_state.notfinite_count.item())
# Next param update with NaN is accepted since we reached maximum
_, opt_state = fn_update(params, opt_state, two)
self.assertEqual(5, int(opt_state.total_notfinite))
self.assertEqual(5, opt_state.total_notfinite.item())

@chex.variants(with_jit=True, without_jit=True, with_pmap=True)
def test_multi_steps(self):
Expand Down
Loading