Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Swift API for MLX

License

NotificationsYou must be signed in to change notification settings

ml-explore/mlx-swift

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.

Examples

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.

Installation

TheMLX Swift package can be built and run from Xcode or SwiftPM. A CMake install is also provided.

More details are in thedocumentation.

Xcode

In Xcode you can addhttps://github.com/ml-explore/mlx-swift as a packagedependency and linkMLX,MLXNN,MLXOptimizers andMLXRandom as needed.

SwiftPM

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.

xcodebuild

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'

CMake

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

Contributing

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.

Versions

TheMLX array functions should match MLX as of tagv0.3.0. TheMLXNNpackage should match MLX (mlx.nn) as of tagv0.0.10.


[8]ページ先頭

©2009-2025 Movatter.jp