未验证 提交 d841062b 编写于 作者: I Infinity_lee 提交者: GitHub

fix fp16 for tile op (#50913)

上级 bf05168c
......@@ -366,6 +366,20 @@ class TestTileAPI_ZeroDim(unittest.TestCase):
paddle.enable_static()
class Testfp16TileOp(unittest.TestCase):
def testfp16(self):
input_x = (np.random.random([1, 2, 3])).astype('float16')
with paddle.static.program_guard(paddle.static.Program()):
x = paddle.static.data(name="x", shape=[1, 2, 3], dtype='float16')
repeat_times = [2, 2]
out = paddle.tile(x, repeat_times=repeat_times)
if paddle.is_compiled_with_cuda():
place = paddle.CUDAPlace(0)
exe = paddle.static.Executor(place)
exe.run(paddle.static.default_startup_program())
out = exe.run(feed={'x': input_x}, fetch_list=[out])
if __name__ == "__main__":
paddle.enable_static()
unittest.main()
......@@ -3084,7 +3084,7 @@ def tile(x, repeat_times, name=None):
Both the number of dimensions of ``x`` and the number of elements in ``repeat_times`` should be less than or equal to 6.
Args:
x (Tensor): The input tensor, its data type should be bool, float32, float64, int32 or int64.
x (Tensor): The input tensor, its data type should be bool, float16, float32, float64, int32 or int64.
repeat_times (list|tuple|Tensor): The number of repeating times. If repeat_times is a list or tuple, all its elements
should be integers or 1-D Tensors with the data type int32. If repeat_times is a Tensor, it should be an 1-D Tensor with the data type int32.
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
......@@ -3145,7 +3145,10 @@ def tile(x, repeat_times, name=None):
), 'Elements in repeat_times must be 1-D Tensors or integers.'
check_variable_and_dtype(
x, 'x', ['bool', 'float32', 'float64', 'int32', 'int64'], 'tile'
x,
'x',
['bool', 'float16', 'float32', 'float64', 'int32', 'int64'],
'tile',
)
if convert_dtype(x.dtype) == 'bool' and not x.stop_gradient:
raise ValueError(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册