huawei-noah / bolt

Bolt is a deep learning library with high performance and heterogeneous flexibility.
https://huawei-noah.github.io/bolt/
MIT License
910 stars 158 forks source link

opencl的一个bug #91

Open peyer opened 2 years ago

peyer commented 2 years ago

我在测试bolt的opencl时发现一个bug; 由于bolt采用了NCHW / NCHWC4等数据排布混用、针对opencl在层与层之间的blob混用了buffer、image1d、image2d、image3d,同时内存分配上还采用了内存复用,可能导致了我的一个模型在depth2space_ocl层触发了一个bug,就是depth2space对应的kernel的arg里是写的是buffer的输入类型,但是内存复用以后,对应arg传入了一个image3d的数据类型,导致set_arg报错CL_INVALID_MEM_OBJ,我还在定位是内存复用的代码

yunfanxiao commented 2 years ago

你好,正常情况下depth2space的output不会被设置为image类型,可在cnn.cpp与memory_tracker的相关代码中定位为何被修改为image,可打开debug模式获取更多信息。

peyer commented 2 years ago

上面的表述有误,我更正一下;应该是depth2space前一层是conv,conv的output是image类型并给了depth2space做输入,而depth2space的输入支持buffer的类型

peyer commented 2 years ago

python脚本构造一个简易网络,第一层是conv,输入1x2x4x4,filter16x2x3x3,stride=1,pad=0,dilation=1,输出1x16x2x2,第二层是depth2space,blocksize=4,输出1x1x8x8,也会触发

yunfanxiao commented 2 years ago

这里确实有些问题,请问计算触发depth2space_mali_fp16.cpp 74行的转换了吗?

peyer commented 2 years ago

2分支都可能触发错误;因为depth2space的kernel输入只支持buffer的类型,一旦前一层传递一个image的就会出错

yunfanxiao commented 2 years ago

提交了一个修复的patch,可以试一试https://github.com/huawei-noah/bolt/pull/92

peyer commented 2 years ago

@yunfanxiao 还是有点问题,需要再改一下 image

peyer commented 2 years ago

按理说github的单元测试应该很容易找到这个bug,是CI没有跑就强合了吗?