diff --git a/backends/npu/tests/unittests/test_compare_op_npu.py b/backends/npu/tests/unittests/test_compare_op_npu.py index 877e0533a..874470462 100755 --- a/backends/npu/tests/unittests/test_compare_op_npu.py +++ b/backends/npu/tests/unittests/test_compare_op_npu.py @@ -115,14 +115,17 @@ def test_dynamic_api_different_type(self): return paddle.disable_static() paddle.set_device("npu:0") - y = np.random.random(size=(10, 7)).astype("int32") + y = np.random.random(size=(10, 7)).astype("float32") if typename == "bfloat16": x = np.random.random(size=(10, 7)).astype(np.float32) else: x = np.random.random(size=(10, 7)).astype(typename) real_result = callback(x, y) - x = paddle.to_tensor(x, dtype=typename) - y = paddle.to_tensor(y, dtype="float32") + if typename in {"bool", "int32", "int64"}: + x = paddle.to_tensor(x, dtype="float32") + else: + x = paddle.to_tensor(x, dtype=typename) + y = paddle.to_tensor(y, dtype=x.dtype) op = eval("paddle.%s" % (self.op_type)) out = op(x, y) self.assertEqual((out.numpy() == real_result).all(), True)