MNN下交叉编译
参考:https://blog.csdn.net/Simplify_boy/article/details/105410235
https://blog.csdn.net/qq_37643960/article/details/99775939
Could NOT find Protobuf (missing: Protobuf_LIBRARIES Protobuf_INCLUDE_DIR)
MNN CMakeLists.txt
CMakelist.txt 设置MNN_ARM82为ON (低精度需要的动态库)
ndk
vim ~/.bashrc
添加android-NDK
export ANDROID_NDK=/$(path)/android-ndk-r21
$(path)为自己的路径
source ~/.bashrc`
编译
cd /path/to/MNN
./schema/generate.sh
cd MNN/project/android
mkdir build_64 && cd build_64 && ../build_64.sh
make -j4
使用动态库
代码设置
// 创建session需要的配置
MNN::ScheduleConfig config;
// 选择Backend
config.type = MNN_FORWARD_CPU;
// 线程数
config.numThread = 2;
// 配置相应的Backend
BackendConfig backendConfig;
// 选择低精度/一般配置计算
backendConfig.precision = BackendConfig::Precision_Low;
// 或者
// backendConfig.precision = BackendConfig::Precision_Normal;
config.backendConfig = &backendConfig;
android添加库
public class MNNNetNative { // load libraries
static {
System.loadLibrary("MNN");
System.loadLibrary("MNN_Arm82");
System.loadLibrary("mnncore");
}
}