diff --git a/mindspore/lite/src/runtime/kernel/opencl/kernel/conv2d_transpose.cc b/mindspore/lite/src/runtime/kernel/opencl/kernel/conv2d_transpose.cc index 38f2fe375c..10c7cfcb04 100644 --- a/mindspore/lite/src/runtime/kernel/opencl/kernel/conv2d_transpose.cc +++ b/mindspore/lite/src/runtime/kernel/opencl/kernel/conv2d_transpose.cc @@ -87,7 +87,7 @@ void Conv2dTransposeOpenCLKernel::SetGlobalLocal() { int oh = out_tensors_[0]->shape()[1]; int ow = out_tensors_[0]->shape()[2]; local_size_ = {16, 1, 16}; - global_size_ = {(size_t)UP_ROUND(oh / 2, stride_h), (size_t)UP_ROUND(ow / 2, stride_w), (size_t)co4}; + global_size_ = {(size_t)UP_ROUND(UP_DIV(oh, 2), stride_h), (size_t)UP_ROUND(UP_DIV(ow, 2), stride_w), (size_t)co4}; AlignGlobalLocal(global_size_, local_size_); } diff --git a/mindspore/lite/test/ut/src/runtime/kernel/opencl/conv2d_transpose_tests.cc b/mindspore/lite/test/ut/src/runtime/kernel/opencl/conv2d_transpose_tests.cc index 65c4b05937..610e723b77 100644 --- a/mindspore/lite/test/ut/src/runtime/kernel/opencl/conv2d_transpose_tests.cc +++ b/mindspore/lite/test/ut/src/runtime/kernel/opencl/conv2d_transpose_tests.cc @@ -103,4 +103,32 @@ TEST_F(TestOpenCL_Conv2dTranspose, test1) { } } +TEST_F(TestOpenCL_Conv2dTranspose, test2) { + int n = 1; + int h = 2; + int w = 2; + int oh = 5; + int ow = 5; + int ci = 2; + int co = 1; + int kh = 3; + int kw = 3; + std::vector pad = {0, 0, 0, 0}; + float input_data[] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0}; + float weight_data[] = {0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, + 1.0, 3.0, 5.0, 7.0, 9.0, 11.0, 13.0, 15.0, 17.0}; + float bias_data[] = {0.5}; + float output_data[] = {1.5, 3.5, 8.5, 13.5, 23.5, 7.5, 9.5, 44.5, 43.5, 53.5, 18.5, 38.5, 128.5, + 106.5, 142.5, 59.5, 77.5, 180.5, 111.5, 137.5, 113.5, 131.5, 312.5, 189.5, 215.5}; + + for (auto fp16_enable : {false, true}) { + std::vector input_shape, weight_shape, bias_shape, output_shape; + auto *param = + CreateParameter(n, h, w, ci, co, kh, kw, pad, oh, ow, &input_shape, &weight_shape, &bias_shape, &output_shape); + TestMain({{input_shape, input_data, VAR}, + {weight_shape, weight_data, CONST_TENSOR}, + {bias_shape, bias_data, CONST_TENSOR}}, + {output_shape, output_data}, param, fp16_enable); + } +} } // namespace mindspore::lite::opencl::test