2.0.0

alibaba/MNN2.0.0Jun 29, 2022by jxt1234

AI Summary

MNN 2.0.0 is a major release featuring significant framework enhancements including expanded operator support (Onnx: 117→158, Torchscripts: 34→163), new MNN-CV and MNN-Numpy modules with 227 combined functions, and substantial CPU/GPU performance improvements through AVX512 and TensorCore optimizations.

Key Highlights

  • Onnx operator support increased from 117 to 158, Torchscripts from 34 to 163
  • CPU performance improved with AVX512 optimization and multi-threading enhancements
  • GPU inference rewritten using TensorCore (removed cudnn dependency)
  • New MNN-CV module with 57 OpenCV-like functions and MNN-Numpy with 170 numpy-like functions
  • Added mnncompress tool for model compression supporting TensorFlow 1.X and PyTorch

New Features

  • MNNConvert now supports model conversion validation and MNN/Json file interchange
  • Unified version number mechanism with compile-time macros, runtime functions, and model version info
  • New mnncompress model compression tool
  • MNN-CV module with 57 image encoding/decoding and processing APIs
  • MNN-Numpy module with 170 numpy-like functions for Python
  • iOS demo project using MNN framework
  • Pymnn offline quantization demo and training-related tests
  • MNN.cv vs OpenCV benchmark and MNN.numpy vs numpy benchmark
  • Various bug fixes including arm64 assembly, GatherND precision, ZeroShape support, and CoreML issues

Full Release Notes

# 一、框架通用性
- 模型推理通用性增加:Torchsciprts OP 添加,Onnx OP 补齐
   - Onnx 算子数由 117 增加到 158 
   - Torchscripts 算子数由 34 增加到 163
- MNNConvert功能扩充
   - 支持模型转换正确性验证
   - 支持MNN模型与Json文件互转,方便查看与编辑模型结构
- MNN增加统一版本号机制
   - 编译期版本宏定义
   - 运行时版本号函数
   - 模型中增加版本信息
- 增加 MNN-CV / MNN-Numpy 功能
   - C++中提供了与OpenCV中图像编解码,图像处理用法相似的API;
   - Python中提供了与cv2/numpy基础功能用法相似的函数;
   - 支持的cv函数57个,numpy函数170个,[函数列表](https://www.yuque.com/mnn/cn/pu0qfp 《MNN cv numpy 模块》);
# 二、性能优化

- 服务/PC端推理CPU/GPU性能提升
   - CPU部分AVX512优化,多线程优化提速;
   - GPU部分CUDA移除cudnn,基于TensorCore重写;

![image](https://user-images.githubusercontent.com/5484403/176395834-d095221d-0f8c-4146-9649-2da7084a67ba.png)
![image](https://user-images.githubusercontent.com/5484403/176395887-bdeb7d51-d951-4138-8df4-d64d72d14c35.png)

![image](https://user-images.githubusercontent.com/5484403/176395988-4586d786-19f0-484b-bccb-d75f0d24e089.png)


# 三、模型压缩

- 新增mnncompress模型压缩工具
   - 支持基于TensorFlow 1.X和Pytorch的模型压缩,具体使用方法见[文档](https://www.yuque.com/mnn/cn/cxgvyh)
   - 添加压缩模型的模型转换,及相关算法的MNN底层推理支持
# 四、其他

- 测试/Demo/Benchmark完善
   - 修正 Android Demo 的 编译Bug;
   - 增加一个使用 mnn framework 的 ios demo工程;
   - Pymnn新增离线量化Demo与测试;
   - Pymnn新增训练相关测试;
   - Pymnn中新增MNN.numpy与numpy对比的benchmark;
   - 新增MNN.cv与OpenCV对比的benchmark;
- Bugfix(包括但不限于)
   - Pymnn修复训练相关API使用Bug;
   - 修复arm64汇编中的sp计算Bug;
   - GatherND 精度数目问题修复;
   - ZeroShape 支持完善;
   - NDK24 下 armv7a-arm82 编译错误修正;
   - benchmark metal crash修复;
   - benchmark metal crash;
   - Module 的 RuntimeManager 设置 precision = low 无效的问题修复;
   - CoreML Pooling CAFFE-PAD,Deconv修复;
   - CoreML多次执行内存占用过高问题修复;