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

【Hackathon + No.60】 angle 等算子 FP16/BF16算子及单测完善 #51666

Closed
wants to merge 8 commits into from
Closed
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
341 changes: 203 additions & 138 deletions paddle/fluid/distributed/ps/thirdparty/round_robin.h

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ class TransformerInputConvertPlugin : public DynamicPluginTensorRT {

int initialize() TRT_NOEXCEPT { return 0; }
void terminate() TRT_NOEXCEPT;
nvinfer1::DimsExprs getOutputDimensions(int outputIndex,
const nvinfer1::DimsExprs* inputs,
int nbInputs,
nvinfer1::IExprBuilder& exprBuilder) // NOLINT
nvinfer1::DimsExprs getOutputDimensions(
int outputIndex,
const nvinfer1::DimsExprs* inputs,
int nbInputs,
nvinfer1::IExprBuilder& exprBuilder) // NOLINT
TRT_NOEXCEPT override;

bool supportsFormatCombination(int pos,
Expand Down Expand Up @@ -155,10 +156,11 @@ class TransformerOutputConvertPlugin : public DynamicPluginTensorRT {

int initialize() TRT_NOEXCEPT { return 0; }
void terminate() TRT_NOEXCEPT;
nvinfer1::DimsExprs getOutputDimensions(int outputIndex,
const nvinfer1::DimsExprs* inputs,
int nbInputs,
nvinfer1::IExprBuilder& exprBuilder) // NOLINT
nvinfer1::DimsExprs getOutputDimensions(
int outputIndex,
const nvinfer1::DimsExprs* inputs,
int nbInputs,
nvinfer1::IExprBuilder& exprBuilder) // NOLINT
TRT_NOEXCEPT override;

bool supportsFormatCombination(int pos,
Expand Down
1 change: 1 addition & 0 deletions paddle/phi/kernels/clip_by_norm_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#pragma once

#include "paddle/phi/common/scalar.h"
#include "paddle/phi/core/dense_tensor.h"

namespace phi {
Expand Down
9 changes: 7 additions & 2 deletions paddle/phi/kernels/cpu/clip_by_norm_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@ void ClipByNormKernel(const Context& dev_ctx,

} // namespace phi

PD_REGISTER_KERNEL(
clip_by_norm, CPU, ALL_LAYOUT, phi::ClipByNormKernel, float) {}
PD_REGISTER_KERNEL(clip_by_norm,
CPU,
ALL_LAYOUT,
phi::ClipByNormKernel,
float,
phi::dtype::float16,
phi::dtype::bfloat16) {}
10 changes: 8 additions & 2 deletions paddle/phi/kernels/cpu/multi_dot_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,11 @@ limitations under the License. */
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/multi_dot_kernel_impl.h"

PD_REGISTER_KERNEL(
multi_dot, CPU, ALL_LAYOUT, phi::MultiDotKernel, float, double) {}
PD_REGISTER_KERNEL(multi_dot,
CPU,
ALL_LAYOUT,
phi::MultiDotKernel,
float,
double,
phi::dtype::float16,
phi::dtype::bfloat16) {}
10 changes: 8 additions & 2 deletions paddle/phi/kernels/cpu/multinomial_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,11 @@ void MultinomialKernel(const Context& dev_ctx,

} // namespace phi

PD_REGISTER_KERNEL(
multinomial, CPU, ALL_LAYOUT, phi::MultinomialKernel, float, double) {}
PD_REGISTER_KERNEL(multinomial,
CPU,
ALL_LAYOUT,
phi::MultinomialKernel,
float,
double,
phi::dtype::float16,
phi::dtype::bfloat16) {}
4 changes: 3 additions & 1 deletion paddle/phi/kernels/cpu/overlap_add_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,6 @@ PD_REGISTER_KERNEL(overlap_add,
float,
double,
phi::dtype::complex<float>,
phi::dtype::complex<double>) {}
phi::dtype::complex<double>,
phi::dtype::float16,
phi::dtype::bfloat16) {}
9 changes: 8 additions & 1 deletion paddle/phi/kernels/cpu/prelu_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,11 @@ void PReluKernel(const Context& dev_ctx,

} // namespace phi

PD_REGISTER_KERNEL(prelu, CPU, ALL_LAYOUT, phi::PReluKernel, float, double) {}
PD_REGISTER_KERNEL(prelu,
CPU,
ALL_LAYOUT,
phi::PReluKernel,
float,
double,
phi::dtype::float16,
phi::dtype::bfloat16) {}
15 changes: 14 additions & 1 deletion paddle/phi/kernels/cpu/randperm_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,24 @@ void RandpermKernel(const Context& dev_ctx,

} // namespace phi

PD_REGISTER_KERNEL(randperm_raw,
CPU,
ALL_LAYOUT,
phi::RandpermRawKernel,
float,
double,
int,
int64_t,
phi::dtype::float16,
phi::dtype::bfloat16) {}

PD_REGISTER_KERNEL(randperm,
CPU,
ALL_LAYOUT,
phi::RandpermKernel,
float,
double,
int,
int64_t) {}
int64_t,
phi::dtype::float16,
phi::dtype::bfloat16) {}
12 changes: 8 additions & 4 deletions paddle/phi/kernels/cpu/sign_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ limitations under the License. */
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/sign_kernel_impl.h"

// See Note [ Why still include the fluid headers? ]
#include "paddle/phi/common/bfloat16.h"

PD_REGISTER_KERNEL(sign, CPU, ALL_LAYOUT, phi::SignKernel, float, double) {}
PD_REGISTER_KERNEL(sign,
CPU,
ALL_LAYOUT,
phi::SignKernel,
float,
double,
phi::dtype::float16,
phi::dtype::bfloat16) {}
3 changes: 2 additions & 1 deletion paddle/phi/kernels/gpu/clip_by_norm_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ PD_REGISTER_KERNEL(clip_by_norm,
ALL_LAYOUT,
phi::ClipByNormKernel,
float,
phi::dtype::float16) {}
phi::dtype::float16,
phi::dtype::bfloat16) {}
10 changes: 8 additions & 2 deletions paddle/phi/kernels/gpu/multi_dot_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,11 @@ limitations under the License. */

using float16 = phi::dtype::float16;

PD_REGISTER_KERNEL(
multi_dot, GPU, ALL_LAYOUT, phi::MultiDotKernel, float, double, float16) {}
PD_REGISTER_KERNEL(multi_dot,
GPU,
ALL_LAYOUT,
phi::MultiDotKernel,
float,
double,
float16,
phi::dtype::bfloat16) {}
4 changes: 3 additions & 1 deletion paddle/phi/kernels/gpu/multinomial_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ PD_REGISTER_KERNEL(multinomial, // cuda_only
ALL_LAYOUT,
phi::MultinomialKernel,
float,
double) {}
double,
phi::dtype::float16,
phi::dtype::bfloat16) {}

#endif
5 changes: 3 additions & 2 deletions paddle/phi/kernels/gpu/overlap_add_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ PD_REGISTER_KERNEL(overlap_add,
int64_t,
float,
double,
phi::dtype::float16,
phi::dtype::complex<float>,
phi::dtype::complex<double>) {}
phi::dtype::complex<double>,
phi::dtype::float16,
phi::dtype::bfloat16) {}
1 change: 1 addition & 0 deletions paddle/phi/kernels/gpu/prelu_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ PD_REGISTER_KERNEL(prelu,
phi::PReluKernel,
float,
phi::dtype::float16,
phi::dtype::bfloat16,
double) {}
15 changes: 14 additions & 1 deletion paddle/phi/kernels/gpu/randperm_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,24 @@ void RandpermKernel(const Context& dev_ctx,

} // namespace phi

PD_REGISTER_KERNEL(randperm_raw,
GPU,
ALL_LAYOUT,
phi::RandpermRawKernel,
float,
double,
int,
int64_t,
phi::dtype::float16,
phi::dtype::bfloat16) {}

PD_REGISTER_KERNEL(randperm,
GPU,
ALL_LAYOUT,
phi::RandpermKernel,
float,
double,
int,
int64_t) {}
int64_t,
phi::dtype::float16,
phi::dtype::bfloat16) {}
10 changes: 8 additions & 2 deletions paddle/phi/kernels/gpu/sign_kernel.cu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@ limitations under the License. */

using float16 = phi::dtype::float16;

PD_REGISTER_KERNEL(
sign, GPU, ALL_LAYOUT, phi::SignKernel, float, double, float16) {}
PD_REGISTER_KERNEL(sign,
GPU,
ALL_LAYOUT,
phi::SignKernel,
float,
double,
float16,
phi::dtype::bfloat16) {}
1 change: 1 addition & 0 deletions paddle/phi/kernels/multi_dot_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#pragma once

#include "paddle/phi/common/scalar.h"
#include "paddle/phi/core/dense_tensor.h"

namespace phi {
Expand Down
1 change: 1 addition & 0 deletions paddle/phi/kernels/overlap_add_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#pragma once

#include "paddle/phi/common/scalar.h"
#include "paddle/phi/core/dense_tensor.h"

namespace phi {
Expand Down
1 change: 1 addition & 0 deletions paddle/phi/kernels/prelu_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#pragma once

#include "paddle/phi/common/scalar.h"
#include "paddle/phi/core/dense_tensor.h"

namespace phi {
Expand Down
1 change: 1 addition & 0 deletions paddle/phi/kernels/randperm_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#pragma once

#include "paddle/phi/common/scalar.h"
#include "paddle/phi/core/dense_tensor.h"
#include "paddle/phi/core/device_context.h"

Expand Down
1 change: 1 addition & 0 deletions paddle/phi/kernels/sign_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ limitations under the License. */

#pragma once

#include "paddle/phi/common/scalar.h"
#include "paddle/phi/core/dense_tensor.h"
#include "paddle/phi/infermeta/unary.h"
#include "paddle/phi/kernels/empty_kernel.h"
Expand Down
Loading