Refactor code examples to use 'gelu' (#2592)

Updated code examples to use 'gelu' directly instead of 'nn.gelu'.
This commit is contained in:
Umberto Mignozzetti
2025-09-15 09:47:02 -07:00
committed by GitHub
parent ee18e1cbf0
commit 36cad99a11

View File

@@ -130,8 +130,8 @@ Now make an array, and benchmark both functions:
.. code-block:: python .. code-block:: python
x = mx.random.uniform(shape=(32, 1000, 4096)) x = mx.random.uniform(shape=(32, 1000, 4096))
timeit(nn.gelu, x) timeit(gelu, x)
timeit(mx.compile(nn.gelu), x) timeit(mx.compile(gelu), x)
On an M1 Max the times are 15.5 and 3.1 milliseconds. The compiled ``gelu`` is On an M1 Max the times are 15.5 and 3.1 milliseconds. The compiled ``gelu`` is
five times faster. five times faster.