mlx/examples/export
Awni Hannun c9d30aa6ac
MLX in C++ example (#1736)
* MLX in C++ example

* nits

* fix docs
2025-01-02 19:09:04 -08:00
..
CMakeLists.txt MLX in C++ example (#1736) 2025-01-02 19:09:04 -08:00
eval_mlp.cpp MLX in C++ example (#1736) 2025-01-02 19:09:04 -08:00
eval_mlp.py Export / import functions to / from a file (#1642) 2024-12-24 11:19:13 -08:00
README.md Export / import functions to / from a file (#1642) 2024-12-24 11:19:13 -08:00
train_mlp.cpp MLX in C++ example (#1736) 2025-01-02 19:09:04 -08:00
train_mlp.py Export / import functions to / from a file (#1642) 2024-12-24 11:19:13 -08:00

Setup

Install MLX:

pip install mlx>=0.22

Build the C++ examples:

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build

Run

Eval MLP

Run the Python script to export the eval function:

python eval_mlp.py

Then run the C++ program to import and run the function:

./build/eval_mlp

The Python and C++ programs should output the same result.

Train MLP

Run the Python script to export the model initialization and training functions:

python train_mlp.py

Then run the C++ program to import and run the functions:

./build/train_mlp

The Python and C++ programs should output the same results.