2023-12-05 12:10:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								MLX
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								===
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-05 14:18:20 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								MLX is a NumPy-like array framework designed for efficient and flexible machine
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								learning on Apple silicon, brought to you by Apple machine learning research.
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-05 12:10:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								The Python API closely follows NumPy with a few exceptions. MLX also has a
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fully featured C++ API which closely follows the Python API.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								The main differences between MLX and NumPy are:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 - **Composable function transformations**: MLX has composable function
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   transformations for automatic differentiation, automatic vectorization,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   and computation graph optimization.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 - **Lazy computation**: Computations in MLX are lazy. Arrays are only
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   materialized when needed.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 - **Multi-device**: Operations can run on any of the supported devices (CPU,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   GPU, ...)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-05 14:18:20 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								The design of MLX is inspired by frameworks like `PyTorch
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-05 12:10:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								<https://pytorch.org/>`_, `Jax <https://github.com/google/jax>`_, and
							 | 
						
					
						
							
								
									
										
										
										
											2024-01-03 20:14:05 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								`ArrayFire <https://arrayfire.org/>`_. A notable difference from these
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-05 12:10:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								frameworks and MLX is the *unified memory model*. Arrays in MLX live in shared
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								memory. Operations on MLX arrays can be performed on any of the supported
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								device types without performing data copies. Currently supported device types
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								are the CPU and GPU.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								.. toctree::
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   :caption: Install
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   :maxdepth: 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   install
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								.. toctree::
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   :caption: Usage 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   :maxdepth: 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-01-06 05:41:48 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   usage/quick_start
							 | 
						
					
						
							
								
									
										
										
										
											2024-01-10 14:14:38 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   usage/lazy_evaluation
							 | 
						
					
						
							
								
									
										
										
										
											2024-01-06 05:41:48 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   usage/unified_memory
							 | 
						
					
						
							
								
									
										
										
										
											2024-01-10 14:14:38 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   usage/indexing
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   usage/saving_and_loading
							 | 
						
					
						
							
								
									
										
										
										
											2024-01-17 17:15:29 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   usage/function_transforms
							 | 
						
					
						
							
								
									
										
										
										
											2024-02-08 12:44:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   usage/compile
							 | 
						
					
						
							
								
									
										
										
										
											2024-01-06 05:41:48 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   usage/numpy
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-06 20:28:06 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   usage/distributed
							 | 
						
					
						
							
								
									
										
										
										
											2024-01-10 14:14:38 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   usage/using_streams
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-05 12:10:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								.. toctree::
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   :caption: Examples
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   :maxdepth: 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   examples/linear_regression
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   examples/mlp
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   examples/llama-inference
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								.. toctree::
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   :caption: Python API Reference
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   :maxdepth: 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   python/array
							 | 
						
					
						
							
								
									
										
										
										
											2024-03-30 17:32:20 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   python/data_types
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-05 12:10:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   python/devices_and_streams
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   python/ops
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   python/random
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   python/transforms
							 | 
						
					
						
							
								
									
										
										
										
											2024-03-30 17:32:20 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   python/fast
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-05 12:10:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   python/fft
							 | 
						
					
						
							
								
									
										
										
										
											2024-01-03 20:14:05 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   python/linalg
							 | 
						
					
						
							
								
									
										
										
										
											2024-03-14 12:46:45 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   python/metal
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-05 12:10:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   python/nn
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   python/optimizers
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-06 20:28:06 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   python/distributed
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-05 12:10:03 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   python/tree_utils
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								.. toctree::
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   :caption: C++ API Reference
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   :maxdepth: 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   cpp/ops
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								.. toctree::
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   :caption: Further Reading
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   :maxdepth: 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								   dev/extensions
							 | 
						
					
						
							
								
									
										
										
										
											2024-03-30 17:32:20 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   dev/metal_debugger
							 | 
						
					
						
							
								
									
										
										
										
											2024-08-23 12:14:53 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								   dev/custom_metal_kernels
							 |