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

add float16 to equal (#50933)

上级 69d49aba
......@@ -467,6 +467,18 @@ class API_TestElementwise_Equal(unittest.TestCase):
(res,) = exe.run(fetch_list=[out])
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):
def test_place_1(self):
......
......@@ -431,8 +431,8 @@ def equal(x, y, name=None):
The output has no gradient.
Args:
x(Tensor): Tensor, data type is bool, float32, float64, int32, int64.
y(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, float16, float32, float64, int32, int64.
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`.
......@@ -465,13 +465,13 @@ def equal(x, y, name=None):
check_variable_and_dtype(
x,
"x",
["bool", "float32", "float64", "int32", "int64"],
["bool", "float16", "float32", "float64", "int32", "int64"],
"equal",
)
check_variable_and_dtype(
y,
"y",
["bool", "float32", "float64", "int32", "int64"],
["bool", "float16", "float32", "float64", "int32", "int64"],
"equal",
)
helper = LayerHelper("equal", **locals())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册