TNN: developed by Tencent Youtu Lab and Guangying Lab, a uniform deep learning inference framework for mobile、desktop and server. TNN is distinguished by several outstanding features, including its cross-platform capability, high performance, model compression and code pruning. Based on ncnn and Rapidnet, TNN further strengthens the support and performance optimization for mobile devices, and also draws on the advantages of good extensibility and high performance from existed open source efforts. TNN has been deployed in multiple Apps from Tencent, such as Mobile QQ, Weishi, Pitu, etc. Contributions are welcome to work in collaborative with us and make TNN a better framework.
1. 环境(environment)
RunTime DEVICE: OPENCL
2. Github版本
commit(optional):
3. 编译方式(compile method) CMake完整编译参数(full cmake arguments)
4. 编译日志(build log)
5. 详细描述bug 情况 (Describe the bug)
opencl的expand层实现,输入的参数output_dims,expand_input_dims,input_step都是shape_6d ,如下:
__kernel void Expand(GLOBAL_SIZE_1_DIMS global float* input, global float output, shape_6d output_dims, shape_6d expand_input_dims, shape_6d input_step) { int index = get_global_id(0); DEAL_NON_UNIFORM_DIM1(index); int inner_idx = index; int input_idx = 0; for(int i = INNER_DIMS - 1; i >= 0 ; i--) { int pos = ((inner_idx % output_dims.data[i]) % expand_input_dims.data[i]); inner_idx /= output_dims.data[i]; input_idx += pos input_step.data[i]; }
}
但是在opencl_expand_layer_acc.cc的OpenCLExpandLayerAcc::Reshape函数中设置参数时,fix_output_dims和fix_input_step都定义为shape_6d,但是expanded_input_dims没有保证一定是长度为6的int类型的vector,
导致运行时报错:
E/tnn: tnn::Status tnn::RunKernel(const cl::Kernel &, const std::vector &, const std::vector &, cl::CommandQueue , std::string, tnn::OpenCLProfilingData ) [File source/tnn/device/opencl/opencl_utils.cc][Line 146] OpenCL ERROR CODE : -52
E/tnn: virtual tnn::Status tnn::OpenCLLayerAcc::Forward(const std::vector<Blob > &, const std::vector<Blob > &) [File source/tnn/device/opencl/acc/opencl_layer_acc.cc][Line 137] code: 0xA001 msg: OpenCL NDRange failed
E/tnn: virtual tnn::Status tnn::DefaultNetwork::Forward() [File source/tnn/core/default_network.cc][Line 603] Forward error code: 0xA001 msg: OpenCL NDRange failed, exit
所以,当expanded_input_dims长度小于6时,需要将expanded_input_dims长度补齐为6。