From 78de085a0ec75188c7a600b96f6d9e9259104398 Mon Sep 17 00:00:00 2001 From: liuruilong Date: Sat, 29 Sep 2018 14:54:56 +0800 Subject: [PATCH] use image in param --- src/framework/cl/cl_helper.h | 3 --- src/framework/cl/cl_image.h | 18 ++++++++++-------- src/io/executor.cpp | 2 ++ src/operators/kernel/cl/conv_kernel.cpp | 1 - src/operators/op_param.h | 14 ++++++++++++++ 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/framework/cl/cl_helper.h b/src/framework/cl/cl_helper.h index 7890ad0656..7562ab7869 100644 --- a/src/framework/cl/cl_helper.h +++ b/src/framework/cl/cl_helper.h @@ -47,9 +47,6 @@ class CLHelper { return scope_->Context(); } - - - private: CLScope *scope_; std::vector> kernels; diff --git a/src/framework/cl/cl_image.h b/src/framework/cl/cl_image.h index 0b842fb56f..5bcd09984f 100644 --- a/src/framework/cl/cl_image.h +++ b/src/framework/cl/cl_image.h @@ -32,7 +32,9 @@ class CLImage { } - const DDim &TensorDim(); + const DDim &TensorDim() { + return tensorDims_; + } std::vector DefaultWorkSize() { return {}; @@ -45,13 +47,13 @@ class CLImage { cl_context context_; }; -void TensorToCLImage(Tensor *tensor, CLImage *image) { - -} - -void CLImageToTensor(CLImage *image, Tensor *tensor) { - -} +//void TensorToCLImage(Tensor *tensor, CLImage *image) { +// +//} +// +//void CLImageToTensor(CLImage *image, Tensor *tensor) { +// +//} } } \ No newline at end of file diff --git a/src/io/executor.cpp b/src/io/executor.cpp index f94ae37e51..9803a35ede 100644 --- a/src/io/executor.cpp +++ b/src/io/executor.cpp @@ -16,6 +16,7 @@ limitations under the License. */ #include #include #include +#include #include "common/enforce.h" #include "common/log.h" #include "framework/framework.pb-c.h" @@ -233,6 +234,7 @@ void Executor::InitMemory() { Get_binary_data(program_.model_path + "/" + var_desc->Name()); char *data = origin_data; LoadMemory(*var_desc, tensor, &data); + delete origin_data; } else { if (var_desc->Type() == framework::VARTYPE_TYPE_LOD_TENSOR) { diff --git a/src/operators/kernel/cl/conv_kernel.cpp b/src/operators/kernel/cl/conv_kernel.cpp index bc8949b6b6..451f96447e 100644 --- a/src/operators/kernel/cl/conv_kernel.cpp +++ b/src/operators/kernel/cl/conv_kernel.cpp @@ -31,7 +31,6 @@ void ConvKernel::Compute(const ConvParam ¶m) { auto kernel = this->cl_helper_.KernelAt(0); size_t global_work_size[3] = {1, 2, 3}; clEnqueueNDRangeKernel(this->cl_helper_.CLCommandQueue(), kernel, 3, NULL, global_work_size, NULL, 0, NULL, NULL); - } template class ConvKernel; diff --git a/src/operators/op_param.h b/src/operators/op_param.h index 5b53743b75..ec5904a822 100644 --- a/src/operators/op_param.h +++ b/src/operators/op_param.h @@ -27,6 +27,10 @@ limitations under the License. */ #include "fpga/api.h" #endif +#ifdef PADDLE_MOBILE_CL +#include "framework/cl/cl_image.h" +#endif + namespace paddle_mobile { namespace operators { @@ -71,6 +75,16 @@ struct DtypeTensorTrait { typedef framework::Tensor rtype; }; + +template <> +struct DtypeTensorTrait { + // This is the type we obtained in variable. + typedef framework::CLImage gtype; + // This type will be the parent class type + // or the same type. + typedef framework::CLImage rtype; +}; + class OpParam { protected: template -- GitLab