Skip to content

Commit f7bdbb3

Browse files
committed
revert global change, only change the affected lines
1 parent 38889cb commit f7bdbb3

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lectures/jax_intro.md

Lines changed: 11 additions & 4 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.16.6
88
kernelspec:
99
display_name: Python 3 (ipykernel)
1010
language: python
@@ -348,7 +348,15 @@ The compiled versions for the previous array size are still available in memory
348348
too, and the following call is dispatched to the correct compiled code.
349349

350350
```{code-cell} ipython3
351-
%time f(x).block_until_ready()
351+
%timeit f(x).block_until_ready()
352+
```
353+
354+
```{note}
355+
Note that we use the [`%timeit` magic](https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-timeit)
356+
here to get more reliable timing statistics.
357+
358+
It runs the code multiple times to calculate both mean and standard deviation,
359+
which takes longer but provides more accurate measurements than a single run.
352360
```
353361

354362
### Compiling the outer function
@@ -368,14 +376,13 @@ f_jit(x)
368376
And now let's time it.
369377

370378
```{code-cell} ipython3
371-
%time f_jit(x).block_until_ready()
379+
%timeit f_jit(x).block_until_ready()
372380
```
373381

374382
Note the speed gain.
375383

376384
This is because the array operations are fused and no intermediate arrays are created.
377385

378-
379386
Incidentally, a more common syntax when targetting a function for the JIT
380387
compiler is
381388

0 commit comments

Comments
 (0)