Defaults OFF
, When OFF
, remove symbols and build with optimizations.
Defaults ON
, When OFF
, do not use openmp multi-thread, only effective on Android/Linux.
Defaults OFF
, When ON
, build the OpenCL backend, apply GPU according to setting the forward type to be MNN_FORWARD_OPENCL at inference time.
Defaults OFF
, When ON
, build the OpenGL backend, apply GPU according to setting the forward type to be MNN_FORWARD_OPENGL at inference time.
Defaults OFF
, When ON
, build the Vulkan backend, apply GPU according to setting the forward type to be MNN_FORWARD_VULKAN at inference time.
Defaults OFF
, When ON
, build the Metal backend, apply GPU according to setting the forward type to be MNN_FORWARD_Metal at inference time, only effective on iOS/macOS.
- Install cmake(cmake version >=3.10 is recommended)
cd /path/to/MNN
./schema/generate.sh
./tools/script/get_model.sh
(optional, models are required only in demo project)mkdir build && cd build && cmake .. && make -j4
Then you will get the MNN library(libMNN.so)
Download cross compile toolchain from Linaro
Example:
- Download AArch64 toolchain
mkdir -p linaro/aarch64
cd linaro/aarch64
wget http://releases.linaro.org/components/toolchain/binaries/latest-7/aarch64-linux-gnu/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz
tar xvf gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz
export cross_compile_toolchain=linaro/aarch64/aarch64-linux-gnu
- build with cmake
cmake .. \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_SYSTEM_VERSION=1 \
-DCMAKE_SYSTEM_PROCESSOR=aarch64 \
-DCMAKE_C_COMPILER=$cross_compile_toolchain/aarch64-linux-gnu-gcc \
-DCMAKE_CXX_COMPILER=$cross_compile_toolchain/aarch64-linux-gnu-g++
- compile
mkdir build
cd build
cmake ..
make -j4
- Install cmake(cmake version >=3.10 is recommended)
- Download and Install NDK, download the the version before r17 is strongly recommended (otherwise cannot use gcc to build, and building armv7 with clang possibly will get error)
- Set ANDROID_NDK path, eg:
export ANDROID_NDK=/Users/username/path/to/android-ndk-r14b
cd /path/to/MNN
./schema/generate.sh
./tools/script/get_model.sh
(optional, models are required only in demo project)cd project/android
- Build armv7 library:
mkdir build_32 && cd build_32 && ../build_32.sh
- Build armv8 library:
mkdir build_64 && cd build_64 && ../build_64.sh
open MNN.xcodeproj with Xcode on macOS, then build.