diff --git a/paddle/fluid/operators/isfinite_op.cc b/paddle/fluid/operators/isfinite_op.cc index 8f68ef13e4a4f5..0d80a1c36b0711 100644 --- a/paddle/fluid/operators/isfinite_op.cc +++ b/paddle/fluid/operators/isfinite_op.cc @@ -124,7 +124,6 @@ namespace ops = paddle::operators; REGISTER_OP_MAKER(isinf, "isinf(X)"); REGISTER_OP_MAKER(isnan, "isnan(X)"); -REGISTER_OP_MAKER(isfinite, "isfinite(X)"); REGISTER_OP_CPU_KERNEL( isinf, @@ -139,10 +138,3 @@ REGISTER_OP_CPU_KERNEL( 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 80a65cbda916b7..300229cbeca668 100755 --- a/paddle/fluid/operators/isfinite_op.cu +++ b/paddle/fluid/operators/isfinite_op.cu @@ -33,11 +33,3 @@ REGISTER_OP_CUDA_KERNEL( ops::OverflowKernel, ops::OverflowKernel, ops::OverflowKernel); - -REGISTER_OP_CUDA_KERNEL( - isfinite, - ops::OverflowKernel, - 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 aab7953d6d1030..5352ccc99df92e 100644 --- a/paddle/fluid/operators/isfinite_op.h +++ b/paddle/fluid/operators/isfinite_op.h @@ -156,12 +156,6 @@ struct NANFunctor { } }; -struct IsfiniteFunctor { - void operator()(const phi::DenseTensor& tensor, phi::DenseTensor* out) { - framework::TensorIsfinite(tensor, out); - } -}; - template class OverflowKernel : public framework::OpKernel { public: diff --git a/test/legacy_test/test_isfinite_op.py b/test/legacy_test/test_isfinite_op.py deleted file mode 100755 index 94e52ee9f2e96c..00000000000000 --- a/test/legacy_test/test_isfinite_op.py +++ /dev/null @@ -1,175 +0,0 @@ -# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import unittest - -import numpy as np -from op_test import OpTest, convert_float_to_uint16 - -from paddle.base import core - - -class TestInf(OpTest): - def setUp(self): - self.op_type = "isinf" - self.dtype = np.float32 - self.init_dtype() - - x = np.random.uniform(0.1, 1, [11, 17]).astype(self.dtype) - x[0] = np.inf - x[-1] = np.inf - - self.inputs = {'X': x} - self.outputs = {'Out': np.array([True]).astype(self.dtype)} - - def init_dtype(self): - pass - - def test_output(self): - self.check_output() - - -@unittest.skipIf( - not core.is_compiled_with_cuda(), "core is not compiled with CUDA" -) -class TestFP16Inf(TestInf): - def init_dtype(self): - self.dtype = np.float16 - - -# BFP16 isinf Test -@unittest.skipIf( - not core.is_compiled_with_cuda() - or not core.is_bfloat16_supported(core.CUDAPlace(0)), - "core is not compiled with CUDA or not support the bfloat16", -) -class TestInfBF16(OpTest): - def setUp(self): - self.op_type = "isinf" - self.dtype = np.uint16 - x = np.random.uniform(0.1, 1, [11, 17]).astype(np.float32) - x[0] = np.inf - x[-1] = np.inf - - out = np.array([True]) - self.inputs = {'X': convert_float_to_uint16(x)} - self.outputs = {'Out': out} - - def test_output(self): - self.check_output_with_place(core.CUDAPlace(0)) - - -class TestNAN(OpTest): - def setUp(self): - self.op_type = "isnan" - self.dtype = np.float32 - self.init_dtype() - - x = np.random.uniform(0.1, 1, [11, 17]).astype(self.dtype) - x[0] = np.nan - x[-1] = np.nan - - self.inputs = {'X': x} - self.outputs = {'Out': np.array([True]).astype(self.dtype)} - - def init_dtype(self): - pass - - def test_output(self): - self.check_output() - - -@unittest.skipIf( - not core.is_compiled_with_cuda(), "core is not compiled with CUDA" -) -class TestFP16NAN(TestNAN): - def init_dtype(self): - self.dtype = np.float16 - - -# BFP16 isnan Test -@unittest.skipIf( - not core.is_compiled_with_cuda() - or not core.is_bfloat16_supported(core.CUDAPlace(0)), - "core is not compiled with CUDA or not support the bfloat16", -) -class TestNANBF16(OpTest): - def setUp(self): - self.op_type = "isnan" - self.dtype = np.uint16 - x = np.random.uniform(0.1, 1, [11, 17]).astype(np.float32) - x[0] = np.nan - x[-1] = np.nan - - out = np.array([True]) - self.inputs = {'X': convert_float_to_uint16(x)} - self.outputs = {'Out': out} - - def test_output(self): - self.check_output_with_place(core.CUDAPlace(0)) - - -class TestIsfinite(OpTest): - def setUp(self): - self.op_type = "isfinite" - self.dtype = np.float32 - self.init_dtype() - - x = np.random.uniform(0.1, 1, [11, 17]).astype(self.dtype) - x[0] = np.inf - x[-1] = np.nan - out = np.isinf(x) | np.isnan(x) - - self.inputs = {'X': x} - self.outputs = {'Out': np.array([False]).astype(self.dtype)} - - def init_dtype(self): - pass - - def test_output(self): - self.check_output() - - -@unittest.skipIf( - not core.is_compiled_with_cuda(), "core is not compiled with CUDA" -) -class TestFP16Isfinite(TestIsfinite): - def init_dtype(self): - self.dtype = np.float16 - - -# BFP16 isfinite Test -@unittest.skipIf( - not core.is_compiled_with_cuda() - or not core.is_bfloat16_supported(core.CUDAPlace(0)), - "core is not compiled with CUDA or not support the bfloat16", -) -class TestIsfiniteBF16(OpTest): - def setUp(self): - self.op_type = "isfinite" - self.dtype = np.uint16 - x = np.random.uniform(0.1, 1, [11, 17]).astype(np.float32) - x[0] = np.inf - x[-1] = np.nan - - out = np.array([False]) - self.inputs = {'X': convert_float_to_uint16(x)} - self.outputs = {'Out': out} - - def test_output(self): - self.check_output_with_place(core.CUDAPlace(0)) - - -if __name__ == '__main__': - unittest.main() diff --git a/tools/parallel_UT_rule.py b/tools/parallel_UT_rule.py index 8db28827b28302..b73e4dd5dc1540 100755 --- a/tools/parallel_UT_rule.py +++ b/tools/parallel_UT_rule.py @@ -1295,7 +1295,6 @@ 'test_quantization_scale_pass', 'test_segment_ops', 'test_layers', - 'test_isfinite_op', 'test_imperative_qat_channelwise', 'test_eye_op', 'test_imperative_framework', @@ -2836,7 +2835,6 @@ 'test_shape_op', 'test_strided_slice_op', 'test_switch_case', - 'test_isfinite_op', 'test_conv_elementwise_add_act_fuse_pass', 'test_unbind_op', 'test_size_op', diff --git a/tools/static_mode_white_list.py b/tools/static_mode_white_list.py index d60c9255f69a7d..c863c1e408f2e3 100755 --- a/tools/static_mode_white_list.py +++ b/tools/static_mode_white_list.py @@ -284,8 +284,6 @@ 'test_io_save_load', 'test_iou_similarity_op', 'test_ir_memory_optimize_pass', - 'test_is_empty_op', - 'test_isfinite_op', 'test_kldiv_loss_op', 'test_kron_op', 'test_l1_norm_op',