Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHI decoupling] move "function_traits.h" from fluid to phi #48065

Merged
merged 1 commit into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions paddle/phi/kernels/funcs/broadcast_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,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,
Expand Down Expand Up @@ -983,7 +983,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(
Expand Down
8 changes: 4 additions & 4 deletions paddle/phi/kernels/funcs/elementwise_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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!");
Expand Down Expand Up @@ -57,5 +57,5 @@ struct FunctionTraits<ReturnType(Args...)> {
using ArgsTuple = std::tuple<Args...>;
};

} // namespace platform
} // namespace paddle
} // namespace funcs
} // namespace phi