Published blog post: MAX Graph API Tutorials
Versions used in this blog
max 24.3.0 (9882e19d)
Modular version 24.3.0-9882e19d-release
-
Install the MAX SDK.
-
git clone this repo and
python3 -m venv venv && source venv/bin/activate
python3 -m pip install --find-links "$(modular config max.path)/wheels" max-engine
python3 -m pip install -r requirements.txt
- Run the code such as
mojo add.mojo
andmojo matmul.mojo
. For mnist, first need to train the model withpython mnist.py
(uses relu) orpython mnist.py --use-relu6
to train with relu6. Then for inference and checking test accuracy matches the PyTorch version, runmojo mnist.mojo
(uses relu) or for relu6 custom op (needspython mnist.py --use-relu6
to train with relu6), ensure to runmojo package custom_ops
and follow withmojo mnist.mojo --use-relu6
.
Note: mojo build mnist.mojo
builds the mnist
binary, make sure to set MOJO_PYTHON_LIBRARY
via
export MOJO_PYTHON_LIBRARY=$(modular config mojo-max.python_lib)
prior to executing the binary ./mnist
- If you encounter any issues, please make sure to check out the roadmap and known issues first