From 2b71b0577e2ed769198bbc360978e52ee80227dd Mon Sep 17 00:00:00 2001 From: hanhuifeng2020 Date: Wed, 2 Nov 2022 18:03:06 +0800 Subject: [PATCH] fix bug of use of CheckTensorSize in new NativeGpuKernelMod --- .../ccsrc/plugin/device/gpu/kernel/nn/conv2d_gpu_kernel.cc | 4 +++- .../device/gpu/kernel/nn/conv2d_grad_filter_gpu_kernel.cc | 4 +++- .../device/gpu/kernel/nn/conv2d_grad_input_gpu_kernel.cc | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mindspore/ccsrc/plugin/device/gpu/kernel/nn/conv2d_gpu_kernel.cc b/mindspore/ccsrc/plugin/device/gpu/kernel/nn/conv2d_gpu_kernel.cc index 9f700fc8ee9..0cab46dec8f 100644 --- a/mindspore/ccsrc/plugin/device/gpu/kernel/nn/conv2d_gpu_kernel.cc +++ b/mindspore/ccsrc/plugin/device/gpu/kernel/nn/conv2d_gpu_kernel.cc @@ -124,7 +124,9 @@ int Conv2dFwdGpuKernelMod::Resize(const BaseOperatorPtr &base_operator, const st if (is_null_input_) { return KRET_OK; } - CheckTensorSize({in_shape, filter_shape, output_shape}); + if (!CheckTensorSize({in_shape, filter_shape, output_shape})) { + return KRET_RESIZE_FAILED; + } std::vector pad_list; // The pad_list is computed in infer shape auto pad_list_me = GetValue>(base_operator->GetAttr("pad_list")); diff --git a/mindspore/ccsrc/plugin/device/gpu/kernel/nn/conv2d_grad_filter_gpu_kernel.cc b/mindspore/ccsrc/plugin/device/gpu/kernel/nn/conv2d_grad_filter_gpu_kernel.cc index 8c45aeb1956..d236249977c 100644 --- a/mindspore/ccsrc/plugin/device/gpu/kernel/nn/conv2d_grad_filter_gpu_kernel.cc +++ b/mindspore/ccsrc/plugin/device/gpu/kernel/nn/conv2d_grad_filter_gpu_kernel.cc @@ -315,7 +315,9 @@ int ConvGradFilterBkwGpuKernelMod::Resize(const BaseOperatorPtr &base_operator, filter_shape_ = value_res.value(); } auto filter_shape = filter_shape_; - CheckTensorSize({in_shape, dy_shape, filter_shape}); + if (!CheckTensorSize({in_shape, dy_shape, filter_shape})) { + return KRET_RESIZE_FAILED; + } int h_index = k2DHeightIndexNCHW; int w_index = k2DHeightIndexNCHW + 1; if (data_format_ == kOpFormat_NHWC) { diff --git a/mindspore/ccsrc/plugin/device/gpu/kernel/nn/conv2d_grad_input_gpu_kernel.cc b/mindspore/ccsrc/plugin/device/gpu/kernel/nn/conv2d_grad_input_gpu_kernel.cc index e17ca1e7514..38778582e85 100644 --- a/mindspore/ccsrc/plugin/device/gpu/kernel/nn/conv2d_grad_input_gpu_kernel.cc +++ b/mindspore/ccsrc/plugin/device/gpu/kernel/nn/conv2d_grad_input_gpu_kernel.cc @@ -314,7 +314,9 @@ int ConvGradInputBkwGpuKernelMod::Resize(const BaseOperatorPtr &base_operator, ShapeNCHW2NHWC(&input_shape); } } - CheckTensorSize({input_shape, dy_shape, filter_shape}); + if (!CheckTensorSize({input_shape, dy_shape, filter_shape})) { + return KRET_RESIZE_FAILED; + } SetNCHW(input_shape, &n_, &c_, &old_height_, &old_width_, data_format_); Set4DDesc(dy_shape, input_shape, filter_shape); auto pad_list = pad_list_;