From e0a319aeb11934584ebf1acd257a720f25de557b Mon Sep 17 00:00:00 2001 From: xiebaiyuan Date: Sun, 12 Apr 2020 15:05:42 +0800 Subject: [PATCH] [LITE][OPENCL][Image] use unique_ptr to wrap filter and bias in conv image compute , test=develop --- lite/kernels/opencl/activation_image_compute.cc | 8 ++------ lite/kernels/opencl/fc_buffer_compute.cc | 3 +-- lite/kernels/opencl/scale_image_compute.cc | 3 +-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lite/kernels/opencl/activation_image_compute.cc b/lite/kernels/opencl/activation_image_compute.cc index de552fe935..6fe7e95ba2 100644 --- a/lite/kernels/opencl/activation_image_compute.cc +++ b/lite/kernels/opencl/activation_image_compute.cc @@ -81,10 +81,6 @@ class ActivationComputeImageDefault "image/activation_kernel.cl", build_options_, time_stamp_); - - STL::stringstream kernel_key; - kernel_key << kernel_func_name_ << build_options_ << time_stamp_; - auto kernel = context.cl_context()->GetKernel(kernel_key.str()); } void ReInitWhenNeeded() override { @@ -119,10 +115,11 @@ class ActivationComputeImageDefault out_img_shape_[0], out_img_shape_[1]); auto& context = ctx_->As(); CHECK(context.cl_context() != nullptr); + std::stringstream kernel_key; kernel_key << kernel_func_name_ << build_options_ << time_stamp_; auto kernel = context.cl_context()->GetKernel(kernel_key.str()); - ; + cl_int status; status = kernel->setArg(0, *x_img); CL_CHECK_FATAL(status); @@ -170,7 +167,6 @@ class ActivationComputeImageDefault std::string kernel_func_name_{}; float threshold_{6.f}; float scale_{1.f}; - cl::Kernel kernel; bool first_epoch_for_reinit_{true}; cl::NDRange global_work_size_ = cl::NDRange{ static_cast(1), static_cast(1), static_cast(1)}; diff --git a/lite/kernels/opencl/fc_buffer_compute.cc b/lite/kernels/opencl/fc_buffer_compute.cc index 3934994619..87d3f34be5 100644 --- a/lite/kernels/opencl/fc_buffer_compute.cc +++ b/lite/kernels/opencl/fc_buffer_compute.cc @@ -108,7 +108,6 @@ class FcCompute std::stringstream kernel_key; kernel_key << kernel_func_name_ << build_options_ << time_stamp_; auto kernel = context.cl_context()->GetKernel(kernel_key.str()); - ; cl_int status; status = kernel->setArg(0, *x_buf); CL_CHECK_FATAL(status); @@ -145,7 +144,7 @@ class FcCompute bool first_epoch_for_reinit_{true}; DDim last_x_dims_; cl::NDRange global_work_size_; - cl::Kernel kernel; + std::shared_ptr event_{new cl::Event}; }; diff --git a/lite/kernels/opencl/scale_image_compute.cc b/lite/kernels/opencl/scale_image_compute.cc index 4ca741755a..56c8373f17 100644 --- a/lite/kernels/opencl/scale_image_compute.cc +++ b/lite/kernels/opencl/scale_image_compute.cc @@ -85,7 +85,6 @@ class ScaleComputeImage2D : public KernelLiteGetKernel(kernel_key.str()); - ; cl_int status; status = kernel->setArg(0, *x_img); CL_CHECK_FATAL(status); @@ -114,7 +113,7 @@ class ScaleComputeImage2D : public KernelLite event_{new cl::Event}; param_t* scale_param_{nullptr}; - cl::Kernel kernel; + bool first_epoch_for_reinit_{true}; DDim last_x_dims_; DDim out_img_shape_ = DDim(std::vector( -- GitLab