2.3.0
alibaba/MNN2.3.0Dec 30, 2022by jxt1234
AI Summary
MNN 2.3.0 introduces significant backend improvements including CUDA high-precision mode (FP32) and SM60 support, OpenCL low power mode, and experimental Vulkan Buffer memory layout. The release also adds MNN-Train derivative optimizations with CONTENT mode for geometric computation, experimental support for separating model structure from weights, and includes various performance optimizations and bug fixes.
Key Highlights
- CUDA backend now supports high-precision models (FP32 with precision=high) and SM60 architecture
- MNN-Train adds CONTENT mode for geometric computation decomposition to reduce derivative operator implementation
- OpenCL backend supports low power running mode (power=low)
- Experimental Vulkan backend adds Buffer memory layout support alongside existing Image layout
- Removed ComputeUnit/ComputeCache, using Session instead with delayed memory allocation to reduce conversion memory usage
New Features
- CUDA high-precision model support (FP32 computation when precision=high)
- CUDA SM60 architecture support
- MNN-Express CONTENT mode for geometric computation decomposition
- Raster/Loop operator partial derivative support
- GridSampler derivative support
- OpenCL low power mode (power=low)
- Vulkan Buffer memory layout support (experimental)
- Separable model structure and weights (--saveExternalData flag for model conversion, setExternalFile/setExternalFile APIs for loading)
- Optimized SeqLength=1 ONNX LSTM with convolution+nonlinear layers
- Fixed Convolution Winograd CPU performance regression
- Raster operator input改造为多输入单输出
- Quantization refactored to online operator insertion
- Static model export optimization (removes invalid operators)
Full Release Notes
# 一、功能完善
- CUDA 后端支持高精度模型(设置 precision = high 时使用 FP32 计算) 和 SM60 架构
- MNN-Train 求导优化
- MNN-Express 支持 CONTENT 模式,该模式下基于几何计算分解算子后再构图,以降低需要实现求导的算子数
- 支持 Raster / Loop 算子部分情况下的求导
- 支持 GridSampler 的求导
- OpenCL 后端支持低优先级运行模式(设置 power = low)
- (实险中特性)Vulkan 后端增加基于Buffer内存布局的算子实现,目前基于编译宏决定用 Image内存布局还是 Buffer内存布局(MNN_VULKAN_IMAGE ,默认为 ON)
- (实验中特性)支持分离模型结构与权重的选项
- 模型转换为 {S}.mnn 时,添加参数 --saveExternalData ,模型权重将单独保存为二进制文件 {S}.mnn.weight
- 模型加载运行时,通过以下方式指定权重文件路径:
- Session API: Interpreter::setExternalFile
- Module API: Executor::RuntimeManager::setExternalFile
# 二、重构/优化
- 修改嵌入式上常用的 SeqLength = 1 的 ONNX LSTM 算子的模型转换实现,改为用卷积+非线性层拼接实现,以提升性能
- 修正部分情况下 Convolution Winograd CPU 相较之前版本变慢的问题
- 优化 VARP 的 fix 函数,避免拷贝内存
- 对 Raster 算子的输入进行了改造,由 region 隐式输入修改为正常的多输入单输出
- 量化计算实现中的量化/反量化过程重构为在线插入相应算子,并修正 prearrange 为 true 时,Module API 计算量化模型的结果错误问题
- 移除 ComputeUnit / ComputeCache ,Executor 内部的计算改为使用 Session ,并延迟内存分配时机,修正模型转换过程中部分情况下占用内存过大的问题
- 优化模型转换静态模型的导出,移除了图中无效算子
# 三、Bugfix
- 修正 convolution transpose 3d 在 pad 为空时计算 crash 问题
- 修正 cumsum 计算 int 输入的 bug
- 修正 Onnx GatherND 算子转换不支持 batch_dims 的问题
- 修正 Onnx Split 算子转换的默认值问题
- 修正 Onnx permute 算子转换不支持 axis 为空的问题