Skip to content

Commit

Permalink
JAX and reordering
Browse files Browse the repository at this point in the history
  • Loading branch information
ker2x committed Feb 6, 2024
1 parent 1179c5a commit 219bdbe
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Writerside/d.tree
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
</toc-element>
<toc-element topic="Web-Enshitification.md"/>
<toc-element topic="On-using-AI-to-write-about-writing.md"/>
<toc-element topic="Sudo-must-die.md"/>
<toc-element topic="LLM-on-SSD.md"/>
<toc-element topic="tinyFramebuffer.md"/>
<toc-element topic="is-JAX-cool.md"/>
<toc-element topic="Reverse-Engineering.md">
<toc-element topic="SOMe-unnamed-software.md"/>
<toc-element topic="IsProcessorFeaturePresent.md"/>
<toc-element topic="Fastfail-Codes.md"/>
</toc-element>
<toc-element topic="Sudo-must-die.md"/>
<toc-element topic="LLM-on-SSD.md"/>
<toc-element topic="tinyFramebuffer.md"/>
<toc-element topic="Fortran.md">
<toc-element topic="Fortran-QuickWin.md"/>
</toc-element>
Expand Down
Binary file added Writerside/images/squareFFT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions Writerside/topics/is-JAX-cool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# is JAX cool ?

Python is slow, and don't get me started on how it "call C".
Even numpy is slow (except for slow computations, then it's relatively fast).

Is JAX cool ? Does it "make Python fast" ?
Perhaps.

It can be a straight-up replacement for numpy, but faster (on GPU, TPU, or CPU fallback).

## Testing stuff

```Python

import jax.numpy as jnp
from jax import grad, jit, vmap
from jax import random
import matplotlib.pyplot as plt

%matplotlib inline

x = jnp.arange(0,2*jnp.pi,0.1) # start,stop,step

for j in range(20):
y = 0
for i in range(1,j,2):
y += jnp.sin(x*i)/i
plt.plot(x,y)
plt.show()

```

To be honest, it's not a good benchmark to compare with numpy.
I'm just putting it here because i always forget how to make square waves from sin (Fourier series).

But it look like numpy, so it's cool.

![squareFFT.png](squareFFT.png)

There is probably a more JNX-ish wat to do it, but how ? Ask Copilot chat ?

Copilot is still using loops. Perhaps it's how it's done in JAX.

I'll need to try some other examples. Perhaps Fractals, or Fractals.

## Hello mandelbrot

0 comments on commit 219bdbe

Please sign in to comment.