diff --git a/src/framework/cl/cl_helper.h b/src/framework/cl/cl_helper.h index 7562ab78695376d9766a72eefc2d5482283c49b7..7890ad0656cf792ef42ae1c11d761f9f038a05f6 100644 --- a/src/framework/cl/cl_helper.h +++ b/src/framework/cl/cl_helper.h @@ -47,6 +47,9 @@ 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 c1f1cd6422f76176d99a09dcef7ea42c5e5acec4..0b842fb56fa4860c759cb6438b85a07df832f66f 100644 --- a/src/framework/cl/cl_image.h +++ b/src/framework/cl/cl_image.h @@ -23,13 +23,23 @@ namespace framework { class CLImage { public: - CLImage(cl_context context, float *tensorInput, DDim ddim) : tensorDims_(ddim), context_(context) { + CLImage() = default; + + void Init(cl_context context, float *tensorInput, DDim ddim) { + } + + void Init(cl_context context, DDim ddim) { } const DDim &TensorDim(); + std::vector DefaultWorkSize() { + return {}; + } + private: + bool initialized_ = false; cl_mem cl_image_; DDim tensorDims_; cl_context context_; diff --git a/src/framework/operator.h b/src/framework/operator.h index 8908f036617a04b27744767fd456a655bdbbe9a0..56a2bc734f3d2766bdc6ad22e87ce7da32c6c39c 100644 --- a/src/framework/operator.h +++ b/src/framework/operator.h @@ -151,11 +151,9 @@ class OpKernelBase { OpKernelBase() = default; #ifdef PADDLE_MOBILE_CL - virtual void InitCLHelper(CLScope *clScope) { cl_helper_ = CLHelper(clScope); } - #endif /* diff --git a/src/operators/kernel/cl/conv_kernel.cpp b/src/operators/kernel/cl/conv_kernel.cpp index bd0dffe8af17b7e21fa83c1b78a45230ae355a58..bc8949b6b64fdb5da2fa4fb2c69dbdb75251087c 100644 --- a/src/operators/kernel/cl/conv_kernel.cpp +++ b/src/operators/kernel/cl/conv_kernel.cpp @@ -1,41 +1,42 @@ -///* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. -// -//Licensed under the Apache License, Version 2.0 (the "License"); -//you may not use this file except in compliance with the License. -//You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -//Unless required by applicable law or agreed to in writing, software -//distributed under the License is distributed on an "AS IS" BASIS, -//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -//See the License for the specific language governing permissions and -//limitations under the License. */ -// -//#ifdef CONV_OP -// -//#include "operators/kernel/conv_kernel.h" -//#include "operators/kernel/central-arm-func/conv_arm_func.h" -// -//namespace paddle_mobile { -//namespace operators { -// -//template <> -//bool ConvKernel::Init(ConvParam *param) { -// this->cl_helper_.AddKernel("conv_3x3", "conv_kernel.cl"); -// return true; -//} -// -//template <> -//void ConvKernel::Compute(const ConvParam ¶m) { -// auto kernel = this->cl_helper_.KernelAt(0); -// -// -//} -// -//template class ConvKernel; -// -//} // namespace operators -//} // namespace paddle_mobile -// -//#endif +/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + +#ifdef CONV_OP + +#include "operators/kernel/conv_kernel.h" +#include "operators/kernel/central-arm-func/conv_arm_func.h" + +namespace paddle_mobile { +namespace operators { + +template <> +bool ConvKernel::Init(ConvParam *param) { + this->cl_helper_.AddKernel("conv_3x3", "conv_kernel.cl"); + return true; +} + +template <> +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; + +} // namespace operators +} // namespace paddle_mobile + +#endif