From 1429e04b7610361a0fd7dc67a8fee0d24d3571be Mon Sep 17 00:00:00 2001 From: wawltor Date: Fri, 4 Mar 2022 09:42:54 +0000 Subject: [PATCH] fix some format problem --- .../phi/kernels/cpu/graph_send_recv_funcs.h | 13 ++-- .../cpu/graph_send_recv_grad_kernel.cc | 62 +++++++++---------- .../phi/kernels/cpu/graph_send_recv_kernel.cc | 47 +++++++------- 3 files changed, 59 insertions(+), 63 deletions(-) diff --git a/paddle/phi/kernels/cpu/graph_send_recv_funcs.h b/paddle/phi/kernels/cpu/graph_send_recv_funcs.h index 726b079a6d3f1..df6d9c87be0ed 100644 --- a/paddle/phi/kernels/cpu/graph_send_recv_funcs.h +++ b/paddle/phi/kernels/cpu/graph_send_recv_funcs.h @@ -16,7 +16,6 @@ #include #include -#include "paddle/fluid/operators/eigen/eigen_function.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/hostdevice.h" @@ -66,12 +65,12 @@ struct GraphSendRecvMaxFunctor { }; template -void elementwise_inner_operation(const DenseTensor& src, - DenseTensor* dst, - const IndexT& src_index, - const IndexT& dst_index, - const bool& first_flag, - Functor functor) { +void ElementwiseInnerOperation(const DenseTensor& src, + DenseTensor* dst, + const IndexT& src_index, + const IndexT& dst_index, + const bool& first_flag, + Functor functor) { auto src_slice = src.Slice(src_index, src_index + 1); auto dst_slice = dst->Slice(dst_index, dst_index + 1); diff --git a/paddle/phi/kernels/cpu/graph_send_recv_grad_kernel.cc b/paddle/phi/kernels/cpu/graph_send_recv_grad_kernel.cc index 204761923c126..8538461b1b83b 100644 --- a/paddle/phi/kernels/cpu/graph_send_recv_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/graph_send_recv_grad_kernel.cc @@ -23,22 +23,22 @@ namespace phi { template -void graph_send_recv_cpu_for_loop_grad(const int& input_size, - const int& index_size, - const IndexT* s_index, - const IndexT* d_index, - const DenseTensor& src, - DenseTensor* dst, - const std::string& pool_type, - const int* dst_count = nullptr, - const DenseTensor* input = nullptr, - const DenseTensor* output = nullptr) { +void GraphSendRecvCpuGradLoop(const int& input_size, + const int& index_size, + const IndexT* s_index, + const IndexT* d_index, + const DenseTensor& src, + DenseTensor* dst, + const std::string& pool_type, + const int* dst_count = nullptr, + const DenseTensor* input = nullptr, + const DenseTensor* output = nullptr) { if (pool_type == "SUM") { Functor functor; for (int i = 0; i < index_size; ++i) { const IndexT& src_idx = s_index[i]; const IndexT& dst_idx = d_index[i]; - elementwise_inner_operation( + ElementwiseInnerOperation( src, dst, src_idx, dst_idx, false, functor); } } else if (pool_type == "MEAN") { @@ -96,33 +96,31 @@ void GraphSendRecvGradOpKernelLaunchHelper( const IndexT* d_index = dst_index.data(); if (pool_type == "SUM") { - graph_send_recv_cpu_for_loop_grad>( + GraphSendRecvCpuGradLoop>( src_dims[0], index_size, d_index, s_index, out_grad, x_grad, pool_type); } else if (pool_type == "MEAN") { const int* s_count = dst_count->data(); // Functor not used here. - graph_send_recv_cpu_for_loop_grad>( - src_dims[0], - index_size, - d_index, - s_index, - out_grad, - x_grad, - pool_type, - s_count); + GraphSendRecvCpuGradLoop>(src_dims[0], + index_size, + d_index, + s_index, + out_grad, + x_grad, + pool_type, + s_count); } else if (pool_type == "MIN" || pool_type == "MAX") { // Functor not used here. - graph_send_recv_cpu_for_loop_grad>( - src_dims[0], - index_size, - d_index, - s_index, - out_grad, - x_grad, - pool_type, - nullptr, - x, - out); + GraphSendRecvCpuGradLoop>(src_dims[0], + index_size, + d_index, + s_index, + out_grad, + x_grad, + pool_type, + nullptr, + x, + out); } } diff --git a/paddle/phi/kernels/cpu/graph_send_recv_kernel.cc b/paddle/phi/kernels/cpu/graph_send_recv_kernel.cc index a9786c1d1c5d7..fecbd4b1d7aa0 100644 --- a/paddle/phi/kernels/cpu/graph_send_recv_kernel.cc +++ b/paddle/phi/kernels/cpu/graph_send_recv_kernel.cc @@ -26,27 +26,27 @@ namespace phi { template -void graph_send_recv_cpu_for_loop(const int& input_size, - const int& index_size, - const IndexT* s_index, - const IndexT* d_index, - const DenseTensor& src, - DenseTensor* dst, - const std::string& pool_type, - int* dst_count = nullptr) { +void GraphSendRecvCpuLoop(const int& input_size, + const int& index_size, + const IndexT* s_index, + const IndexT* d_index, + const DenseTensor& src, + DenseTensor* dst, + const std::string& pool_type, + int* dst_count = nullptr) { Functor functor; if (pool_type == "SUM") { for (int i = 0; i < index_size; ++i) { const IndexT& src_idx = s_index[i]; const IndexT& dst_idx = d_index[i]; - elementwise_inner_operation( + ElementwiseInnerOperation( src, dst, src_idx, dst_idx, false, functor); } } else if (pool_type == "MEAN") { for (int i = 0; i < index_size; ++i) { const IndexT& src_idx = s_index[i]; const IndexT& dst_idx = d_index[i]; - elementwise_inner_operation( + ElementwiseInnerOperation( src, dst, src_idx, dst_idx, false, functor); } for (int i = 0; i < index_size; ++i) { @@ -66,11 +66,11 @@ void graph_send_recv_cpu_for_loop(const int& input_size, const IndexT& dst_idx = d_index[i]; bool in_set = existed_dst.find(dst_idx) != existed_dst.end(); if (!in_set) { - elementwise_inner_operation( + ElementwiseInnerOperation( src, dst, src_idx, dst_idx, true, functor); existed_dst.emplace(dst_idx); } else { - elementwise_inner_operation( + ElementwiseInnerOperation( src, dst, src_idx, dst_idx, false, functor); } } @@ -100,27 +100,26 @@ void GraphSendRecvOpKernelLaunchHelper(const Context& ctx, const IndexT* s_index = src_index.data(); const IndexT* d_index = dst_index.data(); if (pool_type == "SUM") { - graph_send_recv_cpu_for_loop>( + GraphSendRecvCpuLoop>( src_dims[0], index_size, s_index, d_index, x, out, pool_type); } else if (pool_type == "MIN") { - graph_send_recv_cpu_for_loop>( + GraphSendRecvCpuLoop>( src_dims[0], index_size, s_index, d_index, x, out, pool_type); } else if (pool_type == "MAX") { - graph_send_recv_cpu_for_loop>( + GraphSendRecvCpuLoop>( src_dims[0], index_size, s_index, d_index, x, out, pool_type); } else if (pool_type == "MEAN") { ctx.template Alloc(dst_count); int* p_dst_count = dst_count->data(); memset(p_dst_count, 0, src_dims[0] * sizeof(int)); - graph_send_recv_cpu_for_loop>( - src_dims[0], - index_size, - s_index, - d_index, - x, - out, - pool_type, - p_dst_count); + GraphSendRecvCpuLoop>(src_dims[0], + index_size, + s_index, + d_index, + x, + out, + pool_type, + p_dst_count); } }