1 Star 5 Fork 1

新无止竞 / MNN

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

MNN

English Version

MNN官网

简介

MNN是一个高效、轻量的深度学习框架。它支持深度模型推理与训练,尤其在端侧的推理与训练性能在业界处于领先地位。目前,MNN已经在阿里巴巴的手机淘宝、手机天猫、优酷、钉钉、闲鱼等20多个App中使用,覆盖直播、短视频、搜索推荐、商品图像搜索、互动营销、权益发放、安全风控等70多个场景。此外,IoT等场景下也有若干应用。

MNN的架构设计理念与性能数据在MLSys 2020上面发表。Paper 在此处。如果MNN对你的研究有所助益,欢迎引用MNN的论文:

@inproceedings{alibaba2020mnn,
  author = {Jiang, Xiaotang and Wang, Huan and Chen, Yiliu and Wu, Ziqi and Wang, Lichuan and Zou, Bin and Yang, Yafeng and Cui, Zongyang and Cai, Yu and Yu, Tianhang and Lv, Chengfei and Wu, Zhihua},
  title = {MNN: A Universal and Efficient Inference Engine},
  booktitle = {MLSys},
  year = {2020}
}

文档与工具

MNN的使用文档统一放在语雀,请移步至语雀文档

MNN官网上还可以下载MNN团队全新力作MNN工作台,涵盖开箱即用模型、可视化训练等工具,更可以一键部署到多端设备。

MNN 特色

高性能

  • 不依赖任何第三方计算库,依靠大量手写汇编实现核心运算,充分发挥ARM CPU的算力。
  • iOS设备上可以开启GPU加速(Metal),常用模型上快于苹果原生的CoreML。
  • Android上提供了OpenCLVulkanOpenGL三套方案,尽可能多地满足设备需求,针对主流GPU(AdrenoMali)做了深度调优。
  • 卷积、转置卷积算法高效稳定,对于任意形状的卷积均能高效运行,广泛运用了 Winograd 卷积算法,对3x3 -> 7x7之类的对称卷积有高效的实现。
  • 针对ARM v8.2的新架构额外作了优化,新设备可利用FP16半精度计算的特性获得两倍提速。

轻量性

  • 针对端侧设备特点深度定制和裁剪,无任何依赖,可以方便地部署到移动设备和各种嵌入式设备中。
  • iOS平台:armv7+arm64静态库大小5MB左右,链接生成可执行文件增加大小620KB左右,metallib文件600KB左右。
  • Android平台:so大小400KB左右,OpenCL库400KB左右,Vulkan库400KB左右。

通用性

  • 支持TensorflowCaffeONNX等主流模型文件格式,支持CNNRNNGAN等常用网络。
  • 转换器支持149个TensorflowOP、58个TFLite OP、47个Caffe OP、74个ONNX OP;各计算设备后端支持的MNN OP数:CPU 111个,ARM V8.2 6个,Metal 55个,OpenCL 43个,Vulkan 32个。
  • 支持iOS 8.0+、Android 4.3+和具有POSIX接口的嵌入式设备。
  • 支持异构设备混合计算,目前支持CPU和GPU。

易用性

  • 有高效的图像处理模块,覆盖常见的形变、转换等需求,一般情况下,无需额外引入libyuv或opencv库处理图像。
  • 支持回调机制,可以在网络运行中插入回调,提取数据或者控制运行走向。
  • 支持只运行网络中的一部分,或者指定CPU和GPU间并行运行。
  • (BETA)MNN Python API,让算法工程师可以轻松地使用MNN构图、训练、量化训练,无需编写C++。

架构设计

architecture

MNN可以分为Converter和Interpreter两部分。

Converter由Frontends和Graph Optimize构成。前者负责支持不同的训练框架,MNN当前支持Tensorflow(Lite)、Caffe和ONNX(PyTorch/MXNet的模型可先转为ONNX模型再转到MNN);后者通过算子融合、算子替代、布局调整等方式优化图。

Interpreter由Engine和Backends构成。前者负责模型的加载、计算图的调度;后者包含各计算设备下的内存分配、Op实现。在Engine和Backends中,MNN应用了多种优化方案,包括在卷积和反卷积中应用Winograd算法、在矩阵乘法中应用Strassen算法、低精度计算、Neon优化、手写汇编、多线程优化、内存复用、异构计算等。

社区交流与反馈

扫描二维码加入钉钉讨论群。

一群(已满):

二群(已满):

三群:

License

Apache 2.0

致谢

MNN参与人员:淘宝技术部、搜索工程团队、达摩院团队、优酷等集团员工。

MNN参考、借鉴了下列项目:

![MNN](doc/banner.png) [中文版本](README_CN.md) [MNN Homepage](http://www.mnn.zone) ## Intro MNN is a highly efficient and lightweight deep learning framework. It supports inference and training of deep learning models, and has industry leading performance for inference and training on-device. At present, MNN has been integrated in more than 20 apps of Alibaba Inc, such as Taobao, Tmall, Youku, Dingtalk, Xianyu and etc., covering more than 70 usage scenarios such as live broadcast, short video capture, search recommendation, product searching by image, interactive marketing, equity distribution, security risk control. In addition, MNN is also used on embedded devices, such as IoT. The design principles and performance data of MNN has been published in an MLSys 2020 paper [here](https://proceedings.mlsys.org/static/paper_files/mlsys/2020/7-Paper.pdf). Please cite MNN in your publications if it helps your research: @inproceedings{alibaba2020mnn, author = {Jiang, Xiaotang and Wang, Huan and Chen, Yiliu and Wu, Ziqi and Wang, Lichuan and Zou, Bin and Yang, Yafeng and Cui, Zongyang and Cai, Yu and Yu, Tianhang and Lv, Chengfei and Wu, Zhihua}, title = {MNN: A Universal and Efficient Inference Engine}, booktitle = {MLSys}, year = {2020} } ## Documentation and Tools MNN's docs are in placed in [Yuque docs here](https://www.yuque.com/mnn/en). MNN Workbench could be downloaded from [MNN's homepage](http://www.mnn.zone), which provides pretrained models, visualized training tools, and one-click deployment of models to devices. ## Key Features ### High performance - Implements core computing with lots of optimized assembly code to make full use of the ARM CPU. - For iOS, GPU acceleration (Metal) can be turned on, which is faster than Apple's native CoreML. - For Android, `OpenCL`, `Vulkan`, and `OpenGL` are available and deep tuned for mainstream GPUs (`Adreno` and `Mali`). - Convolution and transposition convolution algorithms are efficient and stable. The Winograd convolution algorithm is widely used to better symmetric convolutions such as 3x3 -> 7x7. - Twice speed increase for the new architecture ARM v8.2 with FP16 half-precision calculation support. ### Lightweight - Optimized for devices, no dependencies, can be easily deployed to mobile devices and a variety of embedded devices. - iOS platform: static library size for armv7+arm64 platforms is about 5MB, size increase of linked executables is about 620KB, and metallib file is about 600KB. - Android platform: core so size is about 400KB, OpenCL so is about 400KB, Vulkan so is about 400KB. ### Versatility - Supports `Tensorflow`, `Caffe`, `ONNX`, and supports common neural networks such as `CNN`, `RNN`, `GAN`. - MNN model converter supports 149 `Tensorflow` OPs, 58 `TFLite` OPs, 47 `Caffe` OPs and 74 `ONNX` OPs; Number of OPs by different MNN hardware backends: 111 for CPU, 6 for ARM V8.2, 55 for Metal, 43 for OpenCL, and 32 for Vulkan. - Supports iOS 8.0+, Android 4.3+ and embedded devices with POSIX interface. - Supports hybrid computing on multiple devices. Currently supports CPU and GPU. ### Ease of use - Efficient image processing module, speeding up affine transform and color space transform without libyuv or opencv. - Provides callbacks throughout the workflow to extract data or control the execution precisely. - Provides options for selecting inference branch and paralleling branches on CPU and GPU. - (BETA) MNN Python API helps ML engineers to easily use MNN to build a model, train it and quantize it, without dipping their toes in C++ code. ## Architecture ![architecture](doc/architecture.png) MNN can be divided into two parts: Converter and Interpreter. Converter consists of Frontends and Graph Optimize. The former is responsible for supporting different training frameworks. MNN currently supports Tensorflow, Tensorflow Lite, Caffe and ONNX (PyTorch/MXNet); the latter optimizes graphs by operator fusion, operator substitution, and layout adjustment. Interpreter consists of Engine and Backends. The former is responsible for the loading of the model and the scheduling of the calculation graph; the latter includes the memory allocation and the Op implementation under each computing device. In Engine and Backends, MNN applies a variety of optimization schemes, including applying Winograd algorithm in convolution and deconvolution, applying Strassen algorithm in matrix multiplication, low-precision calculation, Neon optimization, hand-written assembly, multi-thread optimization, memory reuse, heterogeneous computing, etc. ## How to Discuss and Get Help From MNN Community Scan the following QR codes to join Dingtalk discussion group. The group discussions are predominantly Chinese. But we welcome and will help English speakers. Group #1 (Full): <img src="doc/DingTalkQR1.png" height="256"/> Group #2 (Full): <img src="doc/DingTalkQR2.png" height="256"/> Group #3: <img src="doc/DingTalkQR3.png" height="256"/> ## License Apache 2.0 ## Acknowledgement MNN participants: Taobao Technology Department, Search Engineering Team, DAMO Team, Youku and other Alibaba Group employees. MNN refers to the following projects: - [Caffe](https://github.com/BVLC/caffe) - [flatbuffer](https://github.com/google/flatbuffers) - [gemmlowp](https://github.com/google/gemmlowp) - [Google Vulkan demo](http://www.github.com/googlesamples/android-vulkan-tutorials) - [Halide](https://github.com/halide/Halide) - [Mace](https://github.com/XiaoMi/mace) - [ONNX](https://github.com/onnx/onnx) - [protobuffer](https://github.com/protocolbuffers/protobuf) - [skia](https://github.com/google/skia) - [Tensorflow](https://github.com/tensorflow/tensorflow) - [ncnn](https://github.com/Tencent/ncnn) - [paddle-mobile](https://github.com/PaddlePaddle/paddle-mobile) - [stb](https://github.com/nothings/stb) - [rapidjson](https://github.com/Tencent/rapidjson) - [pybind11](https://github.com/pybind/pybind11) - [pytorch](https://github.com/pytorch/pytorch) - [bolt](https://github.com/huawei-noah/bolt) - [libyuv](https://chromium.googlesource.com/libyuv/libyuv)

简介

MNN是一个轻量级的深度神经网络推理引擎,在端侧加载深度神经网络模型进行推理预测 展开 收起
C++
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/huiwei13/MNN.git
git@gitee.com:huiwei13/MNN.git
huiwei13
MNN
MNN
master

搜索帮助