Tree Utils
@@ -845,6 +862,8 @@ document.write(`
@@ -1010,7 +1031,7 @@ document.write(`
L
log2() (in module mlx.core)
- log_cosh_loss (class in mlx.nn.losses)
+ log_cosh_loss() (in module mlx.nn.losses)
logaddexp() (in module mlx.core)
@@ -1070,6 +1091,8 @@ document.write(`
M
- Optimizer (class in mlx.optimizers)
-
- OptimizerState (class in mlx.optimizers)
+ Optimizer (class in mlx.optimizers)
outer() (in module mlx.core)
@@ -1172,7 +1193,7 @@ document.write(`
ReLU (class in mlx.nn)
- relu (class in mlx.nn)
+ relu() (in module mlx.nn)
repeat() (in module mlx.core)
@@ -1270,7 +1291,7 @@ document.write(`
SELU (class in mlx.nn)
- selu (class in mlx.nn)
+ selu() (in module mlx.nn)
Sequential (class in mlx.nn)
@@ -1288,7 +1309,7 @@ document.write(`
SiLU (class in mlx.nn)
- silu (class in mlx.nn)
+ silu() (in module mlx.nn)
sin() (in module mlx.core)
@@ -1304,13 +1325,13 @@ document.write(`
diff --git a/docs/build/html/index.html b/docs/build/html/index.html
index 37d464707..23e7376ee 100644
--- a/docs/build/html/index.html
+++ b/docs/build/html/index.html
@@ -9,7 +9,7 @@
- MLX — MLX 0.1.0 documentation
+ MLX — MLX 0.2.0 documentation
@@ -133,8 +133,8 @@
-
-
+
+
@@ -152,6 +152,7 @@
Indexing Arrays
Saving and Loading Arrays
Function Transforms
+Compilation
Conversion to NumPy and Other Frameworks
Using Streams
@@ -347,6 +348,9 @@
Transforms
shape
-The shape of the array as a Python list.
+The shape of the array as a Python tuple.
size
Number of elements in the array.
diff --git a/docs/build/html/python/_autosummary/mlx.core.array.item.html b/docs/build/html/python/_autosummary/mlx.core.array.item.html
index 8b8b258e8..f724ba20b 100644
--- a/docs/build/html/python/_autosummary/mlx.core.array.item.html
+++ b/docs/build/html/python/_autosummary/mlx.core.array.item.html
@@ -9,7 +9,7 @@
- mlx.core.array.item — MLX 0.1.0 documentation
+ mlx.core.array.item — MLX 0.2.0 documentation
@@ -134,8 +134,8 @@
-
-
+
+
@@ -153,6 +153,7 @@
Indexing Arrays
Saving and Loading Arrays
Function Transforms
+Compilation
Conversion to NumPy and Other Frameworks
Using Streams
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
mlx.utils.tree_flatten
mlx.utils.tree_unflatten
mlx.utils.tree_map
diff --git a/docs/build/html/python/_autosummary/mlx.core.compile.html b/docs/build/html/python/_autosummary/mlx.core.compile.html
new file mode 100644
index 000000000..13a02bb33
--- /dev/null
+++ b/docs/build/html/python/_autosummary/mlx.core.compile.html
@@ -0,0 +1,798 @@
+
+
+
+
+
+
+
+
+
+
+
+ mlx.core.compile — MLX 0.2.0 documentation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Skip to main content
+
+
+
+
+
+
+ Back to top
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+mlx.core.compile
+
+
+mlx.core. compile ( fun : function ) → function
+Returns a compiled function which produces the same output as fun
.
+
+Parameters:
+
+fun (function ) – A function which takes a variable number of
+array
or trees of array
and returns
+a variable number of array
or trees of array
.
+inputs (list or dict , optional ) – These inputs will be captured during
+the function compilation along with the inputs to fun
. The inputs
+can be a list
or a dict
containing arbitrarily nested
+lists, dictionaries, or arrays. Leaf nodes that are not
+array
are ignored. Default: None
+outputs (list or dict , optional ) – These outputs will be captured and
+updated in a compiled function. The outputs
can be a
+list
or a dict
containing arbitrarily nested lists,
+dictionaries, or arrays. Leaf nodes that are not array
are ignored.
+Default: None
+
+
+Returns:
+A compiled function which has the same input arguments
+as fun
and returns the the same output(s).
+
+Return type:
+function
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/build/html/python/_autosummary/mlx.core.concatenate.html b/docs/build/html/python/_autosummary/mlx.core.concatenate.html
index 23e674d6a..7e8cb9668 100644
--- a/docs/build/html/python/_autosummary/mlx.core.concatenate.html
+++ b/docs/build/html/python/_autosummary/mlx.core.concatenate.html
@@ -9,7 +9,7 @@
- mlx.core.concatenate — MLX 0.1.0 documentation
+ mlx.core.concatenate — MLX 0.2.0 documentation
@@ -134,8 +134,8 @@
-
-
+
+
@@ -153,6 +153,7 @@
Indexing Arrays
Saving and Loading Arrays
Function Transforms
+Compilation
Conversion to NumPy and Other Frameworks
Using Streams
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -348,6 +349,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -379,6 +383,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -349,6 +350,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -380,6 +384,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+Tree Utils
@@ -349,6 +350,9 @@
Transforms
mlx.core.eval
+mlx.core.compile
+mlx.core.disable_compile
+mlx.core.enable_compile
mlx.core.grad
mlx.core.value_and_grad
mlx.core.jvp
@@ -380,6 +384,7 @@
mlx.nn.value_and_grad
Module
Optimizers
-Tree Utils
+
+Optimizers
+Optimizer
-Optimizers
-Tree Utils
+Tree Utils
mlx.utils.tree_flatten
mlx.utils.tree_unflatten
mlx.utils.tree_map
@@ -550,7 +578,7 @@
-
- mlx.core.simplify
+ mlx.core.disable_compile
@@ -646,40 +674,13 @@ document.write(`
-
-mlx.core.simplify
+
+mlx.core.disable_compile
-
-mlx.core. simplify ( * args ) → None
-Simplify the graph that computes the arrays.
-Run a few fast graph simplification operations to reuse computation and
-reduce memory consumption. This function is meant to be run every time
-so its overhead should be small, approximately 1ms for a graph with a
-few thousand nodes.
-import mlx.core as mx
-
-def foo ( x ):
- y = x @ x
- z = x @ x
- return y + z
-
-x = mx . ones (( 10 , 10 ))
-y = foo ( x )
-z = foo ( x )
-
-# Computes the matmul twice
-mx . eval ( y )
-
-# Computes the matmul once
-mx . simplify ( z )
-mx . eval ( z )
-
-
-
-Parameters:
-args – Any number of arrays and/or trees of arrays to be simplified.
-
-
+
+mlx.core. disable_compile ( ) → None
+Globally disable compilation. Setting the environment variable
+MLX_DISABLE_COMPILE
can also be used to disable compilation.
@@ -696,20 +697,20 @@ few thousand nodes.
previous
-
mlx.core.vmap
+
mlx.core.compile
next
-
FFT
+
mlx.core.enable_compile
diff --git a/docs/build/html/python/_autosummary/mlx.core.divide.html b/docs/build/html/python/_autosummary/mlx.core.divide.html
index b9d02c2dc..542665d91 100644
--- a/docs/build/html/python/_autosummary/mlx.core.divide.html
+++ b/docs/build/html/python/_autosummary/mlx.core.divide.html
@@ -9,7 +9,7 @@
-
mlx.core.divide — MLX 0.1.0 documentation
+
mlx.core.divide — MLX 0.2.0 documentation
@@ -134,8 +134,8 @@
-
-
+
+
@@ -153,6 +153,7 @@
Indexing Arrays
Saving and Loading Arrays
Function Transforms
+Compilation
Conversion to NumPy and Other Frameworks
Using Streams
@@ -348,6 +349,9 @@
Transforms
@@ -153,6 +153,7 @@
Indexing Arrays
Saving and Loading Arrays
Function Transforms
+
Compilation
Conversion to NumPy and Other Frameworks
Using Streams
@@ -348,6 +349,9 @@
Transforms
@@ -153,6 +153,7 @@
Indexing Arrays
Saving and Loading Arrays
Function Transforms
+Compilation
Conversion to NumPy and Other Frameworks
Using Streams
@@ -346,8 +347,11 @@
mlx.core.random.uniform
-Transforms
+Transforms
-Optimizers
-mlx.optimizers.OptimizerState
-mlx.optimizers.Optimizer
+Optimizers
-Tree Utils
+Tree Utils
mlx.utils.tree_flatten
mlx.utils.tree_unflatten
mlx.utils.tree_map
@@ -567,7 +578,7 @@
-
- mlx.optimizers.Optimizer
+ mlx.core.enable_compile
@@ -663,41 +674,13 @@ document.write(`
-
-mlx.optimizers.Optimizer
-
-
-class mlx.optimizers. Optimizer
-The base class for all optimizers. It allows us to implement an
-optimizer on a per-parameter basis and apply it to a parameter tree.
-
-
-state
-It holds the optimizer’s state dictionary.
-
-Type:
-OptimizerState
-
-
-
-
-Methods
-
-
-__init__
()
-
-
-apply_gradients
(gradients, model)
-Apply the gradients to the parameters and return the updated parameters.
-
-apply_single
(gradient, parameter, state)
-To be extended by the children classes to implement each optimizer's update.
-
-update
(model, gradients)
-Apply the gradients to the parameters of the model and update the model with the new parameters.
-
-
-
+
+mlx.core.enable_compile
+
+
+mlx.core. enable_compile ( ) → None
+Globally enable compilation. This will override the environment
+variable MLX_DISABLE_COMPILE
if set.
@@ -714,20 +697,20 @@ optimizer on a per-parameter basis and apply it to a parameter tree.
@@ -153,6 +153,7 @@
Indexing Arrays
Saving and Loading Arrays
Function Transforms
+Compilation
Conversion to NumPy and Other Frameworks
Using Streams
@@ -348,6 +349,9 @@
Transforms
@@ -154,6 +154,7 @@
Indexing Arrays
Saving and Loading Arrays
Function Transforms
+
Compilation
Conversion to NumPy and Other Frameworks
Using Streams
@@ -349,6 +350,9 @@
Transforms
@@ -153,6 +153,7 @@
Indexing Arrays
Saving and Loading Arrays
Function Transforms
+Compilation
Conversion to NumPy and Other Frameworks
Using Streams
@@ -348,6 +349,9 @@
Transforms