提交 9b772eeb 编写于 作者: R Ray Liu 提交者: GitHub

Merge pull request #1028 from codeWorm2015/opencl

complie success
......@@ -72,6 +72,10 @@ endif()
if (GPU_CL)
add_definitions(-DPADDLE_MOBILE_CL)
# opencl version
add_definitions(-DCL_TARGET_OPENCL_VERSION=220)
link_libraries(/Users/liuruilong/GitHub/paddle-mobile/third_party/opencl/libOpenCL.so)
include_directories(third_party/opencl/OpenCL-Headers)
else()
......@@ -82,7 +86,6 @@ else()
file(GLOB_RECURSE _tmp_list_h src/framework/cl/*.h)
foreach(f ${_tmp_list_h})
message(STATUS ${f})
list(REMOVE_ITEM PADDLE_MOBILE_H ${f})
endforeach()
endif()
......
......@@ -115,7 +115,11 @@ class OperatorWithKernel : public OperatorBase<Dtype> {
const VariableNameMap &outputs, const AttributeMap &attrs,
std::shared_ptr<Scope> scope)
: OperatorBase<Dtype>(type, inputs, outputs, attrs, scope),
param_(inputs, outputs, attrs, *scope) {}
param_(inputs, outputs, attrs, *scope) {
#ifdef PADDLE_MOBILE_CL
kernel_.InitCLHelper(scope->GetCLScpoe());
#endif
}
virtual void RunImpl() { this->kernel_.Compute(this->param_); }
......@@ -126,6 +130,8 @@ class OperatorWithKernel : public OperatorBase<Dtype> {
// DLOG << i.first;
// DLOG << i.second;
// }
PADDLE_MOBILE_ENFORCE(kernel_.Init(&param_), " %s kernel init failed",
this->type_.c_str());
}
......@@ -141,10 +147,16 @@ class OperatorWithKernel : public OperatorBase<Dtype> {
template <typename Dtype, typename P>
class OpKernelBase {
public:
OpKernelBase() = default;
// OpKernelBase(CLScope *clscope): cl_helper_(CLHelper(clscope)) {
// }
#ifdef PADDLE_MOBILE_CL
virtual void InitCLHelper(CLScope *clScope) {
cl_helper_ = CLHelper(clScope);
}
#endif
/*
* @b 所有kernel 需实现 Compute 方法
......@@ -163,7 +175,9 @@ class OpKernelBase {
virtual ~OpKernelBase() = default;
protected:
// CLHelper cl_helper_;
#ifdef PADDLE_MOBILE_CL
CLHelper cl_helper_;
#endif
private:
#ifdef PADDLE_MOBILE_MALI_GPU
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册