- Notifications
You must be signed in to change notification settings - Fork80
ml-explore/mlx-swift
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Installation |Documentation |Examples
MLX Swift is a Swift API forMLX.
MLX is an array framework for machine learning on Apple silicon. MLX Swiftexpands MLX to the Swift language, making research and experimentation easieron Apple silicon.
MLX Swift has afewexamples,including:
- Large-scale text generation with Mistral 7B
- Training a simple LeNet on MNIST
- Examples that run on macOS or iOS
TheMLX Swift Examples repocontains the complete code and documentation for these examples.
TheMLX
Swift package can be built and run from Xcode or SwiftPM. A CMake install is also provided.
More details are in thedocumentation.
In Xcode you can addhttps://github.com/ml-explore/mlx-swift
as a packagedependency and linkMLX
,MLXNN
,MLXOptimizers
andMLXRandom
as needed.
To useMLX
with SwiftPM you can add this to yourPackage.swift
:
dependencies:[.package(url:"https://github.com/ml-explore/mlx-swift", from:"0.10.0")]
and add the libraries as dependencies:
dependencies:[.product(name:"MLX",package:"mlx-swift"),.product(name:"MLXRandom",package:"mlx-swift"),.product(name:"MLXNN",package:"mlx-swift"),.product(name:"MLXOptimizers",package:"mlx-swift"),.product(name:"MLXFFT",package:"mlx-swift")]
Note
SwiftPM (command line) cannot build the Metal shaders so the ultimate build has to be donevia Xcode.
AlthoughSwiftPM
(command line) cannot build the Metal shaders,xcodebuild
can andit can be used to do command line builds:
# build and run testsxcodebuild test -scheme mlx-swift-Package -destination 'platform=OS X'# build Tutorialxcodebuild build -scheme Tutorial -destination 'platform=OS X'
Building with CMake requires both CMake and Ninja to be installed. You can dothis withHomebrew:
brew install cmakebrew install ninja
With CMake:
mkdir buildcd buildcmake .. -G Ninjaninja./example
Check out thecontribution guidelines for more informationon contributing to MLX. See thedocs for moreinformation on building from source, and running tests.
We are grateful for all ofourcontributors. If you contributeto MLX Swift and wish to be acknowledged, please add your name to the list in yourpull request.
MLX Swift was initially developed by David Koski and Ronan Collobert, and isnow maintained by David Koski. MLX Swift is built on top ofMLX, which was initially developed withequal contribution by Awni Hannun, Jagrit Digani, Angelos Katharopoulos, andRonan Collobert.
TheMLX
array functions should match MLX as of tagv0.3.0. TheMLXNN
package should match MLX (mlx.nn
) as of tagv0.0.10.
About
Swift API for MLX