Skip to content

Commit 5762a66

Browse files
committed
remove the remove compile time step as run times are very similar
1 parent f7aab80 commit 5762a66

1 file changed

Lines changed: 1 addition & 17 deletions

File tree

lectures/jax_intro.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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
88
kernelspec:
99
display_name: Python 3 (ipykernel)
1010
language: python
@@ -92,7 +92,6 @@ Even scalar-valued maps on arrays return JAX arrays.
9292
jnp.sum(a)
9393
```
9494

95-
9695
Operations 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.
186185
However, JAX provides a functionally pure equivalent of in-place array modification
187186
using the [`at` method](https://docs.jax.dev/en/latest/_autosummary/jax.numpy.ndarray.at.html).
188187

189-
190188
```{code-cell} ipython3
191189
a = jnp.linspace(0, 1, 3)
192190
id(a)
@@ -608,13 +606,6 @@ x_mesh, y_mesh = jnp.meshgrid(x, y)
608606
z_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-
618609
But 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
654645
z_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-
664648
The execution time is essentially the same as the mesh operation but we are using much less memory.
665649

666650
And we produce the correct answer:

0 commit comments

Comments
 (0)