quick intro to python jax for numpy users
- User
quick intro to python jax for numpy users
Assistant
Here is a quick introduction to JAX for users familiar with NumPy:
-
JAX is a library for automatic differentiation and vectorization that works on CPU and GPU. It is built on top of NumPy and allows for GPU/TPU execution of NumPy-like code.
-
JAX arrays (jnp.ndarray) behave very similarly to NumPy arrays but can execute operations on GPU/TPU. All the usual NumPy operations like +, -, *, etc. work on JAX arrays.
-
To execute code on GPU, use the jax.device_put() function to move arrays to GPU memory:
import jax.numpy as jnp import jax x = jnp.array([1,2,3]) # JAX array x_gpu = jax.device_put(x) # Move to GPU
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.