未验证 提交 e3caf9dd 编写于 作者: X xiebaiyuan 提交者: GitHub

use shared_ptr to wrap shared cl mem ,test=develop (#2364)

上级 1cabc418
...@@ -207,7 +207,7 @@ class CLImage { ...@@ -207,7 +207,7 @@ class CLImage {
real_image_dims_[1] >= image_dims_[1], real_image_dims_[1] >= image_dims_[1],
"real image is not enough!"); "real image is not enough!");
if (cl_image_ != src.cl_image_) { if (cl_image_ != src.cl_image_) {
cl_image_.reset(src.cl_image_.get()); cl_image_.reset(src.cl_image_.get(), CLMemDeleter());
} }
tensor_dims_ = need_dims; tensor_dims_ = need_dims;
...@@ -236,7 +236,7 @@ class CLImage { ...@@ -236,7 +236,7 @@ class CLImage {
"Tensor holds no memory. Call Tensor::mutable_data first.") "Tensor holds no memory. Call Tensor::mutable_data first.")
if (cl_image_ != src.cl_image_) { if (cl_image_ != src.cl_image_) {
cl_image_.reset(src.cl_image_.get()); cl_image_.reset(src.cl_image_.get(), CLMemDeleter());
} }
return *this; return *this;
} }
...@@ -310,7 +310,7 @@ class CLImage { ...@@ -310,7 +310,7 @@ class CLImage {
&cid, // const cl_image_desc *image_desc &cid, // const cl_image_desc *image_desc
data, // void *host_ptr data, // void *host_ptr
&err); &err);
cl_image_.reset(cl_image); cl_image_.reset(cl_image, CLMemDeleter());
if (err != CL_SUCCESS) { if (err != CL_SUCCESS) {
CL_CHECK_ERRORS(err); CL_CHECK_ERRORS(err);
PADDLE_MOBILE_THROW_EXCEPTION(" create image 2d error "); PADDLE_MOBILE_THROW_EXCEPTION(" create image 2d error ");
...@@ -318,7 +318,7 @@ class CLImage { ...@@ -318,7 +318,7 @@ class CLImage {
} }
bool initialized_ = false; bool initialized_ = false;
std::unique_ptr<_cl_mem, CLMemDeleter> cl_image_; std::shared_ptr<_cl_mem> cl_image_;
std::unique_ptr<_cl_event, CLEventDeleter> cl_event_; std::unique_ptr<_cl_event, CLEventDeleter> cl_event_;
DDim tensor_dims_; DDim tensor_dims_;
DDim image_dims_; DDim image_dims_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册