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 (version >= 3.10 is recommended), protobuf (version >= 3.0 is required) and gcc (version >= 4.9 is required)
cd /path/to/MNN
./schema/generate.sh
./tools/script/get_model.sh
(optional, models are needed 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
-
Install cmake (version >= 3.10 is recommended), protobuf (version >= 3.0 is required)
-
cd /path/to/MNN
-
./schema/generate.sh
-
mkdir build && cd build
-
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++
make -j4
Then you will get the MNN library(libMNN.so)
- Install "Microsoft Visual Studio 2019", cmake (version >= 3.10 is recommended),powershell
- Find and click "x64 Native Tools Command Prompt for VS 2019" in Setting
- Change "Setting -> region and language -> administration -> non-Unicide program language" to English (American), otherwise compile may failed because of encoding format.
- compile and build MNN
cd /path/to/MNN
mkdir build && cd build
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release ..
nmake
- Install cmake (version >=3.10 is recommended), protobuf (version >= 3.0 is required) and gcc (version >= 4.9 is required)
- Download and Install NDK
- Set ANDROID_NDK path, eg:
export ANDROID_NDK=/Users/username/path/to/android-ndk-r17b
cd /path/to/MNN
./schema/generate.sh
./tools/script/get_model.sh
(optional, models are needed 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
- Install protobuf (version >= 3.0 is required)
cd /path/to/MNN
./schema/generate.sh
./tools/script/get_model.sh
(optional, models are needed only in demo project)- open MNN.xcodeproj with Xcode on macOS, then build.
Copy mnn.metallib
to the application's main bundle directory if the Metal backend is in your need. You can also refer to Run Script
in Build Phases
of the Playground target.