diff --git a/paddle/fluid/distributed/ps/service/communicator/communicator.h b/paddle/fluid/distributed/ps/service/communicator/communicator.h index b8832964415997524ee080ee9d28f5023bc6b4e8..04ed31f67d2584b310c59947c844842a76b6b23a 100644 --- a/paddle/fluid/distributed/ps/service/communicator/communicator.h +++ b/paddle/fluid/distributed/ps/service/communicator/communicator.h @@ -154,7 +154,7 @@ class BlockingQueue { template -using EigenVector = framework::EigenVector; +using EigenVector = phi::EigenVector; template inline void MergeVars(const std::string &var_name, diff --git a/paddle/fluid/imperative/gradient_accumulator.cc b/paddle/fluid/imperative/gradient_accumulator.cc index f60d8ef51346a41829adb4f421d2057ea6c400b8..188617dd31037a726b6e53d1093b2b0d748a4cca 100644 --- a/paddle/fluid/imperative/gradient_accumulator.cc +++ b/paddle/fluid/imperative/gradient_accumulator.cc @@ -206,13 +206,13 @@ void TensorAdd(const VarType& src, VarType* dst) { #endif } -#define TENSOR_ADD_EIGEN(T) \ - auto cpu_ctx = static_cast( \ - platform::DeviceContextPool::Instance().Get(place)); \ - auto in = paddle::framework::EigenVector::Flatten(src_tensor); \ - auto out = paddle::framework::EigenVector::Flatten(*dst_tensor); \ - auto& p = *(cpu_ctx->eigen_device()); \ - out.device(p) = out + in; \ +#define TENSOR_ADD_EIGEN(T) \ + auto cpu_ctx = static_cast( \ + platform::DeviceContextPool::Instance().Get(place)); \ + auto in = phi::EigenVector::Flatten(src_tensor); \ + auto out = phi::EigenVector::Flatten(*dst_tensor); \ + auto& p = *(cpu_ctx->eigen_device()); \ + out.device(p) = out + in; \ return; if (platform::is_cpu_place(place)) { diff --git a/paddle/fluid/operators/detection/anchor_generator_op.h b/paddle/fluid/operators/detection/anchor_generator_op.h index aaebcef3c901f36cc0ed41feb4f4316b3258aeeb..6582ddac1411444dfc6100f4fa17666d924393fe 100644 --- a/paddle/fluid/operators/detection/anchor_generator_op.h +++ b/paddle/fluid/operators/detection/anchor_generator_op.h @@ -70,7 +70,7 @@ class AnchorGeneratorOpKernel : public framework::OpKernel { anchors->mutable_data(ctx.GetPlace()); vars->mutable_data(ctx.GetPlace()); - auto e_anchors = framework::EigenTensor::From(*anchors); + auto e_anchors = phi::EigenTensor::From(*anchors); for (int h_idx = 0; h_idx < feature_height; ++h_idx) { for (int w_idx = 0; w_idx < feature_width; ++w_idx) { T x_ctr = (w_idx * stride_width) + offset * (stride_width - 1); @@ -110,7 +110,7 @@ class AnchorGeneratorOpKernel : public framework::OpKernel { var_t.mutable_data( phi::make_ddim({1, static_cast(variances.size())}), ctx.GetPlace()); - auto var_et = framework::EigenTensor::From(var_t); + auto var_et = phi::EigenTensor::From(var_t); for (size_t i = 0; i < variances.size(); ++i) { var_et(0, i) = variances[i]; } @@ -119,7 +119,7 @@ class AnchorGeneratorOpKernel : public framework::OpKernel { auto var_dim = vars->dims(); vars->Resize({anchor_num, static_cast(variances.size())}); - auto e_vars = framework::EigenMatrix::From(*vars); + auto e_vars = phi::EigenMatrix::From(*vars); e_vars = var_et.broadcast(Eigen::DSizes(anchor_num, 1)); vars->Resize(var_dim); diff --git a/paddle/fluid/operators/detection/density_prior_box_op.h b/paddle/fluid/operators/detection/density_prior_box_op.h index f3e3cb0ffb6ca8f05c8be980cafc1c046bc416c3..237626fee4c1bdbf0db953ace0ba3fce08babf17 100644 --- a/paddle/fluid/operators/detection/density_prior_box_op.h +++ b/paddle/fluid/operators/detection/density_prior_box_op.h @@ -66,7 +66,7 @@ class DensityPriorBoxOpKernel : public framework::OpKernel { auto box_dim = vars->dims(); boxes->Resize({feature_height, feature_width, num_priors, 4}); - auto e_boxes = framework::EigenTensor::From(*boxes).setConstant(0.0); + auto e_boxes = phi::EigenTensor::From(*boxes).setConstant(0.0); int step_average = static_cast((step_width + step_height) * 0.5); std::vector sqrt_fixed_ratios; @@ -126,7 +126,7 @@ class DensityPriorBoxOpKernel : public framework::OpKernel { phi::make_ddim({1, static_cast(variances.size())}), ctx.GetPlace()); - auto var_et = framework::EigenTensor::From(var_t); + auto var_et = phi::EigenTensor::From(var_t); for (size_t i = 0; i < variances.size(); ++i) { var_et(0, i) = variances[i]; @@ -136,7 +136,7 @@ class DensityPriorBoxOpKernel : public framework::OpKernel { auto var_dim = vars->dims(); vars->Resize({box_num, static_cast(variances.size())}); - auto e_vars = framework::EigenMatrix::From(*vars); + auto e_vars = phi::EigenMatrix::From(*vars); #ifdef PADDLE_WITH_MKLML #pragma omp parallel for collapse(2) #endif diff --git a/paddle/fluid/operators/detection/prior_box_op.h b/paddle/fluid/operators/detection/prior_box_op.h index 51e8bbbcae530c13e9ea7a77042166f4897ffa27..9968a07fcf7f4dd00a88420e39cbe8cc39a390a7 100644 --- a/paddle/fluid/operators/detection/prior_box_op.h +++ b/paddle/fluid/operators/detection/prior_box_op.h @@ -182,7 +182,7 @@ class PriorBoxOpKernel : public framework::OpKernel { var_t.mutable_data( phi::make_ddim({1, static_cast(variances.size())}), ctx.GetPlace()); - auto var_et = framework::EigenTensor::From(var_t); + auto var_et = phi::EigenTensor::From(var_t); #ifdef PADDLE_WITH_MKLML #pragma omp parallel for @@ -195,7 +195,7 @@ class PriorBoxOpKernel : public framework::OpKernel { auto var_dim = vars->dims(); vars->Resize({box_num, static_cast(variances.size())}); - auto e_vars = framework::EigenMatrix::From(*vars); + auto e_vars = phi::EigenMatrix::From(*vars); #ifdef PADDLE_WITH_MKLML #pragma omp parallel for collapse(2) diff --git a/paddle/fluid/operators/index_select_op.h b/paddle/fluid/operators/index_select_op.h index e21da66a1608c5512030b02c0f62b1c2a64ebe8d..71dd10d0aa42bd22d2d7e292e77d5a32d78ae96a 100644 --- a/paddle/fluid/operators/index_select_op.h +++ b/paddle/fluid/operators/index_select_op.h @@ -83,8 +83,8 @@ void IndexSelectInner(const framework::ExecutionContext& context, input->Resize(phi::make_ddim({outer_nums, input_dim[dim], slice_size})); output->Resize(phi::make_ddim({outer_nums, index_size, slice_size})); - auto input_tensor = framework::EigenTensor::From(*input); - auto output_tensor = framework::EigenTensor::From(*output); + auto input_tensor = phi::EigenTensor::From(*input); + auto output_tensor = phi::EigenTensor::From(*output); auto& place = *context.template device_context().eigen_device(); diff --git a/paddle/fluid/operators/interpolate_op.h b/paddle/fluid/operators/interpolate_op.h index ff2d5236d78bb8c66ed9a08b850f8c5cf335affd..11c142910765427de6b23cc750d713ebbfa156b1 100644 --- a/paddle/fluid/operators/interpolate_op.h +++ b/paddle/fluid/operators/interpolate_op.h @@ -25,7 +25,7 @@ template -using EigenTensor = framework::EigenTensor; +using EigenTensor = phi::EigenTensor; using Tensor = phi::DenseTensor; using DataLayout = phi::DataLayout; diff --git a/paddle/fluid/operators/math/sequence_pooling.cc b/paddle/fluid/operators/math/sequence_pooling.cc index 43b39795753197982dc6f7b8f9c8588dc25e05ff..9008111e42b87769d79b4bc148edeb4e50925ddb 100644 --- a/paddle/fluid/operators/math/sequence_pooling.cc +++ b/paddle/fluid/operators/math/sequence_pooling.cc @@ -29,11 +29,11 @@ using LoDTensor = phi::DenseTensor; template -using EigenVector = framework::EigenVector; +using EigenVector = phi::EigenVector; template -using EigenMatrix = framework::EigenMatrix; +using EigenMatrix = phi::EigenMatrix; template class MaxSeqPoolFunctor { diff --git a/paddle/fluid/operators/sequence_ops/sequence_expand_op.h b/paddle/fluid/operators/sequence_ops/sequence_expand_op.h index 025a160b0e9c4d78a0b3509284f9cb4fbbdd81d2..af43aec7931e7ebbfb35cf4804ddac897c3d8358 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_expand_op.h +++ b/paddle/fluid/operators/sequence_ops/sequence_expand_op.h @@ -26,7 +26,7 @@ using LoDTensor = phi::DenseTensor; template -using EigenMatrix = framework::EigenMatrix; +using EigenMatrix = phi::EigenMatrix; template struct SequenceExpandFunctor { diff --git a/paddle/phi/kernels/cpu/norm_grad_kernel.cc b/paddle/phi/kernels/cpu/norm_grad_kernel.cc index 92ca51b499c7a892deecac4526344cd9d9a8daca..b27546d7814033c15843d27582c25230baaf7e4a 100644 --- a/paddle/phi/kernels/cpu/norm_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/norm_grad_kernel.cc @@ -45,10 +45,10 @@ void NormGradKernel(const Context& ctx, auto* place = ctx.eigen_device(); - auto x_e = paddle::framework::EigenVector::Flatten(*in_x); - auto dy_e = paddle::framework::EigenVector::Flatten(*in_dy); - auto norm_e = paddle::framework::EigenVector::Flatten(*in_norm); - auto dx_e = paddle::framework::EigenVector::Flatten(*out_dx); + auto x_e = phi::EigenVector::Flatten(*in_x); + auto dy_e = phi::EigenVector::Flatten(*in_dy); + auto norm_e = phi::EigenVector::Flatten(*in_norm); + auto dx_e = phi::EigenVector::Flatten(*out_dx); Eigen::DSizes shape(pre, n, post); Eigen::DSizes rshape(pre, 1, post); @@ -60,7 +60,7 @@ void NormGradKernel(const Context& ctx, DenseTensor rsum; rsum.Resize({pre, post}); ctx.template Alloc(&rsum); - auto sum = paddle::framework::EigenTensor::From(rsum); + auto sum = phi::EigenTensor::From(rsum); Eigen::DSizes rdim(1); Eigen::DSizes bcast(1, n, 1); diff --git a/paddle/phi/kernels/cpu/norm_kernel.cc b/paddle/phi/kernels/cpu/norm_kernel.cc index f69d03b66b1b5d8364099ce2f6410075bc010382..21af086515d71cf97c4eec943a16cca57269c8bf 100644 --- a/paddle/phi/kernels/cpu/norm_kernel.cc +++ b/paddle/phi/kernels/cpu/norm_kernel.cc @@ -55,9 +55,9 @@ void NormKernel(const Context& ctx, Eigen::DSizes shape(pre, n, post); Eigen::DSizes norm_shape(pre, post); - auto x_e = paddle::framework::EigenVector::Flatten(x); - auto y_e = paddle::framework::EigenVector::Flatten(*out); - auto norm_e = paddle::framework::EigenVector::Flatten(*out_norm); + auto x_e = phi::EigenVector::Flatten(x); + auto y_e = phi::EigenVector::Flatten(*out); + auto norm_e = phi::EigenVector::Flatten(*out_norm); auto x_r = x_e.reshape(shape); auto y = y_e.reshape(shape); auto norm_reshape = norm_e.reshape(norm_shape); diff --git a/paddle/phi/kernels/funcs/detail/gru_cpu_kernel.h b/paddle/phi/kernels/funcs/detail/gru_cpu_kernel.h index 0fdf490c5534d1f1d89a69789dbec8b85aa8f41b..eb02200f01db01985545feb18bf773ca9bfc5ffc 100644 --- a/paddle/phi/kernels/funcs/detail/gru_cpu_kernel.h +++ b/paddle/phi/kernels/funcs/detail/gru_cpu_kernel.h @@ -15,9 +15,9 @@ limitations under the License. */ #pragma once #include -#include "paddle/fluid/framework/eigen.h" #include "paddle/phi/kernels/funcs/activation_functor.h" #include "paddle/phi/kernels/funcs/detail/activation_functions.h" +#include "paddle/phi/kernels/funcs/eigen/common.h" #include "paddle/phi/kernels/funcs/gru_compute.h" namespace phi { @@ -27,7 +27,7 @@ using Array1 = Eigen::DSizes; template -using EigenVector = paddle::framework::EigenVector; +using EigenVector = phi::EigenVector; #if !defined(__NVCC__) && !defined(__HIPCC___) // @{ Group for GRU CPU template diff --git a/paddle/phi/kernels/funcs/detail/lstm_cpu_kernel.h b/paddle/phi/kernels/funcs/detail/lstm_cpu_kernel.h index 02fddc57b313a0169373ab4cb82d72a586ce3cc9..e8b8e957c80d1c9e392c75c65ab0da706c590742 100644 --- a/paddle/phi/kernels/funcs/detail/lstm_cpu_kernel.h +++ b/paddle/phi/kernels/funcs/detail/lstm_cpu_kernel.h @@ -15,9 +15,9 @@ limitations under the License. */ #pragma once #include -#include "paddle/fluid/framework/eigen.h" #include "paddle/phi/kernels/funcs/activation_functor.h" #include "paddle/phi/kernels/funcs/detail/activation_functions.h" +#include "paddle/phi/kernels/funcs/eigen/common.h" #include "paddle/phi/kernels/funcs/lstm_compute.h" #if defined(_WIN32) @@ -34,7 +34,7 @@ using Array1 = Eigen::DSizes; template -using EigenVector = paddle::framework::EigenVector; +using EigenVector = phi::EigenVector; #if !defined(__NVCC__) && !defined(__HIPCC___) // @{ Group LSTM CPU diff --git a/paddle/phi/kernels/funcs/math_function.cc b/paddle/phi/kernels/funcs/math_function.cc index 7102b9cb11ad6c28e8bafae8327e1a7e6f699af7..7cad886654852af432b09d755f437716d89de152 100644 --- a/paddle/phi/kernels/funcs/math_function.cc +++ b/paddle/phi/kernels/funcs/math_function.cc @@ -299,9 +299,9 @@ struct RowwiseAdd { in_dims_cstr, out_dims_cstr)); - auto in = paddle::framework::EigenMatrix::From(input); - auto vec = paddle::framework::EigenVector::Flatten(vector); - auto out = paddle::framework::EigenMatrix::From(*output); + auto in = phi::EigenMatrix::From(input); + auto vec = phi::EigenVector::Flatten(vector); + auto out = phi::EigenMatrix::From(*output); for (int64_t i = 0; i < in_dims[0]; ++i) { out.chip(i, 0) = in.chip(i, 0) + vec; diff --git a/paddle/phi/kernels/funcs/math_function.h b/paddle/phi/kernels/funcs/math_function.h index 3a95c998b1f9afabb145df085ed30ddf34419191..e922864060c2b8ba02e75b049d72ea8b0c3ac198 100644 --- a/paddle/phi/kernels/funcs/math_function.h +++ b/paddle/phi/kernels/funcs/math_function.h @@ -18,7 +18,6 @@ limitations under the License. */ #include #include "paddle/fluid/framework/convert_utils.h" -#include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/framework/tensor_util.h" @@ -26,6 +25,7 @@ limitations under the License. */ #include "paddle/fluid/platform/enforce.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/utils/data_type.h" +#include "paddle/phi/kernels/funcs/eigen/common.h" namespace phi { namespace funcs { diff --git a/paddle/phi/kernels/funcs/math_function_impl.h b/paddle/phi/kernels/funcs/math_function_impl.h index 512f21e82091ceb7d2c5d41fcda24a233fd93fbb..1ab9455215e9a82d332242f8af1868d6408bdf0d 100644 --- a/paddle/phi/kernels/funcs/math_function_impl.h +++ b/paddle/phi/kernels/funcs/math_function_impl.h @@ -22,13 +22,13 @@ limitations under the License. */ namespace phi { namespace funcs { -using paddle::framework::To32BitIndex; +using phi::To32BitIndex; template void SetConstant::operator()(const DeviceContext& context, phi::DenseTensor* tensor, T num) { - auto t = paddle::framework::EigenVector::Flatten(*tensor); + auto t = phi::EigenVector::Flatten(*tensor); t.device(*context.eigen_device()) = t.constant(static_cast(num)); } @@ -60,8 +60,8 @@ void Transpose::operator()( for (int i = 0; i < Rank; i++) { permute[i] = axis[i]; } - auto eigen_in = paddle::framework::EigenTensor::From(in); - auto eigen_out = paddle::framework::EigenTensor::From(*out); + auto eigen_in = phi::EigenTensor::From(in); + auto eigen_out = phi::EigenTensor::From(*out); auto* dev = context.eigen_device(); // use 32bit index to speed up computation bool use_32bit_index = eigen_out.size() < Eigen::NumTraits::highest(); @@ -89,8 +89,8 @@ void ColwiseSum::operator()(const DeviceContext& context, size, out->numel())); - auto in = paddle::framework::EigenMatrix::From(input); - auto vec = paddle::framework::EigenVector::Flatten(*out); + auto in = phi::EigenMatrix::From(input); + auto vec = phi::EigenVector::Flatten(*out); vec.device(*context.eigen_device()) = in.sum(Eigen::array({{0}})); } @@ -151,8 +151,8 @@ void RowwiseMean::operator()(const DeviceContext& context, in_dims[0], out->numel())); - auto in = paddle::framework::EigenMatrix::From(input); - auto vec = paddle::framework::EigenVector::Flatten(*out); + auto in = phi::EigenMatrix::From(input); + auto vec = phi::EigenVector::Flatten(*out); vec.device(*context.eigen_device()) = in.mean(Eigen::array({{1}})); } @@ -217,8 +217,8 @@ void RowwiseSum::operator()(const DeviceContext& context, in_dims[0], out->numel())); - auto in = paddle::framework::EigenMatrix::From(input); - auto vec = paddle::framework::EigenVector::Flatten(*out); + auto in = phi::EigenMatrix::From(input); + auto vec = phi::EigenVector::Flatten(*out); vec.device(*context.eigen_device()) = in.sum(Eigen::array({{1}})); } diff --git a/paddle/phi/kernels/funcs/sequence2batch.h b/paddle/phi/kernels/funcs/sequence2batch.h index 5ae2c2f617da8ab062e88f004d1b58565a3e2f84..83c89a30916faf171d357d1ff991d6e8ad7d6800 100644 --- a/paddle/phi/kernels/funcs/sequence2batch.h +++ b/paddle/phi/kernels/funcs/sequence2batch.h @@ -16,10 +16,10 @@ limitations under the License. */ #include #include -#include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/platform/device_context.h" +#include "paddle/phi/kernels/funcs/eigen/common.h" namespace phi { namespace funcs { @@ -27,7 +27,7 @@ namespace funcs { template -using EigenMatrix = paddle::framework::EigenMatrix; +using EigenMatrix = phi::EigenMatrix; template class CopyMatrixRowsFunctor { diff --git a/paddle/phi/kernels/gpudnn/conv_grad_kernel.cu b/paddle/phi/kernels/gpudnn/conv_grad_kernel.cu index 6d7c486a75f8a2ee13579e69b7a4d69ef4bad5b6..43b0d0a81d43830aca62549d2408a0c8c5376d46 100644 --- a/paddle/phi/kernels/gpudnn/conv_grad_kernel.cu +++ b/paddle/phi/kernels/gpudnn/conv_grad_kernel.cu @@ -14,7 +14,6 @@ #include "paddle/phi/kernels/conv_grad_kernel.h" -#include "paddle/fluid/framework/eigen.h" #include "paddle/phi/backends/gpu/gpu_context.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/impl/conv_cudnn_impl.h b/paddle/phi/kernels/impl/conv_cudnn_impl.h index ba7f69f9c3a8cc338711f7209b7ec1ada3ee1b2d..02b0ab644711d7cea150c98193716543cbb1e06f 100644 --- a/paddle/phi/kernels/impl/conv_cudnn_impl.h +++ b/paddle/phi/kernels/impl/conv_cudnn_impl.h @@ -14,7 +14,6 @@ #pragma once -#include "paddle/fluid/framework/eigen.h" #include "paddle/phi/backends/gpu/gpu_context.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/impl/segment_pool_grad_kernel_impl.h b/paddle/phi/kernels/impl/segment_pool_grad_kernel_impl.h index e75c3e980ef69c4e26ece1153991e7655974b912..8d37c7c5124cd3dd2e5893a6d890f49ff4c6113a 100644 --- a/paddle/phi/kernels/impl/segment_pool_grad_kernel_impl.h +++ b/paddle/phi/kernels/impl/segment_pool_grad_kernel_impl.h @@ -16,7 +16,6 @@ #include -#include "paddle/fluid/framework/eigen.h" #include "paddle/phi/common/place.h" #include "paddle/phi/kernels/funcs/math_function.h" #include "paddle/phi/kernels/funcs/segment_pooling.h" diff --git a/paddle/phi/kernels/impl/segment_pool_kernel_impl.h b/paddle/phi/kernels/impl/segment_pool_kernel_impl.h index 48111913c7822464403234b54c8f1ae6779f3f49..216d5e6100d6cfddd772bae1b6c4b88854a7a3b5 100644 --- a/paddle/phi/kernels/impl/segment_pool_kernel_impl.h +++ b/paddle/phi/kernels/impl/segment_pool_kernel_impl.h @@ -16,7 +16,6 @@ #include -#include "paddle/fluid/framework/eigen.h" #include "paddle/phi/common/place.h" #include "paddle/phi/kernels/funcs/math_function.h" #include "paddle/phi/kernels/funcs/segment_pooling.h"