-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG:
.device
attribute inside jax.jit
- Loading branch information
1 parent
8a79994
commit 2aeb387
Showing
4 changed files
with
42 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import jax | ||
import jax.numpy as jnp | ||
from numpy.testing import assert_equal | ||
|
||
from array_api_compat import device, to_device | ||
|
||
|
||
def test_device_jit(): | ||
# Test work around to https://github.com/jax-ml/jax/issues/26000 | ||
@jax.jit | ||
def f(x): | ||
return jnp.zeros(1, device=device(x)) | ||
|
||
@jax.jit | ||
def g(x): | ||
return to_device(jnp.zeros(1), device(x)) | ||
|
||
x = jnp.ones(1) | ||
assert_equal(f(x), jnp.asarray(0)) | ||
assert_equal(g(x), jnp.asarray(0)) |