Created
July 11, 2022 11:31
-
-
Save mwitiderrick/d9822afd27293b1da25602f06a09cf87 to your computer and use it in GitHub Desktop.
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
mat = jax.random.normal(key, (150, 100)) | |
batched_x = jax.random.normal(key, (10, 100)) | |
def apply_matrix(v): | |
return jnp.dot(mat, v) | |
@jax.jit | |
def vmap_batched_apply_matrix(v_batched): | |
return jax.vmap(apply_matrix)(v_batched) | |
print('Auto-vectorized with vmap') | |
%timeit vmap_batched_apply_matrix(batched_x).block_until_ready() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment