From b7841a2b6641c46cff7843d92707645e5ba5c4a7 Mon Sep 17 00:00:00 2001 From: Wang Xin Date: Thu, 17 Nov 2022 14:11:28 +0800 Subject: [PATCH] move "function_traits.h" from fluid to phi (#48065) --- paddle/phi/kernels/funcs/broadcast_function.h | 4 ++-- paddle/phi/kernels/funcs/elementwise_base.h | 8 ++++---- .../platform => phi/kernels/funcs}/function_traits.h | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) rename paddle/{fluid/platform => phi/kernels/funcs}/function_traits.h (93%) diff --git a/paddle/phi/kernels/funcs/broadcast_function.h b/paddle/phi/kernels/funcs/broadcast_function.h index 67d3a309b1f..a222422c89f 100644 --- a/paddle/phi/kernels/funcs/broadcast_function.h +++ b/paddle/phi/kernels/funcs/broadcast_function.h @@ -176,7 +176,7 @@ __device__ void VectorizedBroadcastKernelImpl( #endif constexpr bool kCallElementwiseAny = - paddle::platform::FunctionTraits::has_pointer_args; + phi::funcs::FunctionTraits::has_pointer_args; phi::funcs::ElementwisePrimitiveCaller, VecSize, @@ -787,7 +787,7 @@ void BroadcastKernelForDifferentVecSize( std::vector *outs, int axis, Functor func) { - using Traits = paddle::platform::FunctionTraits; + using Traits = phi::funcs::FunctionTraits; const int kArity = Traits::has_pointer_args ? static_cast(ET) : Traits::arity; PADDLE_ENFORCE_EQ( diff --git a/paddle/phi/kernels/funcs/elementwise_base.h b/paddle/phi/kernels/funcs/elementwise_base.h index a1b0a709569..17b0a653cc8 100644 --- a/paddle/phi/kernels/funcs/elementwise_base.h +++ b/paddle/phi/kernels/funcs/elementwise_base.h @@ -23,9 +23,9 @@ limitations under the License. */ #include "paddle/phi/kernels/funcs/math_function.h" #if defined(__NVCC__) || defined(__HIPCC__) || defined(__xpu__) -#include "paddle/fluid/platform/function_traits.h" #include "paddle/phi/backends/gpu/gpu_launch_config.h" #include "paddle/phi/kernels/funcs/aligned_vector.h" +#include "paddle/phi/kernels/funcs/function_traits.h" #include "paddle/phi/kernels/primitive/kernel_primitives.h" #define HOSTDEVICE __host__ __device__ @@ -563,7 +563,7 @@ int GetVectorizedSizeForTensors(const std::vector &ins, #ifdef PADDLE_WITH_XPU_KP int vec_size = 256; #else - using Traits = paddle::platform::FunctionTraits; + using Traits = phi::funcs::FunctionTraits; using ArgsT = typename Traits::ArgsTuple; const int Arity = Traits::arity; int vec_size = 4; @@ -736,7 +736,7 @@ __device__ void VectorizedElementwiseKernelImpl( int num, int read_lens, Functor func) { - using Traits = paddle::platform::FunctionTraits; + using Traits = phi::funcs::FunctionTraits; using ArgsT = typename Traits::ArgsTuple; ArgsT args[VecSize]; ConditionalT result[VecSize]; @@ -831,7 +831,7 @@ void ElementwiseKernel(const KPDevice &ctx, const std::vector &ins, std::vector *outs, Functor func) { - using Traits = paddle::platform::FunctionTraits; + using Traits = phi::funcs::FunctionTraits; const int kArity = Traits::arity; PADDLE_ENFORCE_EQ(ins.size(), kArity, diff --git a/paddle/fluid/platform/function_traits.h b/paddle/phi/kernels/funcs/function_traits.h similarity index 93% rename from paddle/fluid/platform/function_traits.h rename to paddle/phi/kernels/funcs/function_traits.h index 662e3ac58a6..aae3a35dda1 100644 --- a/paddle/fluid/platform/function_traits.h +++ b/paddle/phi/kernels/funcs/function_traits.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. +/* Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. Licensed under the Apache License, Version 2.1 (the "License"); you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ limitations under the License. */ #include -namespace paddle { -namespace platform { +namespace phi { +namespace funcs { template struct IsPointerArgs { static_assert(Arity == sizeof...(Args), "Arity and Args not match!"); @@ -57,5 +57,5 @@ struct FunctionTraits { using ArgsTuple = std::tuple; }; -} // namespace platform -} // namespace paddle +} // namespace funcs +} // namespace phi -- GitLab