From 14ed2f548d87f347544a174f361ecec7f3c4bf14 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Thu, 10 Feb 2022 13:20:42 +0800 Subject: [PATCH] [pten] update isnan registration (#39419) * update isnan registration * fix compile --- paddle/fluid/operators/isfinite_op.cc | 31 ++++++++++++++++++++- paddle/fluid/operators/isfinite_op.cu | 39 +++++++++++++++++++-------- paddle/fluid/operators/isfinite_op.h | 5 ---- 3 files changed, 58 insertions(+), 17 deletions(-) diff --git a/paddle/fluid/operators/isfinite_op.cc b/paddle/fluid/operators/isfinite_op.cc index c4bc3a7fda..7fdb0599eb 100644 --- a/paddle/fluid/operators/isfinite_op.cc +++ b/paddle/fluid/operators/isfinite_op.cc @@ -132,4 +132,33 @@ namespace ops = paddle::operators; REGISTER_OP_MAKER(isinf, "isinf(X)"); REGISTER_OP_MAKER(isnan, "isnan(X)"); REGISTER_OP_MAKER(isfinite, "isfinite(X)"); -FOR_EACH_KERNEL_FUNCTOR(REGISTER_OVERFLOW_CPU_KERNEL); + +REGISTER_OP_CPU_KERNEL(isinf, + ops::OverflowKernel, + ops::OverflowKernel, + ops::OverflowKernel, + ops::OverflowKernel); + +REGISTER_OP_CPU_KERNEL(isnan, + ops::OverflowKernel, + ops::OverflowKernel, + ops::OverflowKernel, + ops::OverflowKernel); + +REGISTER_OP_CPU_KERNEL(isfinite, + ops::OverflowKernel, + ops::OverflowKernel, + ops::OverflowKernel, + ops::OverflowKernel); diff --git a/paddle/fluid/operators/isfinite_op.cu b/paddle/fluid/operators/isfinite_op.cu index 995969cd42..e233e37136 100644 --- a/paddle/fluid/operators/isfinite_op.cu +++ b/paddle/fluid/operators/isfinite_op.cu @@ -17,15 +17,32 @@ namespace ops = paddle::operators; namespace plat = paddle::platform; -#define REGISTER_OVERFLOW_CUDA_KERNEL(op_type, functor) \ - REGISTER_OP_CUDA_KERNEL( \ - op_type, ops::OverflowKernel, \ - ops::OverflowKernel, \ - ops::OverflowKernel, \ - ops::OverflowKernel); +REGISTER_OP_CUDA_KERNEL( + isinf, ops::OverflowKernel, + ops::OverflowKernel, + ops::OverflowKernel, + ops::OverflowKernel); -FOR_EACH_KERNEL_FUNCTOR(REGISTER_OVERFLOW_CUDA_KERNEL); +REGISTER_OP_CUDA_KERNEL(isnan, + ops::OverflowKernel, + ops::OverflowKernel, + ops::OverflowKernel, + ops::OverflowKernel); + +REGISTER_OP_CUDA_KERNEL( + isfinite, ops::OverflowKernel, + ops::OverflowKernel, + ops::OverflowKernel, + ops::OverflowKernel); diff --git a/paddle/fluid/operators/isfinite_op.h b/paddle/fluid/operators/isfinite_op.h index abed0e6903..7f59af1be0 100644 --- a/paddle/fluid/operators/isfinite_op.h +++ b/paddle/fluid/operators/isfinite_op.h @@ -73,8 +73,3 @@ class OverflowKernel : public framework::OpKernel { } // namespace operators } // namespace paddle - -#define FOR_EACH_KERNEL_FUNCTOR(__macro) \ - __macro(isinf, InfinityFunctor); \ - __macro(isnan, NANFunctor); \ - __macro(isfinite, IsfiniteFunctor); -- GitLab