IREE on iOS: The Progress #11732
wangkuiyi
started this conversation in
Show and tell
Replies: 2 comments 5 replies
-
This is fantastic writeup, thanks all the great work @wangkuiyi! I'll take a look at the Info.plist issue. |
Beta Was this translation helpful? Give feedback.
0 replies
-
BTW, @wangkuiyi would you mind to turn the steps into a proper doc like what we have here for Android? Just need to create an |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
IREE supports Android https://iree-org.github.io/iree/#support-matrix. It is on its way to supporting iOS.
Build for iOS
Our first step is to enable the build of IREE for iOS. IREE has two sets of building rules, CMake and Bazel. CMake is the recommended one. Bazel is mostly for integration with TensorFlow and Google internal build system.
As kindly explained by @ScottTodd, IREE includes two parts. The compilers run on desktops and servers. They can lower
torch.fx.Graph
traced from PyTorch programs orJAXPRs
traced from JAX programs intovmfb
, a flatbuffer containing CPU and GPU code. The runtime runs on devices like an Android phone and executes code in the vmfb.This discussion #11716 records the progress of enabling the build for iOS. After merging several pull requests by @antiagainst , we were able to build the compilers for macOS and then for iOS (device and simulator).
Step 1. Build the Compiler for macOS
Step 2.1. Build the Runtime for the iOS Simulator
In the directory
./build-sim/install/bin
, we can see some iOS apps.Jan 5, 2023: The content of
Info.plist
is incomplete. Details follow.Jan 7, 2023: @antiagainst fixed this problem in #11742
Step 2.2. Build the Runtime for iOS Devices
The only difference between building for the simulator and devices is the value of
-DCMAKE_OSX_SYSROOT
.Run
flags_demo.app
on iOS SimulatorsTo verify the build result, we want to run an app, say,
flags_demo.app
, on the iOS simulator.Like the Android ecosystem offers the Android Debugger,
adb
, Apple offers a command-line tool,simctl
, to manage and operate iOS simulators. Following steps in https://wkyi.quip.com/JYFLAuqPQgNT, I started an iOS simulator on my M1 MacBook Pro.Step 1. Manually complete the Info.plist file
I manually added the following content into
./build-sim/install/bin/flags_demo.app/Info.plist
. Otherwise, the following app install step will fail with error messages complaining the lack of fields likeCFBundleVersion
.Step 2. Install the App
The following command prints the boosted simulator ID.
The following command installs the app to the simulator.
The following command verifies the installation. Please note that com.company.app is what I added manually into the Info.plist file to identify the app.
Step 3. Run the App
The following command launches the installed flags_demo.app. It redirects the stdout and stderr of the app to the terminal.
Run on iPhones
[TBD: use
xcrun altool
to notarize the app and publish on App Store.]Run
iree-run-module
on iOS SimulatorsI verified this simple Android example (https://iree-org.github.io/iree/building-from-source/android/#running-tools-directly) works for iOS Simulator.
Build IREE as described above.
Run the compiler built for macOS to generate the vmfb.
Copy the generated vmfb file into the iOS app bundle of
iree-run-module
.Manually add the following into the
./build-sim/install/bin/iree-run-module.app/Info.plist
file.We will be able to avoid this hacky step once after we fix CMake build for iOS generates incomplete Info.plist files #11733.
You can use an arbitrary bundle ID other than
org.iree.runmodule
. The following commands refer to the app by this ID.Install the app to the iOS simulator.
Check the path to the installed bundle.
Launch the iree-run-module app on the simulator.
It prints the following content.
Note: why it seems that the program ran twice and printed the result twice?
An JAX Example
[TBD: Run something like this example https://github.com/iree-org/iree-jax]
Beta Was this translation helpful? Give feedback.
All reactions