提交 a1422f73 编写于 作者: Y Yuan Shuai 提交者: GitHub

[LITE][PROFILE] Enhance Profiler for OpenCL. test=develop (#3668)

上级 8dc7b259
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
#include "lite/kernels/opencl/image_helper.h" #include "lite/kernels/opencl/image_helper.h"
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -63,16 +67,24 @@ class ReluCompute ...@@ -63,16 +67,24 @@ class ReluCompute
auto global_work_size = cl::NDRange{count}; auto global_work_size = cl::NDRange{count};
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size, global_work_size,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
} }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
private: private:
std::string kernel_func_name_{"relu"}; std::string kernel_func_name_{"relu"};
std::string build_options_{"-DCL_DTYPE_float -DRELU"}; std::string build_options_{"-DCL_DTYPE_float -DRELU"};
...@@ -120,16 +132,24 @@ class SigmoidCompute ...@@ -120,16 +132,24 @@ class SigmoidCompute
auto global_work_size = cl::NDRange{count}; auto global_work_size = cl::NDRange{count};
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size, global_work_size,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
} }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
private: private:
std::string kernel_func_name_{"sigmoid"}; std::string kernel_func_name_{"sigmoid"};
std::string build_options_{"-DCL_DTYPE_float -DSIGMOID"}; std::string build_options_{"-DCL_DTYPE_float -DSIGMOID"};
......
...@@ -19,6 +19,10 @@ ...@@ -19,6 +19,10 @@
#include "lite/kernels/opencl/image_helper.h" #include "lite/kernels/opencl/image_helper.h"
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -148,16 +152,24 @@ class ActivationComputeImageDefault ...@@ -148,16 +152,24 @@ class ActivationComputeImageDefault
auto& context = ctx_->As<OpenCLContext>(); auto& context = ctx_->As<OpenCLContext>();
CHECK(context.cl_context() != nullptr); CHECK(context.cl_context() != nullptr);
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size_, global_work_size_,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
} }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
private: private:
param_t* act_param_{nullptr}; param_t* act_param_{nullptr};
DDim x_img_shape_ = DDim(std::vector<DDim::value_type>( DDim x_img_shape_ = DDim(std::vector<DDim::value_type>(
......
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/logging.h" #include "lite/utils/logging.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -142,13 +146,13 @@ class BilinearInterpImageCompute ...@@ -142,13 +146,13 @@ class BilinearInterpImageCompute
static_cast<cl::size_type>(default_work_size[1]), static_cast<cl::size_type>(default_work_size[1]),
static_cast<cl::size_type>(default_work_size[2])}; static_cast<cl::size_type>(default_work_size[2])};
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size, global_work_size,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
#ifdef LITE_WITH_LOG #ifdef LITE_WITH_LOG
VLOG(4) << "global_work_size:[2D]:" << global_work_size[0] << " " VLOG(4) << "global_work_size:[2D]:" << global_work_size[0] << " "
......
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/logging.h" #include "lite/utils/logging.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -121,13 +125,13 @@ class BoxCoderComputeImage : public KernelLite<TARGET(kOpenCL), ...@@ -121,13 +125,13 @@ class BoxCoderComputeImage : public KernelLite<TARGET(kOpenCL),
cl::NDRange{static_cast<cl::size_type>(default_work_size[0]), cl::NDRange{static_cast<cl::size_type>(default_work_size[0]),
static_cast<cl::size_type>(default_work_size[2])}; static_cast<cl::size_type>(default_work_size[2])};
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size, global_work_size,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
#ifdef LITE_WITH_LOG #ifdef LITE_WITH_LOG
...@@ -138,6 +142,14 @@ class BoxCoderComputeImage : public KernelLite<TARGET(kOpenCL), ...@@ -138,6 +142,14 @@ class BoxCoderComputeImage : public KernelLite<TARGET(kOpenCL),
} }
std::string doc() { return "Boxcoder using cl::Image, kFP16"; } std::string doc() { return "Boxcoder using cl::Image, kFP16"; }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
param_t* boxcoder_param_{nullptr}; param_t* boxcoder_param_{nullptr};
std::string kernel_func_name_{}; std::string kernel_func_name_{};
std::string build_options_{" -DCL_DTYPE_half"}; std::string build_options_{" -DCL_DTYPE_half"};
......
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
#include "lite/kernels/opencl/image_helper.h" #include "lite/kernels/opencl/image_helper.h"
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -124,13 +128,13 @@ class ConcatCompute : public KernelLite<TARGET(kOpenCL), ...@@ -124,13 +128,13 @@ class ConcatCompute : public KernelLite<TARGET(kOpenCL),
status = kernel.setArg(++arg_idx, total1); status = kernel.setArg(++arg_idx, total1);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size, global_work_size,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
} else { } else {
auto start = 0; auto start = 0;
...@@ -157,13 +161,13 @@ class ConcatCompute : public KernelLite<TARGET(kOpenCL), ...@@ -157,13 +161,13 @@ class ConcatCompute : public KernelLite<TARGET(kOpenCL),
status = kernel.setArg(++arg_idx, total0); status = kernel.setArg(++arg_idx, total0);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size, global_work_size,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
start += size; start += size;
} }
...@@ -172,6 +176,14 @@ class ConcatCompute : public KernelLite<TARGET(kOpenCL), ...@@ -172,6 +176,14 @@ class ConcatCompute : public KernelLite<TARGET(kOpenCL),
std::string doc() { return "Concat using cl::Buffer, kFloat"; } std::string doc() { return "Concat using cl::Buffer, kFloat"; }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
int axis_size_ = 1; int axis_size_ = 1;
int post_size_ = 1; int post_size_ = 1;
int pre_size_ = 1; int pre_size_ = 1;
......
...@@ -19,6 +19,10 @@ ...@@ -19,6 +19,10 @@
#include "lite/kernels/opencl/image_helper.h" #include "lite/kernels/opencl/image_helper.h"
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -246,6 +250,14 @@ class ConcatComputeImage : public KernelLite<TARGET(kOpenCL), ...@@ -246,6 +250,14 @@ class ConcatComputeImage : public KernelLite<TARGET(kOpenCL),
std::string doc() { return "Concat using cl::Image, kFP16"; } std::string doc() { return "Concat using cl::Image, kFP16"; }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
int axis_size_ = 1; int axis_size_ = 1;
int axis_ = 1; int axis_ = 1;
int flag_ = 1; int flag_ = 1;
......
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
#include "lite/core/tensor.h" #include "lite/core/tensor.h"
#include "lite/kernels/opencl/image_helper.h" #include "lite/kernels/opencl/image_helper.h"
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -39,6 +43,14 @@ class ConvCompute ...@@ -39,6 +43,14 @@ class ConvCompute
void Run() override; void Run() override;
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_names_[0];
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
private: private:
void GemmlikeConv2d(); void GemmlikeConv2d();
void Conv2d1x1(); void Conv2d1x1();
......
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
#include "lite/kernels/opencl/image_helper.h" #include "lite/kernels/opencl/image_helper.h"
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -119,6 +123,14 @@ class DepthwiseConv2dCompute ...@@ -119,6 +123,14 @@ class DepthwiseConv2dCompute
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
} }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
private: private:
std::string kernel_func_name_{"depthwise_conv2d"}; std::string kernel_func_name_{"depthwise_conv2d"};
std::string build_options_{"-DCL_DTYPE_float"}; std::string build_options_{"-DCL_DTYPE_float"};
......
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#include "lite/utils/string.h" #include "lite/utils/string.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -89,16 +93,24 @@ class DropoutComputeImage2D : public KernelLite<TARGET(kOpenCL), ...@@ -89,16 +93,24 @@ class DropoutComputeImage2D : public KernelLite<TARGET(kOpenCL),
static_cast<cl::size_type>(default_work_size.data()[1]), static_cast<cl::size_type>(default_work_size.data()[1]),
static_cast<cl::size_type>(default_work_size.data()[2])}; static_cast<cl::size_type>(default_work_size.data()[2])};
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size, global_work_size,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
} }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
private: private:
std::string kernel_func_name_{"dropout"}; std::string kernel_func_name_{"dropout"};
std::string build_options_{"-DCL_DTYPE_half"}; std::string build_options_{"-DCL_DTYPE_half"};
......
...@@ -19,6 +19,10 @@ ...@@ -19,6 +19,10 @@
#include "lite/kernels/opencl/image_helper.h" #include "lite/kernels/opencl/image_helper.h"
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/cp_logging.h" #include "lite/utils/cp_logging.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -38,6 +42,14 @@ class ElementwiseAddCompute ...@@ -38,6 +42,14 @@ class ElementwiseAddCompute
return "ElementwiseAdd using cl::Buffer, kFloat"; return "ElementwiseAdd using cl::Buffer, kFloat";
} }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
protected: protected:
void UpdateParams(); void UpdateParams();
......
...@@ -17,11 +17,14 @@ ...@@ -17,11 +17,14 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "lite/backends/opencl/cl_half.h" #include "lite/backends/opencl/cl_half.h"
#include "lite/backends/opencl/cl_utility.h"
#include "lite/core/kernel.h" #include "lite/core/kernel.h"
#include "lite/kernels/opencl/image_helper.h" #include "lite/kernels/opencl/image_helper.h"
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/cp_logging.h" #include "lite/utils/cp_logging.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
......
...@@ -153,13 +153,13 @@ void ElementwiseMulFloatImageCompute::Run() { ...@@ -153,13 +153,13 @@ void ElementwiseMulFloatImageCompute::Run() {
auto global_work_size = cl::NDRange{static_cast<cl::size_type>(x_img_width), auto global_work_size = cl::NDRange{static_cast<cl::size_type>(x_img_width),
static_cast<cl::size_type>(x_img_height)}; static_cast<cl::size_type>(x_img_height)};
auto status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel auto status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size, global_work_size,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
std::string time_stamp_{GetTimeStamp()}; std::string time_stamp_{GetTimeStamp()};
......
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/logging.h" #include "lite/utils/logging.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -186,13 +190,13 @@ class ElementwiseMulImageCompute ...@@ -186,13 +190,13 @@ class ElementwiseMulImageCompute
cl::NDRange{static_cast<cl::size_type>(x_img_width), cl::NDRange{static_cast<cl::size_type>(x_img_width),
static_cast<cl::size_type>(x_img_height)}; static_cast<cl::size_type>(x_img_height)};
auto status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( auto status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size, global_work_size,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
#ifdef LITE_WITH_LOG #ifdef LITE_WITH_LOG
VLOG(4) << "global_work_size:[2D]:" << x_img_width << " " << x_img_height; VLOG(4) << "global_work_size:[2D]:" << x_img_width << " " << x_img_height;
......
...@@ -138,8 +138,13 @@ void ElementwiseSubImageCompute::Run() { ...@@ -138,8 +138,13 @@ void ElementwiseSubImageCompute::Run() {
VLOG(4) << "global_work_size:[2D]:" << x_img_width << " " << x_img_height; VLOG(4) << "global_work_size:[2D]:" << x_img_width << " " << x_img_height;
#endif #endif
auto status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( auto status = EnqueueNDRangeKernel(context,
kernel, cl::NullRange, global_work_size, cl::NullRange, nullptr, nullptr); kernel,
cl::NullRange,
global_work_size,
cl::NullRange,
nullptr,
event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
} }
......
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
#include "lite/kernels/opencl/image_helper.h" #include "lite/kernels/opencl/image_helper.h"
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/cp_logging.h" #include "lite/utils/cp_logging.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -41,6 +45,14 @@ class ElementwiseSubImageCompute ...@@ -41,6 +45,14 @@ class ElementwiseSubImageCompute
return "ElementwiseSub using cl::Image2D, kFP16"; return "ElementwiseSub using cl::Image2D, kFP16";
} }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
protected: protected:
param_t* ele_param_{nullptr}; param_t* ele_param_{nullptr};
std::string kernel_func_name_{"elementwise_sub"}; std::string kernel_func_name_{"elementwise_sub"};
......
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#include "lite/utils/string.h" #include "lite/utils/string.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -124,16 +128,24 @@ class FcCompute ...@@ -124,16 +128,24 @@ class FcCompute
auto& context = ctx_->As<OpenCLContext>(); auto& context = ctx_->As<OpenCLContext>();
CHECK(context.cl_context() != nullptr); CHECK(context.cl_context() != nullptr);
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size_, global_work_size_,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
} }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
private: private:
int m_, n_, k_; int m_, n_, k_;
param_t* fc_param_{nullptr}; param_t* fc_param_{nullptr};
......
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/logging.h" #include "lite/utils/logging.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -131,16 +135,24 @@ class GridSamplerImageCompute : public KernelLite<TARGET(kOpenCL), ...@@ -131,16 +135,24 @@ class GridSamplerImageCompute : public KernelLite<TARGET(kOpenCL),
auto& context = ctx_->As<OpenCLContext>(); auto& context = ctx_->As<OpenCLContext>();
CHECK(context.cl_context() != nullptr); CHECK(context.cl_context() != nullptr);
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size_, global_work_size_,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
} }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
protected: protected:
param_t* grid_param_{nullptr}; param_t* grid_param_{nullptr};
bool first_epoch_for_reinit_{true}; bool first_epoch_for_reinit_{true};
......
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/logging.h" #include "lite/utils/logging.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -137,13 +141,13 @@ class InstanceNormImageCompute : public KernelLite<TARGET(kOpenCL), ...@@ -137,13 +141,13 @@ class InstanceNormImageCompute : public KernelLite<TARGET(kOpenCL),
status = kernel.setArg(7, *out_img); status = kernel.setArg(7, *out_img);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size, global_work_size,
local_work_size, local_work_size,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
} }
...@@ -258,17 +262,25 @@ class InstanceNormImageCompute : public KernelLite<TARGET(kOpenCL), ...@@ -258,17 +262,25 @@ class InstanceNormImageCompute : public KernelLite<TARGET(kOpenCL),
status = kernel.setArg(arg_idx++, in_w); status = kernel.setArg(arg_idx++, in_w);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size, global_work_size,
local_work_size, local_work_size,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
} }
#endif #endif
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
protected: protected:
param_t* instance_norm_param_{nullptr}; param_t* instance_norm_param_{nullptr};
std::string kernel_func_name_{"instance_norm_onnx"}; std::string kernel_func_name_{"instance_norm_onnx"};
......
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/logging.h" #include "lite/utils/logging.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -128,13 +132,13 @@ class LrnImageCompute : public KernelLite<TARGET(kOpenCL), ...@@ -128,13 +132,13 @@ class LrnImageCompute : public KernelLite<TARGET(kOpenCL),
static_cast<cl::size_type>(default_work_size[1]), static_cast<cl::size_type>(default_work_size[1]),
static_cast<cl::size_type>(default_work_size[2])}; static_cast<cl::size_type>(default_work_size[2])};
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size, global_work_size,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
#ifdef LITE_WITH_LOG #ifdef LITE_WITH_LOG
VLOG(4) << "global_work_size:[2D]:" << global_work_size[0] << " " VLOG(4) << "global_work_size:[2D]:" << global_work_size[0] << " "
...@@ -142,6 +146,14 @@ class LrnImageCompute : public KernelLite<TARGET(kOpenCL), ...@@ -142,6 +146,14 @@ class LrnImageCompute : public KernelLite<TARGET(kOpenCL),
#endif #endif
} }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
protected: protected:
param_t* lrn_param_{nullptr}; param_t* lrn_param_{nullptr};
int n_{5}; int n_{5};
......
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#include "lite/utils/string.h" #include "lite/utils/string.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -92,16 +96,24 @@ class MulCompute ...@@ -92,16 +96,24 @@ class MulCompute
auto global_work_size = cl::NDRange{static_cast<size_t>((m_ + 3) / 4), auto global_work_size = cl::NDRange{static_cast<size_t>((m_ + 3) / 4),
static_cast<size_t>((n_ + 3) / 4)}; static_cast<size_t>((n_ + 3) / 4)};
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size, global_work_size,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
} }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
private: private:
int m_, n_, k_; int m_, n_, k_;
std::string kernel_func_name_{"mat_mul"}; std::string kernel_func_name_{"mat_mul"};
......
...@@ -19,6 +19,10 @@ ...@@ -19,6 +19,10 @@
#include "lite/kernels/opencl/image_helper.h" #include "lite/kernels/opencl/image_helper.h"
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -110,16 +114,24 @@ class NearestInterpComputeImageDefault ...@@ -110,16 +114,24 @@ class NearestInterpComputeImageDefault
static_cast<cl::size_type>(default_work_size.data()[1]), static_cast<cl::size_type>(default_work_size.data()[1]),
static_cast<cl::size_type>(default_work_size.data()[2])}; static_cast<cl::size_type>(default_work_size.data()[2])};
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size, global_work_size,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
} }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
private: private:
std::string kernel_func_name_{"nearest_interp"}; std::string kernel_func_name_{"nearest_interp"};
std::string build_options_{" -DCL_DTYPE_half"}; std::string build_options_{" -DCL_DTYPE_half"};
......
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/logging.h" #include "lite/utils/logging.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -142,13 +146,13 @@ class Pad2dCompute : public KernelLite<TARGET(kOpenCL), ...@@ -142,13 +146,13 @@ class Pad2dCompute : public KernelLite<TARGET(kOpenCL),
static_cast<cl::size_type>(default_work_size[1]), static_cast<cl::size_type>(default_work_size[1]),
static_cast<cl::size_type>(default_work_size[2])}; static_cast<cl::size_type>(default_work_size[2])};
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size, global_work_size,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
#ifdef LITE_WITH_LOG #ifdef LITE_WITH_LOG
VLOG(4) << "global_work_size:[2D]:" << global_work_size[0] << " " VLOG(4) << "global_work_size:[2D]:" << global_work_size[0] << " "
...@@ -156,6 +160,14 @@ class Pad2dCompute : public KernelLite<TARGET(kOpenCL), ...@@ -156,6 +160,14 @@ class Pad2dCompute : public KernelLite<TARGET(kOpenCL),
#endif #endif
} }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
protected: protected:
param_t* pad2d_param_{nullptr}; param_t* pad2d_param_{nullptr};
std::string kernel_func_name_{}; std::string kernel_func_name_{};
......
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#include "lite/utils/string.h" #include "lite/utils/string.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -106,16 +110,24 @@ class PoolCompute ...@@ -106,16 +110,24 @@ class PoolCompute
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
auto global_work_size = cl::NDRange(static_cast<size_t>(numel)); auto global_work_size = cl::NDRange(static_cast<size_t>(numel));
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size, global_work_size,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
} }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
private: private:
std::string kernel_func_name_{"pool_"}; std::string kernel_func_name_{"pool_"};
std::string build_options_{"-DCL_DTYPE_float"}; std::string build_options_{"-DCL_DTYPE_float"};
......
...@@ -16,13 +16,16 @@ ...@@ -16,13 +16,16 @@
#include "lite/backends/opencl/cl_half.h" #include "lite/backends/opencl/cl_half.h"
#include "lite/backends/opencl/cl_include.h" #include "lite/backends/opencl/cl_include.h"
#include "lite/backends/opencl/cl_utility.h"
#include "lite/core/kernel.h" #include "lite/core/kernel.h"
#include "lite/core/op_registry.h" #include "lite/core/op_registry.h"
#include "lite/kernels/opencl/image_helper.h" #include "lite/kernels/opencl/image_helper.h"
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#include "lite/utils/string.h" #include "lite/utils/string.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
#undef LITE_WITH_LOG #undef LITE_WITH_LOG
......
...@@ -14,13 +14,16 @@ ...@@ -14,13 +14,16 @@
#include "lite/backends/opencl/cl_half.h" #include "lite/backends/opencl/cl_half.h"
#include "lite/backends/opencl/cl_include.h" #include "lite/backends/opencl/cl_include.h"
#include "lite/backends/opencl/cl_utility.h"
#include "lite/core/kernel.h" #include "lite/core/kernel.h"
#include "lite/core/op_registry.h" #include "lite/core/op_registry.h"
#include "lite/kernels/opencl/image_helper.h" #include "lite/kernels/opencl/image_helper.h"
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/logging.h" #include "lite/utils/logging.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
#undef LITE_WITH_LOG #undef LITE_WITH_LOG
......
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#include "lite/utils/string.h" #include "lite/utils/string.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -93,16 +97,24 @@ class ScaleComputeImage2D : public KernelLite<TARGET(kOpenCL), ...@@ -93,16 +97,24 @@ class ScaleComputeImage2D : public KernelLite<TARGET(kOpenCL),
status = kernel.setArg(3, bias); status = kernel.setArg(3, bias);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size_, global_work_size_,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
} }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
private: private:
std::string kernel_func_name_{"scale"}; std::string kernel_func_name_{"scale"};
std::string build_options_{"-DCL_DTYPE_half"}; std::string build_options_{"-DCL_DTYPE_half"};
......
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
#include "lite/operators/op_params.h" #include "lite/operators/op_params.h"
#include "lite/utils/replace_stl/stream.h" #include "lite/utils/replace_stl/stream.h"
#include "lite/utils/string.h" #include "lite/utils/string.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/profiler.h"
#endif
#include "lite/backends/opencl/cl_utility.h"
namespace paddle { namespace paddle {
namespace lite { namespace lite {
...@@ -96,16 +100,24 @@ class SliceComputeImage2D : public KernelLite<TARGET(kOpenCL), ...@@ -96,16 +100,24 @@ class SliceComputeImage2D : public KernelLite<TARGET(kOpenCL),
static_cast<cl::size_type>(default_work_size.data()[1]), static_cast<cl::size_type>(default_work_size.data()[1]),
static_cast<cl::size_type>(default_work_size.data()[2])}; static_cast<cl::size_type>(default_work_size.data()[2])};
status = context.cl_context()->GetCommandQueue().enqueueNDRangeKernel( status = EnqueueNDRangeKernel(context,
kernel, kernel,
cl::NullRange, cl::NullRange,
global_work_size, global_work_size,
cl::NullRange, cl::NullRange,
nullptr, nullptr,
nullptr); event_);
CL_CHECK_FATAL(status); CL_CHECK_FATAL(status);
} }
#ifdef LITE_WITH_PROFILE
void SetProfileRuntimeKernelInfo(paddle::lite::profile::OpCharacter* ch) {
ch->kernel_func_name = kernel_func_name_;
ch->cl_event =
event_; // `event_` defined in `kernel.h`, valid after kernel::Run
}
#endif
private: private:
std::string kernel_func_name_{"slice"}; std::string kernel_func_name_{"slice"};
std::string build_options_{"-DCL_DTYPE_half"}; std::string build_options_{"-DCL_DTYPE_half"};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册