未验证 提交 b7841a2b 编写于 作者: W Wang Xin 提交者: GitHub

move "function_traits.h" from fluid to phi (#48065)

上级 ff44df18
......@@ -176,7 +176,7 @@ __device__ void VectorizedBroadcastKernelImpl(
#endif
constexpr bool kCallElementwiseAny =
paddle::platform::FunctionTraits<Functor>::has_pointer_args;
phi::funcs::FunctionTraits<Functor>::has_pointer_args;
phi::funcs::ElementwisePrimitiveCaller<InT,
ConditionalT<OutT, NumOuts>,
VecSize,
......@@ -787,7 +787,7 @@ void BroadcastKernelForDifferentVecSize(
std::vector<DenseTensor *> *outs,
int axis,
Functor func) {
using Traits = paddle::platform::FunctionTraits<Functor>;
using Traits = phi::funcs::FunctionTraits<Functor>;
const int kArity =
Traits::has_pointer_args ? static_cast<int>(ET) : Traits::arity;
PADDLE_ENFORCE_EQ(
......
......@@ -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<const DenseTensor *> &ins,
#ifdef PADDLE_WITH_XPU_KP
int vec_size = 256;
#else
using Traits = paddle::platform::FunctionTraits<Functor>;
using Traits = phi::funcs::FunctionTraits<Functor>;
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<Functor>;
using Traits = phi::funcs::FunctionTraits<Functor>;
using ArgsT = typename Traits::ArgsTuple;
ArgsT args[VecSize];
ConditionalT<OutT, NumOuts> result[VecSize];
......@@ -831,7 +831,7 @@ void ElementwiseKernel(const KPDevice &ctx,
const std::vector<const DenseTensor *> &ins,
std::vector<DenseTensor *> *outs,
Functor func) {
using Traits = paddle::platform::FunctionTraits<Functor>;
using Traits = phi::funcs::FunctionTraits<Functor>;
const int kArity = Traits::arity;
PADDLE_ENFORCE_EQ(ins.size(),
kArity,
......
/* 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 <tuple>
namespace paddle {
namespace platform {
namespace phi {
namespace funcs {
template <int Arity, typename... Args>
struct IsPointerArgs {
static_assert(Arity == sizeof...(Args), "Arity and Args not match!");
......@@ -57,5 +57,5 @@ struct FunctionTraits<ReturnType(Args...)> {
using ArgsTuple = std::tuple<Args...>;
};
} // namespace platform
} // namespace paddle
} // namespace funcs
} // namespace phi
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册