Destructing DeviceArray produces Numpy arrays
See original GitHub issueDon’t know if this is a new feature or a bug. Destructing a DeviceArray is resulting in its pieces being converted to Numpy arrays:
import jax
import jax.numpy as jnp
key = jax.random.PRNGKey(0)
key1, key2 = jax.random.split(key)
assert not isintance(key1, jnp.ndarray)
assert not isintance(key2, jnp.ndarray)
This is surprising given this pattern with split
is used extensively in the docs. Now it seems you have to do this:
key = jax.random.PRNGKey(0)
splits = jax.random.split(key)
key1, key2 = splits[0], splits[1]
assert isintance(key1, jnp.ndarray)
assert isintance(key2, jnp.ndarray)
Which is less nice.
Versions:
name = "jax"
version = "0.2.21"
name = "jaxlib"
version = "0.1.71"
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
List comprehensions and for-loops on xla.DeviceArrays return ...
Looping through a DeviceArray like in a list comprehension, for loop, or enumerate ... Destructing DeviceArray produces Numpy arrays #8017.
Read more >jax.numpy package - JAX documentation - Read the Docs
Gives a new shape to an array without changing its data. resize (a, new_shape). Return a new array with the specified shape.
Read more >Is there any way to delete the specific elements of an numpy ...
NumPy arrays are fixed-size, so there can't be an in-place version of np.delete . Any such function would have to change the array's...
Read more >TF_JAX_tutorials - Part 4 (JAX and DeviceArray) | Kaggle
We will create two arrays, one with numpy and other with jax # to check ... dive into DeviceArray and see what makes...
Read more >[SciPy-User] Memory Leak? Problems with deleting numpy ...
I am having some difficulty with memory management with numpy arrays. I have some c-code which creates a numpy array which is fairly...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah, the issue is much larger than
split
, unfortunately. We really need to get #3821 or something like it in, but it has been challenging for various reasons.Alternatively, you can also replace
jax.random.split
with this: