This demo provides CMake build scripts to compile a source code, demo.cpp
, that trains a LeNet model in MNN framework, into an executable target file demo.out
along with MNN shared libraries for Linux/macOS and Android platforms.
- cmake (version >=3.10 is recommended)
- protobuf (version >= 3.0 is required)
- gcc (version >= 4.9 is required)
- run
./build_x86_linux.sh
, which will generate the executable filedemo.out
under build_x86_linux folder.
cd build/train
sh build_x86_linux.sh
./build_x86_linux/demo.out mnist ../../../data/lenet_mnist.mnn ../../../data/mnist
# Use high precision model (Customized Softmax Operator):
./build_x86_linux/demo.out mnist ../../../data/lenet_mnist_high_precision.mnn ../../../data/mnist
# Use tabular type dataset for functional testing:
./build_x86_linux/demo.out tabular ../../../data/lenet_mnist.mnn ../../../data/tabular
- Download and Install NDK, latest release version is recommended
- Set ANDROID_NDK path at line 3 in
build_arm_android_64.sh
, eg: ANDROID_NDK=/Users/username/path/to/Android-ndk-r14b - run
./build_arm_android_64.sh
, which will generate the executable filedemo.out
under build_arm_android_64 folder. - run
./test_arm_android_64.sh
, which will pushdemo.out
to your android device and execute it.
- You can change CMake compilation options in
build.sh
as needed (i.e. turn off demo/quantools/evaluation/converter/test/benchmark options, turn on openmp/opencl/opengl/vulkan as your backend, set FP16/BF16 low precision mode, and etc). Check MNN document and MNN CMakeList for more information. - MNN compilation artifacts under
build/mnn_binary_dir
- libMNN: Backend Shared Library
- libMNNTrain: Training Framework Shared Library
- libMNNExpr: Express Training API Shared Library
- To run
demo.out
on your linux/macOS machine, first download MNIST dataset from Google Drive, and run./demo.out /path/to/data/mnist_data
. To rundemo.out
on your android device, adb push mnist_data to your android device under/data/local/tmp
before running./test_arm_android_64.sh
.