提交 bdbca339 编写于 作者: C chenjiaoAngel

fix format. test=develop

上级 a81f190b
...@@ -28,7 +28,7 @@ namespace paddle { ...@@ -28,7 +28,7 @@ namespace paddle {
namespace lite { namespace lite {
namespace kernels { namespace kernels {
namespace opencl { namespace opencl {
class BoxCoderComputeImage : public KernelLite<TARGET(kOpenCL), class BoxCoderComputeImage : public KernelLite<TARGET(kOpenCL),
PRECISION(kFP16), PRECISION(kFP16),
DATALAYOUT(kImageDefault)> { DATALAYOUT(kImageDefault)> {
public: public:
...@@ -55,7 +55,8 @@ namespace opencl { ...@@ -55,7 +55,8 @@ namespace opencl {
const auto& out_dims = boxcoder_param_->proposals->dims(); const auto& out_dims = boxcoder_param_->proposals->dims();
auto image_shape = InitImageDimInfoWith(out_dims); auto image_shape = InitImageDimInfoWith(out_dims);
auto* out_buf = boxcoder_param_->proposals->mutable_data<half_t, cl::Image2D>( auto* out_buf =
boxcoder_param_->proposals->mutable_data<half_t, cl::Image2D>(
image_shape["width"], image_shape["height"]); image_shape["width"], image_shape["height"]);
#ifndef LITE_SHUTDOWN_LOG #ifndef LITE_SHUTDOWN_LOG
...@@ -90,10 +91,10 @@ namespace opencl { ...@@ -90,10 +91,10 @@ namespace opencl {
int out_H = new_dims[2]; int out_H = new_dims[2];
#ifndef LITE_SHUTDOWN_LOG #ifndef LITE_SHUTDOWN_LOG
VLOG(4) << TargetToStr(boxcoder_param_->proposals->target()); VLOG(4) << TargetToStr(boxcoder_param_->proposals->target());
VLOG(4) << "output shape: " << out_dims[0] << ", " << VLOG(4) << "output shape: " << out_dims[0] << ", "
out_dims[1] << ", " << << out_dims[1] << ", "
out_dims[2] << ", " << << out_dims[2] << ", "
out_dims[3]; << out_dims[3];
VLOG(4) << "image_shape(w,h):" << image_shape["width"] << " " VLOG(4) << "image_shape(w,h):" << image_shape["width"] << " "
<< image_shape["height"]; << image_shape["height"];
VLOG(4) << "out_C = " << out_C; VLOG(4) << "out_C = " << out_C;
......
...@@ -127,16 +127,17 @@ TEST(box_coder_image2d, compute) { ...@@ -127,16 +127,17 @@ TEST(box_coder_image2d, compute) {
context->As<OpenCLContext>().InitOnce(); context->As<OpenCLContext>().InitOnce();
kernel->SetParam(param); kernel->SetParam(param);
std::unique_ptr<KernelContext> boxcoder_context( std::unique_ptr<KernelContext> boxcoder_context(new KernelContext);
new KernelContext);
context->As<OpenCLContext>().CopySharedTo( context->As<OpenCLContext>().CopySharedTo(
&(boxcoder_context->As<OpenCLContext>())); &(boxcoder_context->As<OpenCLContext>()));
kernel->SetContext(std::move(boxcoder_context)); kernel->SetContext(std::move(boxcoder_context));
const DDim prior_box_dims = const DDim prior_box_dims =
DDim(std::vector<DDim::value_type>{1, 1, m, 4}); DDim(std::vector<DDim::value_type>{1, 1, m, 4});
const DDim prior_box_var_dims = DDim(std::vector<DDim::value_type>{1, 1, m, 4}); const DDim prior_box_var_dims =
const DDim target_box_dims = DDim(std::vector<DDim::value_type>{1, n, m, 4}); DDim(std::vector<DDim::value_type>{1, 1, m, 4});
const DDim target_box_dims =
DDim(std::vector<DDim::value_type>{1, n, m, 4});
const DDim out_dim = const DDim out_dim =
DDim(std::vector<DDim::value_type>{1, n, m, 4}); DDim(std::vector<DDim::value_type>{1, n, m, 4});
...@@ -165,35 +166,45 @@ TEST(box_coder_image2d, compute) { ...@@ -165,35 +166,45 @@ TEST(box_coder_image2d, compute) {
default_converter->InitImageDimInfoWith(prior_box_dims); default_converter->InitImageDimInfoWith(prior_box_dims);
LOG(INFO) << "prior_box_image_shape = " << prior_box_image_shape[0] << " " LOG(INFO) << "prior_box_image_shape = " << prior_box_image_shape[0] << " "
<< prior_box_image_shape[1]; << prior_box_image_shape[1];
std::vector<half_t> prior_box_image_data(prior_box_image_shape.production() * std::vector<half_t> prior_box_image_data(
4); // 4 : RGBA prior_box_image_shape.production() * 4); // 4 : RGBA
default_converter->NCHWToImage( default_converter->NCHWToImage(
prior_box_data.data(), prior_box_image_data.data(), prior_box_dims); prior_box_data.data(),
prior_box_image_data.data(),
prior_box_dims);
auto* prior_box_image = prior_box.mutable_data<half_t, cl::Image2D>( auto* prior_box_image = prior_box.mutable_data<half_t, cl::Image2D>(
prior_box_image_shape[0], prior_box_image_shape[1], prior_box_image_data.data()); prior_box_image_shape[0],
prior_box_image_shape[1],
prior_box_image_data.data());
DDim prior_box_var_image_shape = DDim prior_box_var_image_shape =
default_converter->InitImageDimInfoWith(prior_box_var_dims); default_converter->InitImageDimInfoWith(prior_box_var_dims);
LOG(INFO) << "prior_box_var_image_shape = " << prior_box_var_image_shape[0] << " " LOG(INFO) << "prior_box_var_image_shape = " << prior_box_var_image_shape[0] << " "
<< prior_box_var_image_shape[1]; << prior_box_var_image_shape[1];
std::vector<half_t> prior_box_var_image_data(prior_box_var_image_shape.production() * std::vector<half_t> prior_box_var_image_data(
4); // 4 : RGBA prior_box_var_image_shape.production() * 4); // 4 : RGBA
default_converter->NCHWToImage( default_converter->NCHWToImage(
prior_box_var_data.data(), prior_box_var_image_data.data(), prior_box_var_dims); prior_box_var_data.data(),
prior_box_var_image_data.data(),
prior_box_var_dims);
auto* prior_box_var_image = prior_box_var.mutable_data<half_t, cl::Image2D>( auto* prior_box_var_image = prior_box_var.mutable_data<half_t, cl::Image2D>(
prior_box_var_image_shape[0], prior_box_var_image_shape[1], prior_box_var_image_shape[0],
prior_box_var_image_shape[1],
prior_box_var_image_data.data()); prior_box_var_image_data.data());
DDim target_box_image_shape = DDim target_box_image_shape =
default_converter->InitImageDimInfoWith(target_box_dims); default_converter->InitImageDimInfoWith(target_box_dims);
LOG(INFO) << "target_box_image_shape = " << target_box_image_shape[0] << " " LOG(INFO) << "target_box_image_shape = " << target_box_image_shape[0] << " "
<< target_box_image_shape[1]; << target_box_image_shape[1];
std::vector<half_t> target_box_image_data(target_box_image_shape.production() * std::vector<half_t> target_box_image_data(
4); // 4 : RGBA target_box_image_shape.production() * 4); // 4 : RGBA
default_converter->NCHWToImage( default_converter->NCHWToImage(
target_box_data.data(), target_box_image_data.data(), target_box_dims); target_box_data.data(),
target_box_image_data.data(),
target_box_dims);
auto* target_box_image = target_box.mutable_data<half_t, cl::Image2D>( auto* target_box_image = target_box.mutable_data<half_t, cl::Image2D>(
target_box_image_shape[0], target_box_image_shape[1], target_box_image_shape[0],
target_box_image_shape[1],
target_box_image_data.data()); target_box_image_data.data());
DDim out_image_shape = DDim out_image_shape =
...@@ -219,9 +230,15 @@ TEST(box_coder_image2d, compute) { ...@@ -219,9 +230,15 @@ TEST(box_coder_image2d, compute) {
lite::Tensor out_ref_tensor; lite::Tensor out_ref_tensor;
out_ref_tensor.Resize(out_dim); out_ref_tensor.Resize(out_dim);
box_coder_ref(out_ref_tensor.mutable_data<float>(), prior_box_data.data(), box_coder_ref(out_ref_tensor.mutable_data<float>(),
target_box_data.data(), prior_box_var_data.data(), prior_box_data.data(),
axis, norm, code_type, target_box_dims[0], target_box_dims[1]); target_box_data.data(),
prior_box_var_data.data(),
axis,
norm,
code_type,
target_box_dims[0],
target_box_dims[1]);
const size_t cl_image2d_row_pitch{0}; const size_t cl_image2d_row_pitch{0};
const size_t cl_image2d_slice_pitch{0}; const size_t cl_image2d_slice_pitch{0};
...@@ -239,8 +256,7 @@ TEST(box_coder_image2d, compute) { ...@@ -239,8 +256,7 @@ TEST(box_coder_image2d, compute) {
out_image_data, out_data, out_image_shape, out_dim); out_image_data, out_data, out_image_shape, out_dim);
// result // result
#ifdef BOXCODER_FP16_PRINT_RESULT #ifdef BOXCODER_FP16_PRINT_RESULT
LOG(INFO) LOG(INFO) << "---- print kernel result (input -> output) ----";
<< "---- print kernel result (input -> output) ----";
for (int eidx = 0; eidx < out_dim.production(); ++eidx) { for (int eidx = 0; eidx < out_dim.production(); ++eidx) {
std::cout << target_box_data[eidx] << " -> " << out_data[eidx] std::cout << target_box_data[eidx] << " -> " << out_data[eidx]
<< std::endl; << std::endl;
...@@ -270,7 +286,7 @@ TEST(box_coder_image2d, compute) { ...@@ -270,7 +286,7 @@ TEST(box_coder_image2d, compute) {
} // code_type } // code_type
} // norm } // norm
} // m } // m
} // n } // n
#else #else
// nothing to do. // nothing to do.
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册