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][jit] clean paddle/phi/kernels/jit Unused methods #51446

Merged
merged 15 commits into from
Mar 17, 2023
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,4 @@ This is an incomplete list of authors of [Paddle](https://github.com/PaddlePaddl
| yiakwy, yiakwy-xpu-ml-framework-team | Yi Wang (Graphcore) |
| [Yulv-git](https://github.com/Yulv-git) | Shuangchi He |
| [zrr1999](https://github.com/zrr1999) | Rongrui Zhan |
| [gouzil](https://github.com/gouzil) | Chuan Tian |
8 changes: 2 additions & 6 deletions paddle/phi/kernels/cpu/layer_norm_grad_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@

#include "paddle/phi/kernels/layer_norm_grad_kernel.h"

#include "paddle/phi/kernels/cpu/elementwise.h"
#include "paddle/phi/kernels/funcs/layer_norm_util.h"
#if !defined(PADDLE_WITH_CUDA) && !defined(_WIN32) && !defined(__APPLE__) && \
!defined(__OSX__)
#include "paddle/phi/kernels/funcs/jit/kernels.h"
#endif
#include "paddle/phi/backends/cpu/cpu_context.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/core/tensor_utils.h"
#include "paddle/phi/kernels/cpu/elementwise.h"
#include "paddle/phi/kernels/funcs/blas/blas.h"
#include "paddle/phi/kernels/funcs/elementwise_base.h"
#include "paddle/phi/kernels/funcs/elementwise_functor.h"
#include "paddle/phi/kernels/funcs/layer_norm_util.h"
#include "paddle/phi/kernels/funcs/math_function.h"

namespace phi {
Expand Down
35 changes: 0 additions & 35 deletions paddle/phi/kernels/funcs/jit/benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,6 @@ void BenchKernelAXYN() {
}
}

template <typename KernelTuple, typename PlaceType>
void BenchKernelXRN() {
using T = typename KernelTuple::data_type;
for (int d : TestSizes()) {
phi::DenseTensor x;
RandomVec<T>(d, x.mutable_data<T>({d}, PlaceType()));
T res;
BenchAllImpls<KernelTuple, PlaceType>(d, x.data<T>(), &res, d);
}
}

template <typename KernelTuple, typename PlaceType>
void BenchKernelXYN() {
using T = typename KernelTuple::data_type;
Expand Down Expand Up @@ -390,22 +379,6 @@ void BenchKernelMatMul() {
}
}

template <typename KernelTuple, typename PlaceType>
void BenchKernelSoftmax() {
using T = typename KernelTuple::data_type;
for (int bs : {1, 2, 10}) {
for (int n : TestSizes()) {
phi::DenseTensor x, y;
x.Resize({bs, n});
y.Resize({bs, n});
RandomVec<T>(bs * n, x.mutable_data<T>(PlaceType()), -2.f, 2.f);
const T* x_data = x.data<T>();
T* y_data = y.mutable_data<T>(PlaceType());
BenchAllImpls<KernelTuple, PlaceType>(n, x_data, y_data, n, bs, 1);
}
}
}

template <typename KernelTuple, typename PlaceType>
void BenchKernelLayerNorm() {
using T = typename KernelTuple::data_type;
Expand Down Expand Up @@ -514,9 +487,6 @@ void BenchKernelVBroadcast() {
#define BenchKernelVTanh BenchKernelXYN
#define BenchKernelVCopy BenchKernelXYN

#define BenchKernelHMax BenchKernelXRN
#define BenchKernelHSum BenchKernelXRN

#define BenchKernelLSTMCtHt BenchKernelLSTM
#define BenchKernelLSTMC1H1 BenchKernelLSTM

Expand Down Expand Up @@ -550,10 +520,6 @@ BENCH_FP32_CPU(VSigmoid);
BENCH_FP32_CPU(VTanh);
BENCH_FP32_CPU(VCopy);

// xrn
BENCH_FP32_CPU(HMax);
BENCH_FP32_CPU(HSum);

// LSTM
BENCH_FP32_CPU(LSTMCtHt);
BENCH_FP32_CPU(LSTMC1H1);
Expand All @@ -569,7 +535,6 @@ BENCH_FP32_CPU(CRFDecoding);
BENCH_FP32_CPU(SeqPool);
BENCH_FP32_CPU(EmbSeqPool);
BENCH_FP32_CPU(MatMul);
BENCH_FP32_CPU(Softmax);
BENCH_FP32_CPU(Sgd);
BENCH_FP32_CPU(VBroadcast);

Expand Down
3 changes: 0 additions & 3 deletions paddle/phi/kernels/funcs/jit/gen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ use_jitkernel_gen(kLSTMC1H1)
use_jitkernel_gen(kGRUH1)
use_jitkernel_gen(kGRUHtPart1)
use_jitkernel_gen(kGRUHtPart2)
use_jitkernel_gen(kNCHW16CMulNC)
use_jitkernel_gen(kSeqPool)
use_jitkernel_gen(kHMax)
use_jitkernel_gen(kHSum)
use_jitkernel_gen(kEmbSeqPool)
use_jitkernel_gen(kAdam)
use_jitkernel_gen(kAdamW)
Expand Down
43 changes: 0 additions & 43 deletions paddle/phi/kernels/funcs/jit/gen/blas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,48 +110,6 @@ void VXXJitCode::genCode() {
ret();
}

void NCHW16CMulNCJitCode::genCode() {
// RDI is ptr x_input
// RSI is ptr y_input
// RDX is ptr output
// RCX is height
// r8 is width

push(rbx);

xor_(rax, rax);
xor_(r10, r10);
vmovups(zmm3, ptr[rsi]);

L("h_loop");
xor_(rbx, rbx);
L("w_loop");
vmovups(zmm2, ptr[rdi + rax]);
vmulps(zmm1, zmm2, zmm3);
vmovups(ptr[rdx + rax], zmm1);
add(rax, 64);
inc(rbx);
cmp(r8, rbx);
jnz("w_loop");
inc(r10);
cmp(r10, rcx);
jnz("h_loop");

pop(rbx);
ret();
}

class NCHW16CMulNCCreator : public JitCodeCreator<int> {
public:
bool CanBeUsed(const int& attr) const override {
return phi::backends::cpu::MayIUse(phi::backends::cpu::avx512f);
}
size_t CodeSize(const int& d) const override { return 256 * 1024; }
std::unique_ptr<GenBase> CreateJitCode(const int& attr) const override {
return make_unique<NCHW16CMulNCJitCode>(attr, CodeSize(attr));
}
};

#define DECLARE_BLAS_CREATOR(name) \
class name##Creator : public JitCodeCreator<int> { \
public: \
Expand Down Expand Up @@ -188,4 +146,3 @@ REGISTER_JITKERNEL_GEN(kVSub, gen::VSubCreator);
REGISTER_JITKERNEL_GEN(kVAddRelu, gen::VAddReluCreator);
REGISTER_JITKERNEL_GEN(kVScal, gen::VScalCreator);
REGISTER_JITKERNEL_GEN(kVAddBias, gen::VAddBiasCreator);
REGISTER_JITKERNEL_GEN(kNCHW16CMulNC, gen::NCHW16CMulNCCreator);
13 changes: 0 additions & 13 deletions paddle/phi/kernels/funcs/jit/gen/blas.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,6 @@ DECLARE_BLAS_JITCODE(VAddBias, operand_type::ADD, 1, false);

#undef DECLARE_BLAS_JITCODE

// nChw16c = nChw16c .* NC
class NCHW16CMulNCJitCode : public JitCode {
public:
DECLARE_JIT_CODE(NCHW16CMulNCJitCode);
explicit NCHW16CMulNCJitCode(int d /*unused*/,
size_t code_size,
void* code_ptr = nullptr)
: JitCode(code_size, code_ptr) {
this->genCode();
}
void genCode() override;
};

} // namespace gen
} // namespace jit
} // namespace phi
102 changes: 0 additions & 102 deletions paddle/phi/kernels/funcs/jit/gen/hopv.cc

This file was deleted.

93 changes: 0 additions & 93 deletions paddle/phi/kernels/funcs/jit/gen/hopv.h

This file was deleted.

Loading