Giter Club home page Giter Club logo

mlx-swift's Introduction

MLX Swift

Installation | Documentation | Examples

MLX Swift is a Swift API for MLX.

MLX is an array framework for machine learning research on Apple silicon. MLX Swift expands MLX to the Swift language, making research and experimentation easier on Apple silicon. MLX is intended for research and not for production deployment of models in apps.

Examples

MLX Swift has a few examples, including:

  • Large-scale text generation with Mistral 7B
  • Training a simple LeNet on MNIST
  • Examples that run on macOS or iOS

The MLX Swift Examples repo contains the complete code and documentation for these examples.

Installation

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

More details are in the documentation.

Xcode

In Xcode you can add https://github.com/ml-explore/mlx-swift as a package dependency and link MLX, MLXNN, MLXOptimizers and MLXRandom as needed.

SwiftPM

To use MLX with SwiftPM you can add this to your Package.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 done via Xcode.

xcodebuild

Although SwiftPM (command line) cannot build the Metal shaders, xcodebuild can and it can be used to do command line builds:

# build and run tests
xcodebuild test -scheme mlx-swift-Package -destination 'platform=OS X'

# build Tutorial
xcodebuild build -scheme Tutorial -destination 'platform=OS X'

CMake

Building with CMake requires both CMake and Ninja to be installed. You can do this with Homebrew:

brew install cmake
brew install ninja

With CMake:

mkdir build
cd build
cmake .. -G Ninja
ninja
./example

Contributing

Check out the contribution guidelines for more information on contributing to MLX. See the docs for more information on building from source, and running tests.

We are grateful for all of our contributors. If you contribute to MLX Swift and wish to be acknowledged, please add your name to the list in your pull request.

MLX Swift was initially developed by David Koski and Ronan Collobert, and is now maintained by David Koski. MLX Swift is built on top of MLX, which was initially developed with equal contribution by Awni Hannun, Jagrit Digani, Angelos Katharopoulos, and Ronan Collobert.

Versions

The MLX array functions should match MLX as of tag v0.3.0. The MLXNN package should match MLX (mlx.nn) as of tag v0.0.10.

mlx-swift's People

Contributors

davidkoski avatar awni avatar andresy avatar rounak avatar kyle-ye avatar adhulipa avatar angeloskath avatar florentmorin avatar krzyzanowskim avatar nheagy avatar noahsmartin avatar ronaldmannak avatar finestructure avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.