Skip to content

Commit d734316

Browse files
author
Yibing Liu
authored
Add fp16 support in squeeze & assign api (#22912)
test=release/1.7
1 parent 4ac2729 commit d734316

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

python/paddle/fluid/layers/nn.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5712,7 +5712,7 @@ def squeeze(input, axes, name=None):
57125712
Out.shape = [1,3,5]
57135713

57145714
Args:
5715-
input (Variable): The input Tensor. Support data type: float32, float64, int8, int32, int64.
5715+
input (Variable): The input Tensor. Support data type: float16, float32, float64, int8, int32, int64.
57165716
axes (list): One integer or List of integers, indicating the dimensions to be squeezed.
57175717
Axes range is :math:`[-rank(input), rank(input))`.
57185718
If axes is negative, :math:`axes=axes+rank(input)`.
@@ -5732,9 +5732,9 @@ def squeeze(input, axes, name=None):
57325732

57335733
"""
57345734
helper = LayerHelper("squeeze", **locals())
5735-
check_type_and_dtype(input, 'input', Variable,
5736-
['float32', 'float64', 'int8', 'int32', 'int64'],
5737-
'squeeze')
5735+
check_type_and_dtype(
5736+
input, 'input', Variable,
5737+
['float16', 'float32', 'float64', 'int8', 'int32', 'int64'], 'squeeze')
57385738
check_type(axes, 'axes', list, 'squeeze')
57395739
out = helper.create_variable_for_type_inference(dtype=input.dtype)
57405740
x_shape = helper.create_variable_for_type_inference(dtype=input.dtype)

python/paddle/fluid/layers/tensor.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def assign(input, output=None):
448448
449449
Parameters:
450450
input (Variable|numpy.ndarray): A tensor or numpy ndarray, its data type supports
451-
float32, float64, int32 and int64.
451+
float16, float32, float64, int32 and int64.
452452
output (Variable, optional): A tensor. If :attr:`output` is None, a new tensor will
453453
be created as :attr:`output`. Default: None.
454454
@@ -469,9 +469,10 @@ def assign(input, output=None):
469469
helper = LayerHelper('assign', **locals())
470470
check_type(input, 'input', (Variable, numpy.ndarray), 'assign')
471471
if isinstance(input, Variable):
472-
check_dtype(input.dtype, 'input',
473-
['float32', 'float64', 'int32', 'int64', 'bool'], 'assign',
474-
'(When the type of input in assign is Variable.)')
472+
check_dtype(
473+
input.dtype, 'input',
474+
['float16', 'float32', 'float64', 'int32', 'int64', 'bool'],
475+
'assign', '(When the type of input in assign is Variable.)')
475476
if output is None:
476477
output = helper.create_variable_for_type_inference(
477478
dtype=input.dtype)

0 commit comments

Comments
 (0)