Run build.sh
in this project to
- build the IREE compiler, runtime, and Python binding for macOS, and
- build the IREE runtime into an XCFramework bundle that supports macOS, iOS, and iOS simulator.
Do not run cmake with the CMakeLists.txt file unless you know how to set the many options.
- Mac
- Xcode, which includes
- python3 and pip3, and
- clang
- Homebrew
- CMake and Ninja
brew install cmake ninja tree
Git-clone this repo and the IREE repo. Make sure that they are in the same directory. For example:
~/work
├── iree-for-apple-platforms
└── iree
Run ~/work/iree-for-apple-platforms/build.sh
to build
- the IREE runtime into
~/work/iree-for-apple-platforms/build/runtime/iree.xcframework
, and - the IREE compiler, runtime, and Python binding for macOS in
~/work/iree-for-apple-platforms/build/compiler
.
Run build.sh -f
to force rebuild the IREE runtime XCFramework.
Run build.sh -r
to force rebuild the IREE compiler and runtime.
Run build.sh -m
to enable the Metal GPU support. As of Apr 20, 2023, the Metal GPU backend is in https://github.com/antiagainst/iree/tree/apple-metal-hal. It will be merged into the official repo soon.
Clone this project.
mkdir ~/work/
cd ~/work
git clone <URL to this project>
Clone IREE.
cd ~/work
git clone --recursive https://github.com/openxla/iree
If you want Metal GPU support, you will need to clone https://github.com/antiagainst/ and use the branch apple-metal-hal
.
cd ~/work/iree
git remote add lei https://github.com/antiagainst/iree
git fetch lei
git checkout metal-hal-pr
git submodule update
Build IREE compiler, runtime, and Python binding for macOS, and IREE runtime into an XCFramework.
cd ~/work/iree-for-apple-platform
./build.sh
Run the following commands to
- Set
DYLD_LIBRARY_PATH
environment variable to expose the dynamic library of IREE compiler. - Set
PATH
environment variable and runiree-compile
. - Set
PYTHONPATH
environment variable to expose Python packagesiree.compiler
andiree.runtime
.
source ./install.sh
Then, you should be able to run the IREE compiler from the command-line.
iree-compile -h
and you should be able to import iree.compiler
and iree.runtime
in Python.
python3 -c 'import iree.compiler; import iree.runtime'
Apple devices run various operating systems, and each kind of device may have more than one CPU architecture. The built iree.xcframework
supports the following platforms:
Apple Platform | CPU architectures |
---|---|
macOS | x86_64 and arm64 |
iOS | arm64 and arm64e |
iOS Simulator | x86_64 and arm64 |
This step uses the CMakeLists.txt file in the root directory of the IREE project.
This step uses the CMakeLists.txt file in this project. It includes the following steps:
- The IREE runtime is built by
build.sh
into alibiree.a
library for each OS-CPU combo. - For all CPU architectures of an OS,
build.sh
combines thelibiree.a
files into a single FATlibiree.a
file. - For each OS,
build.sh
puts the IREE runtime header files and this FATlibiree.a
into a framework bundle, which is a bundle, or a directory structure, on the filesystem. - For all frameworks for all of the above operating systems,
build.sh
combines the framework bundles into an XCFramework bundle.