From f12f2a9d94506e440678bbd31ff960ca494896e0 Mon Sep 17 00:00:00 2001 From: Ryan <44900829+DrRyanHuang@users.noreply.github.com> Date: Mon, 30 Jan 2023 15:13:35 +0800 Subject: [PATCH] bool => bool_ (#49961) --- .../paddle/fluid/tests/unittests/ipu/test_flip_op_ipu.py | 4 ++-- .../ir/inference/test_trt_convert_compare_and_logical.py | 4 ++-- .../ir/inference/test_trt_convert_fill_any_like.py | 2 +- .../unittests/ir/inference/test_trt_convert_one_hot.py | 2 +- .../unittests/ir/inference/test_trt_convert_unary.py | 4 ++-- .../unittests/ir/inference/test_trt_convert_where.py | 4 ++-- .../fluid/tests/unittests/npu/test_assign_value_op_npu.py | 4 ++-- .../paddle/fluid/tests/unittests/test_assign_value_op.py | 4 ++-- .../unittests/test_fused_multi_transformer_int8_op.py | 2 +- .../tests/unittests/test_fused_multi_transformer_op.py | 2 +- .../fluid/tests/unittests/test_update_loss_scaling_op.py | 2 +- .../fluid/tests/unittests/xpu/test_assign_value_op_xpu.py | 4 ++-- .../fluid/tests/unittests/xpu/test_bitwise_op_xpu.py | 2 +- .../fluid/tests/unittests/xpu/test_logical_op_xpu.py | 8 ++++---- 14 files changed, 24 insertions(+), 24 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/ipu/test_flip_op_ipu.py b/python/paddle/fluid/tests/unittests/ipu/test_flip_op_ipu.py index 179f30cb1e8..f9cca510208 100644 --- a/python/paddle/fluid/tests/unittests/ipu/test_flip_op_ipu.py +++ b/python/paddle/fluid/tests/unittests/ipu/test_flip_op_ipu.py @@ -80,8 +80,8 @@ class TestCase1(TestBase): class TestCase2(TestBase): def set_feed(self): data = np.random.randint(0, 2, size=[4, 3, 2, 2]) - self.feed_fp32 = {'x': data.astype(np.bool)} - self.feed_fp16 = {'x': data.astype(np.bool)} + self.feed_fp32 = {'x': data.astype(np.bool_)} + self.feed_fp16 = {'x': data.astype(np.bool_)} if __name__ == "__main__": diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_compare_and_logical.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_compare_and_logical.py index 21b51beded0..e59b9a0cd41 100755 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_compare_and_logical.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_compare_and_logical.py @@ -46,14 +46,14 @@ class TrtConvertLogicalTest(TrtLayerAutoScanTest): "op_inputs": {"X": ["input_data1"]}, "op_outputs": {"Out": ["cast_output_data1"]}, "op_attrs": dics[1], - "outputs_dtype": {"cast_output_data1": np.bool}, + "outputs_dtype": {"cast_output_data1": np.bool_}, }, { "op_type": "cast", "op_inputs": {"X": ["input_data2"]}, "op_outputs": {"Out": ["cast_output_data3"]}, "op_attrs": dics[1], - "outputs_dtype": {"cast_output_data3": np.bool}, + "outputs_dtype": {"cast_output_data3": np.bool_}, }, { "op_type": op_type, diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_fill_any_like.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_fill_any_like.py index 64a63ef1ba3..40b0b829d8f 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_fill_any_like.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_fill_any_like.py @@ -36,7 +36,7 @@ class TrtConvertExpandV2Test(TrtLayerAutoScanTest): if self.dims == 4: self.input_shape = [1, 1, 4, 6] if self.dtype == 0: - return np.random.random([1, 1, 4, 6]).astype(np.bool) + return np.random.random([1, 1, 4, 6]).astype(np.bool_) elif self.dtype == 2 or self.dtype == -1: return np.random.random([1, 1, 4, 6]).astype(np.int32) elif self.dtype == 3: diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_one_hot.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_one_hot.py index 60e654bb95e..53574a3fd27 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_one_hot.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_one_hot.py @@ -59,7 +59,7 @@ class TrtConvertOneHotTest(TrtLayerAutoScanTest): }, "op_outputs": {"Out": ["output_data"]}, "op_attrs": dics[0], - "outputs_dtype": {"output_data": np.int}, + "outputs_dtype": {"output_data": np.int64}, }, ] ops = self.generate_op_config(ops_config) diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_unary.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_unary.py index 0fd95eaa29f..673ab597659 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_unary.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_unary.py @@ -193,7 +193,7 @@ class TrtConvertLogicalNotTest(TrtLayerAutoScanTest): "op_inputs": {"X": ["input_data"]}, "op_outputs": {"Out": ["cast_output_data1"]}, "op_attrs": dics[1], - "outputs_dtype": {"cast_output_data1": np.bool}, + "outputs_dtype": {"cast_output_data1": np.bool_}, }, { "op_type": op_type, @@ -202,7 +202,7 @@ class TrtConvertLogicalNotTest(TrtLayerAutoScanTest): }, "op_outputs": {"Out": ["cast_output_data0"]}, "op_attrs": dics[0], - "outputs_dtype": {"cast_output_data0": np.bool}, + "outputs_dtype": {"cast_output_data0": np.bool_}, }, { "op_type": "cast", diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_where.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_where.py index 10a9fef067b..269a8edae19 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_where.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_where.py @@ -73,7 +73,7 @@ class TrtConvertActivationTest(TrtLayerAutoScanTest): "op_inputs": {"X": ["condition_data"]}, "op_outputs": {"Out": ["condition_data_bool"]}, "op_attrs": {"in_dtype": 5, "out_dtype": 0}, - "outputs_dtype": {"condition_data_bool": np.bool}, + "outputs_dtype": {"condition_data_bool": np.bool_}, }, { "op_type": "where", @@ -84,7 +84,7 @@ class TrtConvertActivationTest(TrtLayerAutoScanTest): }, "op_outputs": {"Out": ["output_data"]}, "op_attrs": dics[0], - "outputs_dtype": {"condition_data_bool": np.bool}, + "outputs_dtype": {"condition_data_bool": np.bool_}, }, ] ops = self.generate_op_config(ops_config) diff --git a/python/paddle/fluid/tests/unittests/npu/test_assign_value_op_npu.py b/python/paddle/fluid/tests/unittests/npu/test_assign_value_op_npu.py index 1df24e54a16..e5acef812ba 100644 --- a/python/paddle/fluid/tests/unittests/npu/test_assign_value_op_npu.py +++ b/python/paddle/fluid/tests/unittests/npu/test_assign_value_op_npu.py @@ -70,7 +70,7 @@ class TestAssignValueNPUOp3(TestAssignValueNPUOp): class TestAssignValueNPUOp4(TestAssignValueNPUOp): def init_data(self): self.value = np.random.choice(a=[False, True], size=(2, 5)).astype( - np.bool + np.bool_ ) self.attrs["bool_values"] = [int(v) for v in self.value.flat] @@ -116,7 +116,7 @@ class TestAssignApi4(TestAssignApi): def setUp(self): self.init_dtype() self.value = np.random.choice(a=[False, True], size=(2, 5)).astype( - np.bool + np.bool_ ) self.place = ( fluid.NPUPlace(0) diff --git a/python/paddle/fluid/tests/unittests/test_assign_value_op.py b/python/paddle/fluid/tests/unittests/test_assign_value_op.py index c0a5554d39b..e0b6bd8bd42 100644 --- a/python/paddle/fluid/tests/unittests/test_assign_value_op.py +++ b/python/paddle/fluid/tests/unittests/test_assign_value_op.py @@ -60,7 +60,7 @@ class TestAssignValueOp3(TestAssignValueOp): class TestAssignValueOp4(TestAssignValueOp): def init_data(self): self.value = np.random.choice(a=[False, True], size=(2, 5)).astype( - np.bool + np.bool_ ) self.attrs["bool_values"] = [int(v) for v in self.value.flat] @@ -106,7 +106,7 @@ class TestAssignApi4(TestAssignApi): def setUp(self): self.init_dtype() self.value = np.random.choice(a=[False, True], size=(2, 5)).astype( - np.bool + np.bool_ ) self.place = ( fluid.CUDAPlace(0) diff --git a/python/paddle/fluid/tests/unittests/test_fused_multi_transformer_int8_op.py b/python/paddle/fluid/tests/unittests/test_fused_multi_transformer_int8_op.py index ab32d845151..991da5f41eb 100644 --- a/python/paddle/fluid/tests/unittests/test_fused_multi_transformer_int8_op.py +++ b/python/paddle/fluid/tests/unittests/test_fused_multi_transformer_int8_op.py @@ -175,7 +175,7 @@ class TestFusedMultiTransformerInt8Op(unittest.TestCase): self.x_type = np.float32 self.attn_mask_type = np.float64 - # self.attn_mask_type = np.bool + # self.attn_mask_type = np.bool_ self.pre_layer_norm = True self.has_attn_mask = True diff --git a/python/paddle/fluid/tests/unittests/test_fused_multi_transformer_op.py b/python/paddle/fluid/tests/unittests/test_fused_multi_transformer_op.py index f1b048102eb..e3da925a01e 100644 --- a/python/paddle/fluid/tests/unittests/test_fused_multi_transformer_op.py +++ b/python/paddle/fluid/tests/unittests/test_fused_multi_transformer_op.py @@ -109,7 +109,7 @@ class TestFusedMultiTransformerOp(OpTest): self.x_type = np.float32 self.attn_mask_type = np.float64 - # self.attn_mask_type = np.bool + # self.attn_mask_type = np.bool_ self.pre_layer_norm = True self.has_attn_mask = True diff --git a/python/paddle/fluid/tests/unittests/test_update_loss_scaling_op.py b/python/paddle/fluid/tests/unittests/test_update_loss_scaling_op.py index 00b943df85d..9cef4d72167 100644 --- a/python/paddle/fluid/tests/unittests/test_update_loss_scaling_op.py +++ b/python/paddle/fluid/tests/unittests/test_update_loss_scaling_op.py @@ -85,7 +85,7 @@ class TestUpdateLossScalingOp(OpTest): self.num_good_steps = np.array([999], dtype=np.int32) self.num_bad_steps = np.array([1], dtype=np.int32) self.zero_steps = np.array([0], dtype=np.int32) - self.stop_update = np.array([False], dtype=np.bool) + self.stop_update = np.array([False], dtype=np.bool_) self.attrs = { 'incr_every_n_steps': 1000, 'decr_every_n_nan_or_inf': 2, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_assign_value_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_assign_value_op_xpu.py index 560815cb56b..9030cc1e4f6 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_assign_value_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_assign_value_op_xpu.py @@ -75,7 +75,7 @@ class XPUTestAssignValueOp(XPUOpTestWrapper): class TestAssignValueOp4(TestAssignValueOp): def init_data(self): self.value = np.random.choice(a=[False, True], size=(2, 5)).astype( - np.bool + np.bool_ ) self.attrs["bool_values"] = [int(v) for v in self.value.flat] @@ -117,7 +117,7 @@ class TestAssignApi4(TestAssignApi): def setUp(self): self.init_dtype() self.value = np.random.choice(a=[False, True], size=(2, 5)).astype( - np.bool + np.bool_ ) self.place = fluid.XPUPlace(0) diff --git a/python/paddle/fluid/tests/unittests/xpu/test_bitwise_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_bitwise_op_xpu.py index 71aa969afc1..7bd11bed1a8 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_bitwise_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_bitwise_op_xpu.py @@ -300,7 +300,7 @@ class XPUTestBitwiseNot(XPUOpTestWrapper): self.outputs = {'Out': out} def init_case(self): - self.dtype = np.bool + self.dtype = np.bool_ self.x_shape = [2, 3, 4, 5] diff --git a/python/paddle/fluid/tests/unittests/xpu/test_logical_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_logical_op_xpu.py index 62120c0d1be..8783fb3bb41 100755 --- a/python/paddle/fluid/tests/unittests/xpu/test_logical_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_logical_op_xpu.py @@ -47,7 +47,7 @@ class XPUTestLogicalAnd(XPUOpTestWrapper): self.op_type = 'logical_and' # special range for bool dtype - if self.dtype == np.dtype(np.bool): + if self.dtype == np.dtype(np.bool_): self.low = 0 self.high = 2 @@ -108,7 +108,7 @@ class XPUTestLogicalOr(XPUOpTestWrapper): self.op_type = 'logical_or' # special range for bool dtype - if self.dtype == np.dtype(np.bool): + if self.dtype == np.dtype(np.bool_): self.low = 0 self.high = 2 @@ -169,7 +169,7 @@ class XPUTestLogicalXor(XPUOpTestWrapper): self.op_type = 'logical_xor' # special range for bool dtype - if self.dtype == np.dtype(np.bool): + if self.dtype == np.dtype(np.bool_): self.low = 0 self.high = 2 @@ -230,7 +230,7 @@ class XPUTestLogicalNot(XPUOpTestWrapper): self.op_type = 'logical_not' # special range for bool dtype - if self.dtype == np.dtype(np.bool): + if self.dtype == np.dtype(np.bool_): self.low = 0 self.high = 2 -- GitLab