@@ -4,7 +4,7 @@ jupytext:
44 extension : .md
55 format_name : myst
66 format_version : 0.13
7- jupytext_version : 1.16.1
7+ jupytext_version : 1.17.2
88kernelspec :
99 display_name : Python 3 (ipykernel)
1010 language : python
@@ -92,7 +92,6 @@ Even scalar-valued maps on arrays return JAX arrays.
9292jnp.sum(a)
9393```
9494
95-
9695Operations on higher dimensional arrays are also similar to NumPy:
9796
9897``` {code-cell} ipython3
@@ -186,7 +185,6 @@ functional programming style. More on this below.
186185However, JAX provides a functionally pure equivalent of in-place array modification
187186using the [ ` at ` method] ( https://docs.jax.dev/en/latest/_autosummary/jax.numpy.ndarray.at.html ) .
188187
189-
190188``` {code-cell} ipython3
191189a = jnp.linspace(0, 1, 3)
192190id(a)
@@ -608,13 +606,6 @@ x_mesh, y_mesh = jnp.meshgrid(x, y)
608606z_mesh = f(x_mesh, y_mesh).block_until_ready()
609607```
610608
611- Let's run again to get rid of compile time.
612-
613- ``` {code-cell} ipython3
614- %%time
615- z_mesh = f(x_mesh, y_mesh).block_until_ready()
616- ```
617-
618609But there is one problem here: the mesh grids use a lot of memory.
619610
620611``` {code-cell} ipython3
@@ -654,13 +645,6 @@ With this construction, we can now call the function $f$ on flat (low memory) ar
654645z_vmap = f_vec(x, y).block_until_ready()
655646```
656647
657- We run it again to eliminate compile time.
658-
659- ``` {code-cell} ipython3
660- %%time
661- z_vmap = f_vec(x, y).block_until_ready()
662- ```
663-
664648The execution time is essentially the same as the mesh operation but we are using much less memory.
665649
666650And we produce the correct answer:
0 commit comments