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

[JAX] Replace uses of jax.devices("cpu") with jax.local_devices(backend="cpu"). #317

Merged
merged 1 commit into from
Nov 17, 2023
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 chex/_src/asserts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ def test_assert_tree_has_only_ndarrays(self):
asserts.assert_tree_has_only_ndarrays({'a': jnp.zeros(101), 'b': [1, 2]})

def test_assert_tree_is_on_host(self):
cpu = jax.devices('cpu')[0]
cpu = jax.local_devices(backend='cpu')[0]

# Check Numpy arrays.
for flag in (False, True):
Expand Down Expand Up @@ -1173,7 +1173,7 @@ def test_assert_tree_is_on_host(self):

def test_assert_tree_is_on_device(self):
# Check CPU platform.
cpu = jax.devices('cpu')[0]
cpu = jax.local_devices(backend='cpu')[0]
to_cpu = lambda x: jax.device_put(x, cpu)

cpu_tree = {'a': to_cpu(np.zeros(1)), 'b': to_cpu(np.ones(3))}
Expand Down Expand Up @@ -1262,7 +1262,7 @@ def _format(*devs):
return re.escape(f'{devs}')

# Check single-device case.
cpu = jax.devices('cpu')[0]
cpu = jax.local_devices(backend='cpu')[0]
cpu_tree = jax.device_put_replicated(np_tree, (cpu,))

asserts.assert_tree_is_sharded(cpu_tree, devices=(cpu,))
Expand Down
Loading