未验证 提交 1e02769b 编写于 作者: 陈沧夜 提交者: GitHub

add float16 to equal (#50933)

上级 69d49aba
...@@ -467,6 +467,18 @@ class API_TestElementwise_Equal(unittest.TestCase): ...@@ -467,6 +467,18 @@ class API_TestElementwise_Equal(unittest.TestCase):
(res,) = exe.run(fetch_list=[out]) (res,) = exe.run(fetch_list=[out])
self.assertEqual((res == np.array([True, True])).all(), True) self.assertEqual((res == np.array([True, True])).all(), True)
def test_api_fp16(self):
paddle.enable_static()
with fluid.program_guard(fluid.Program(), fluid.Program()):
label = paddle.to_tensor([3, 3], dtype="float16")
limit = paddle.to_tensor([3, 2], dtype="float16")
out = paddle.equal(x=label, y=limit)
if core.is_compiled_with_cuda():
place = paddle.CUDAPlace(0)
exe = fluid.Executor(place)
(res,) = exe.run(fetch_list=[out])
self.assertEqual((res == np.array([True, False])).all(), True)
class TestCompareOpPlace(unittest.TestCase): class TestCompareOpPlace(unittest.TestCase):
def test_place_1(self): def test_place_1(self):
......
...@@ -431,8 +431,8 @@ def equal(x, y, name=None): ...@@ -431,8 +431,8 @@ def equal(x, y, name=None):
The output has no gradient. The output has no gradient.
Args: Args:
x(Tensor): Tensor, data type is bool, float32, float64, int32, int64. x(Tensor): Tensor, data type is bool, float16, float32, float64, int32, int64.
y(Tensor): Tensor, data type is bool, float32, float64, int32, int64. y(Tensor): Tensor, data type is bool, float16, float32, float64, int32, int64.
name(str, optional): The default value is None. Normally there is no need for name(str, optional): The default value is None. Normally there is no need for
user to set this property. For more information, please refer to :ref:`api_guide_Name`. user to set this property. For more information, please refer to :ref:`api_guide_Name`.
...@@ -465,13 +465,13 @@ def equal(x, y, name=None): ...@@ -465,13 +465,13 @@ def equal(x, y, name=None):
check_variable_and_dtype( check_variable_and_dtype(
x, x,
"x", "x",
["bool", "float32", "float64", "int32", "int64"], ["bool", "float16", "float32", "float64", "int32", "int64"],
"equal", "equal",
) )
check_variable_and_dtype( check_variable_and_dtype(
y, y,
"y", "y",
["bool", "float32", "float64", "int32", "int64"], ["bool", "float16", "float32", "float64", "int32", "int64"],
"equal", "equal",
) )
helper = LayerHelper("equal", **locals()) helper = LayerHelper("equal", **locals())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册