Skip to content

Commit

Permalink
Merge pull request #2355 from wangzhaode/feature/sync_2.5.0
Browse files Browse the repository at this point in the history
[MNN:Sync] Sync Internal 2.5.0
  • Loading branch information
wangzhaode committed Apr 27, 2023
2 parents fa653d7 + 9fe7803 commit d7d1efe
Show file tree
Hide file tree
Showing 129 changed files with 9,038 additions and 1,759 deletions.
1 change: 1 addition & 0 deletions 3rd_party/OpenCLHeaders/CL/cl.h
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@ typedef struct _cl_buffer_region {
#define CL_PROFILING_COMMAND_COMPLETE 0x1284
#endif

#define CL_DEVICE_NUM_THREADS_PER_EU_INTEL 0x4255
/********************************************************************************************************/

/* Platform API */
Expand Down
1 change: 1 addition & 0 deletions 3rd_party/OpenCLHeaders/CL/cl2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,7 @@ inline cl_int getInfoHelper(Func f, cl_uint name, T* param, int, typename T::cl_
F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \
F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \
F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \
F(cl_device_info, CL_DEVICE_NUM_THREADS_PER_EU_INTEL, cl_uint) \
F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \
F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, size_type) \
F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, cl::vector<size_type>) \
Expand Down
3 changes: 0 additions & 3 deletions demo/exec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ list(APPEND MNN_EXEC_DEMOS expressMakeModel.out)
add_executable(transformerDemo.out ${CMAKE_CURRENT_LIST_DIR}/transformerDemo.cpp)
list(APPEND MNN_EXEC_DEMOS transformerDemo.out)

add_executable(rasterDemo.out ${CMAKE_CURRENT_LIST_DIR}/rasterDemo.cpp)
list(APPEND MNN_EXEC_DEMOS rasterDemo.out)

add_executable(nluDemo.out ${CMAKE_CURRENT_LIST_DIR}/nluDemo.cpp)
list(APPEND MNN_EXEC_DEMOS nluDemo.out)

Expand Down
252 changes: 0 additions & 252 deletions demo/exec/rasterDemo.cpp

This file was deleted.

Binary file added docs/_static/images/cv/adaptiveThreshold.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/cv/bilateralFilter.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/cv/erode.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/cv/remap.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion docs/compile/cmake.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ MNN使用CMake构建项目,CMake中的宏定义列表如下:
| MNN_IMGPROC_HISTOGRAMS | 构建MNN的OpenCV功能是否开启`直方图`,默认为`ON` |
| MNN_CALIB3D | 构建MNN的OpenCV功能是否开启`3d`,默认为`ON` |
| MNN_IMGCODECS | 构建MNN的OpenCV功能是否开启`图像编解码`,默认为`OFF` |
| MNN_CVCORE | 构建MNN的OpenCV功能是否开启`core`功能,默认为`ON` |
| MNN_OPENCV_TEST | 构建MNN的OpenCV功能是否开启单元测试,默认为`OFF` |
| MNN_OPENCV_BENCH | 构建MNN的OpenCV功能是否开启性能benchmark,默认为`OFF` |
| MNN_VULKAN_IMAGE | 构建MNN的Vulkan后端时采用Image内存模式,以便支持FP16和部分移动端上GPU的加速,默认为`ON` |
| MNN_VULKAN_IMAGE | 构建MNN的Vulkan后端时采用Image内存模式,以便支持FP16和部分移动端上GPU的加速,默认为`ON` |
8 changes: 4 additions & 4 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ opConverter ==> MNN Converter NOT_SUPPORTED_OP: [ ANY_OP_NAME ]

- 若原始模型为 tflite / caffe(含自定义算子) , 改成 MNN 支持较好的 Tensorflow pb 格式导出或转成 Onnx ,再转 MNN
- 提 Issue 等待我们支持,并关注 MNN 的更新
- 参考 [https://www.yuque.com/mnn/cn/customize_op](https://www.yuque.com/mnn/cn/customize_op) 自定义算子
- 参考[自定义算子](./contribute/op.md)

### 模型转换后与原框架结果不一致
先使用MNN中的模型一致性验证脚本进行测试,确定不是调用方法或其他错误,[使用方法](./usage/convert.html#id3)
先使用MNN中的模型一致性验证脚本进行测试,确定不是调用方法或其他错误,[使用方法](./tools/convert.html#id3)

## Pymnn
### import MNN 出现 import numpy error
Expand Down Expand Up @@ -160,7 +160,7 @@ const float* outputPtr = output->readMap<float>();
- 如果确定输入形状正确,并且执行了`resizeTensor`和`resizeSession`;可以打开`source/shape/SizeComputer.cpp`中的宏`// #define MNN_DEBUG_TENSOR_SIZE`定义,然后执行模型推理;打开宏之后可以看到每一层的形状信息,可以逐层进行Debug
### Android 设备无法查看日志
Android 系统有两类打印日志的方式: printf 和 logcat. 默认 MNN 的编译脚本使用 printf,这样方便在命令行中调试([https://www.yuque.com/mnn/cn/tool_test](https://www.yuque.com/mnn/cn/tool_test)),集成到 App 上时,用 cmake -DMNN_USE_LOGCAT=ON 将打印日志的方式改成 logcat 即可用 adb logcat 查看
Android 系统有两类打印日志的方式: printf 和 logcat. 默认 MNN 的编译脚本使用 printf,这样方便在命令行中调试集成到 App 上时,用 cmake -DMNN_USE_LOGCAT=ON 将打印日志的方式改成 logcat 即可用 adb logcat 查看
###
### 如何增加 opencl so 地址?
MNN opencl 后端默认采用 dlopen 的方式动态打开设备的 opencl 驱动,相应位置若找不到您设备上的驱动,请修改 **OpenCLWrapper.cpp**
Expand Down Expand Up @@ -208,7 +208,7 @@ OpenCL / Vulkan 采用静态变量自注册的方式往 MNN 主库注册后端.
- 输入输出指针为空/段错误
- 一般是直接访问了 tensor 的 host
- 按 [https://www.yuque.com/mnn/cn/input](https://www.yuque.com/mnn/cn/input) 和 [https://www.yuque.com/mnn/cn/output](https://www.yuque.com/mnn/cn/output) 里面的方式建host tensor 并 copy ,参考相关文档修改使用代码
- 按 [输入数据](./inference/session.html#id8) 和[获取输出](./inference/session.html#id21) 里面的方式建host tensor 并 copy ,参考相关文档修改使用代码
- 是否可基于 deviceId 直接传 GPU 地址?
- 可以,需要理解 MNN GPU 内存布局并传上下文给 MNN ,但相关实现较复杂
- 采用 MNN_Express 系列接口,可以支持模型之间的内存直接传递不做拷贝
Expand Down
63 changes: 62 additions & 1 deletion docs/intro/releases.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,66 @@
# 发布版本
## 2.2.0 (`Latest`)
## 2.4.0 (`Latest`)
#### 新特性
- NNAPI 支持int8 量化模型;
- MNN OpenCL/Metal支持算子在线Fuse与代码生成;
- 支持使用cibuildwheel构建Python Wheel包;
- Github Action支持自动化构建多端库与Whl包;
- (测试中)CUDA后端支持量化模型运行
#### 重构/优化
- CUDA优化Softmax/DepthwiseConv算子
- 优化 KernelSize = 3x3 的 OpenCL 卷积算子性能
- 优化了MaxPool/AvgPool的int8量化计算;
- 移除原来的LLVMJit, C等Codegen后端;
- 更新MNN.podspec, MNNBridge.podspec;
- 增加GELU模块Fuse为GELU算子的功能,Vulkan 和 OpenCL 后端支持 GELU 算子
- NetModule析构函数中增加gc函降低内存占用;
- OpenCL支持设置推理低优先级配置;
- OpenCL updateCache支持异步,降低阻塞时间;
- fastTestOnnx.py / fastTestTf.py / fastTestTflite.py / fastTestTorch.py 分别更名为 testMNNFromOnnx.py / testMNNFromTf.py / testMNNFromTflite.py / testMNNFromTorch.py
- Android Demo新增使用README文档;
#### Bugfix
- 修复Android Demo运行Crash的问题;
- 修复Metal中的onSync的Bug;
- 修复Metal多段模型推理的Bug;
- 修复在Windows下MNN Train的编译问题;
- 修复perm值非法时的Crash问题;
- 修复Pad的输入参数为负数时(此时等效为Crop),计算出错的问题
- 修正 Relu Int8 不支持非对称量化的问题
- 修正部分AVX2架构的机器上运行量化模型crash的问题
- 修正Module API 运行静态模型crash的问题
- 修正Winograd量化过程未使用相同变换矩阵的问题
- 修正Winograd量化计算多Batch输入错误的问题
- 修正 OpenCL Relu 算子在 AMD GPU 上段错误的问题
- 修正 OpenCL ROIPooling 算子实现错误
## 2.3.0
### 功能完善
- 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 为空的问题
## 2.2.0
### 框架通用性
- MNN新增对`ARMv8.6-A`指令支持,支持了`smmla``bfmmla`指令
- MNN新增汇编预处理脚本,能够将汇编指令转换为`.inst`指令,降低新指令对编译器的依赖
Expand Down

0 comments on commit d7d1efe

Please sign in to comment.