Skip to content

Commit

Permalink
fix enforce usage
Browse files Browse the repository at this point in the history
  • Loading branch information
huangjiyi committed Feb 26, 2023
1 parent ec9d8b6 commit 5f521f0
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
20 changes: 10 additions & 10 deletions paddle/phi/kernels/funcs/selected_rows_functor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@ struct SelectedRowsAdd<phi::CPUContext, T> {
out_value->numel() / out_rows.size()));

auto in1_place = input1.place();
PADDLE_ENFORCE_EQ(in1_place.GetType() == phi::AllocationType::CPU,
true,
PADDLE_ENFORCE_EQ(in1_place.GetType(),
phi::AllocationType::CPU,
phi::errors::InvalidArgument(
"The running environment is not on the CPU place."));
auto in2_place = input2.place();
PADDLE_ENFORCE_EQ(in2_place.GetType() == phi::AllocationType::CPU,
true,
PADDLE_ENFORCE_EQ(in2_place.GetType(),
phi::AllocationType::CPU,
phi::errors::InvalidArgument(
"The running environment is not on the CPU place."));
auto out_place = context.GetPlace();
PADDLE_ENFORCE_EQ(out_place.GetType() == phi::AllocationType::CPU,
true,
PADDLE_ENFORCE_EQ(out_place.GetType(),
phi::AllocationType::CPU,
phi::errors::InvalidArgument(
"The running environment is not on the CPU place."));

Expand Down Expand Up @@ -204,13 +204,13 @@ struct SelectedRowsAddTo<phi::CPUContext, T> {
mixv_in2_rows.Extend(in1_rows.begin(), in1_rows.end());

auto in1_place = input1.place();
PADDLE_ENFORCE_EQ(in1_place.GetType() == phi::AllocationType::CPU,
true,
PADDLE_ENFORCE_EQ(in1_place.GetType(),
phi::AllocationType::CPU,
phi::errors::InvalidArgument(
"The running environment is not on the CPU place."));
auto in2_place = input2->place();
PADDLE_ENFORCE_EQ(in2_place.GetType() == phi::AllocationType::CPU,
true,
PADDLE_ENFORCE_EQ(in2_place.GetType(),
phi::AllocationType::CPU,
phi::errors::InvalidArgument(
"The running environment is not on the CPU place."));

Expand Down
20 changes: 10 additions & 10 deletions paddle/phi/kernels/funcs/selected_rows_functor.cu
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ struct SelectedRowsAdd<phi::GPUContext, T> {
auto* in1_data = in1_value.data<T>();

auto in1_place = input1.place();
PADDLE_ENFORCE_EQ(in1_place.GetType() == phi::AllocationType::GPU,
true,
PADDLE_ENFORCE_EQ(in1_place.GetType(),
phi::AllocationType::GPU,
phi::errors::InvalidArgument(
"The running environment is not on the GPU place."));
auto in2_place = input2.place();
PADDLE_ENFORCE_EQ(in2_place.GetType() == phi::AllocationType::GPU,
true,
PADDLE_ENFORCE_EQ(in2_place.GetType(),
phi::AllocationType::GPU,
phi::errors::InvalidArgument(
"The running environment is not on the GPU place."));
auto out_place = context.GetPlace();
PADDLE_ENFORCE_EQ(out_place.GetType() == phi::AllocationType::GPU,
true,
PADDLE_ENFORCE_EQ(out_place.GetType(),
phi::AllocationType::GPU,
phi::errors::InvalidArgument(
"The running environment is not on the GPU place."));

Expand Down Expand Up @@ -237,13 +237,13 @@ struct SelectedRowsAddTo<phi::GPUContext, T> {
}

auto in1_place = input1.place();
PADDLE_ENFORCE_EQ(in1_place.GetType() == phi::AllocationType::GPU,
true,
PADDLE_ENFORCE_EQ(in1_place.GetType(),
phi::AllocationType::GPU,
phi::errors::InvalidArgument(
"The running environment is not on the GPU place."));
auto in2_place = input2->place();
PADDLE_ENFORCE_EQ(in1_place.GetType() == phi::AllocationType::GPU,
true,
PADDLE_ENFORCE_EQ(in1_place.GetType(),
phi::AllocationType::GPU,
phi::errors::InvalidArgument(
"The running environment is not on the GPU place."));

Expand Down
4 changes: 2 additions & 2 deletions paddle/phi/kernels/gpu/put_along_axis_grad_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ void PutAlongAxisGradKernel(const Context& dev_ctx,
const std::string& reduce,
DenseTensor* x_grad,
DenseTensor* value_grad) {
PADDLE_ENFORCE_EQ(dev_ctx.GetPlace().GetType() == phi::AllocationType::GPU,
true,
PADDLE_ENFORCE_EQ(dev_ctx.GetPlace().GetType(),
phi::AllocationType::GPU,
errors::PreconditionNotMet(
"PutAlongAxisGradOpCUDAKernel only runs on GPU."));

Expand Down
4 changes: 2 additions & 2 deletions paddle/phi/kernels/gpu/put_along_axis_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ void PutAlongAxisKernel(const Context& dev_ctx,
int axis,
const std::string& reduce,
DenseTensor* out) {
PADDLE_ENFORCE_EQ(dev_ctx.GetPlace().GetType() == phi::AllocationType::GPU,
true,
PADDLE_ENFORCE_EQ(dev_ctx.GetPlace().GetType(),
phi::AllocationType::GPU,
errors::PreconditionNotMet(
"PutAlongAxisCUDAKernel only runs on GPU device."));

Expand Down
4 changes: 2 additions & 2 deletions paddle/phi/kernels/onednn/activation_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ void EltwiseForward(const OneDNNContext& dev_ctx,
float beta,
DenseTensor* out,
dnnl::algorithm algorithm) {
PADDLE_ENFORCE_EQ(dev_ctx.GetPlace().GetType() == phi::AllocationType::CPU,
true,
PADDLE_ENFORCE_EQ(dev_ctx.GetPlace().GetType(),
phi::AllocationType::CPU,
phi::errors::PreconditionNotMet(
"Operator DNNL eletwise_forward must use ONEDNNPlace"));

Expand Down
4 changes: 2 additions & 2 deletions paddle/phi/kernels/onednn/matmul_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,8 @@ void MatmulWithFlattenKernelINT8(const Context &dev_ctx,
int x_num_col_dims,
int y_num_col_dims,
DenseTensor *out) {
PADDLE_ENFORCE_EQ(dev_ctx.GetPlace().GetType() == AllocationType::CPU,
true,
PADDLE_ENFORCE_EQ(dev_ctx.GetPlace().GetType(),
AllocationType::CPU,
errors::PreconditionNotMet(
"oneDNN MatmulWithFlatten kernel must use CPUPlace"));

Expand Down
4 changes: 2 additions & 2 deletions paddle/phi/kernels/onednn/transpose_grad_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ void TransposeGradKernel(const Context& dev_ctx,
const DenseTensor& out_grad,
const std::vector<int>& axis,
DenseTensor* x_grad) {
PADDLE_ENFORCE_EQ(dev_ctx.GetPlace().GetType() == AllocationType::CPU,
true,
PADDLE_ENFORCE_EQ(dev_ctx.GetPlace().GetType(),
AllocationType::CPU,
errors::PreconditionNotMet(
"oneDNN TransposeGrad kernel must use CPUPlace"));
if (!x_grad) return;
Expand Down

0 comments on commit 5f521f0

Please sign in to comment.