TNN icon indicating copy to clipboard operation
TNN copied to clipboard

opencl的expand实现报错

Open nicheng0019 opened this issue 1 year ago • 1 comments

1. 环境(environment)

  • Build OS and Version: Mac/Ubuntu/Centos/Windows
  • RunTime OS Version: Linux/Android/IOS
  • RunTime DEVICE: OPENCL

2. Github版本

  • branch:master
  • commit(optional):

3. 编译方式(compile method) CMake完整编译参数(full cmake arguments)

4. 编译日志(build log)

将日志粘贴在这里
Paste log here or pastebin

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]; }

output[index] = input[input_idx];

}

但是在opencl_expand_layer_acc.cc的OpenCLExpandLayerAcc::Reshape函数中设置参数时,fix_output_dims和fix_input_step都定义为shape_6d,但是expanded_input_dims没有保证一定是长度为6的int类型的vector,

image

导致运行时报错:

E/tnn: tnn::Status tnn::RunKernel(const cl::Kernel &, const std::vector<uint32_t> &, const std::vector<uint32_t> &, 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。

nicheng0019 avatar Mar 23 '23 03:03 nicheng0019

666老铁

TD-wzw avatar May 24 '23 06:05 TD-wzw