This directory contains configuration to create an Android application that executes a single IREE module as a native activity.
Note that this app is purely for benchmarking/profiling IREE itself. This is not the expected integration path for a real Android application, for which we expect to provide proper Java API and build support.
The app uses Android NativeActivity
to bridge IREE core libraries together with the Android system. Native activity allows one to implement an Android Activity purely in C/C++. There are tutorials and examples one can follow to learn about Native Activity.
This app does not contain Gradle configurations. The reason is that we need to package both IREE native libraries and a specific VM module invocation into the app. The procedure cannot be automated much by Android Studio; rather one might need to copy files from different places, rename them, and wire up the build. It's inconvenient. For a developer tool we would like to avoid such friction and thus improve velocity. So a script, build_apk.sh
, is provided to automate the process.
But the script itself requires an Android SDK/NDK installation structure that matches Android Studio. So it's easier to just install Android Studio to manage Android SDK/NDK. The script will use proper tools in Android SDK/NDK to build and package the final APK file.
In general, we need to
iree_run_module_app
shared library following normal C++ build process.AndroidManifest.xml
from the template by providing the proper target Android API level.assets/module.vmfb
, write the entry function input buffers, and HAL driver into assets/entry_function.txt
, assets/inputs.txt
, and assets/device.txt
, respectively.lib/<android-abi>/
.res/
directory into an Android DEX file.When started on Android, the app will read the contents in assets
to get the VM FlatBuffer and invocation information and run it.