Skip to content

Commit b2df5fe

Browse files
committed
[API-Compat] Fixed min/max out mechanism
1 parent 5297d47 commit b2df5fe

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

python/paddle/tensor/compat.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -673,14 +673,13 @@ def min(
673673
_check_out_status(out, False)
674674
ret = _C_ops.minimum(input, dim_or_other)
675675

676-
if out is None:
677-
return ret
678-
else:
676+
if out is not None:
679677
if isinstance(ret, MinMaxRetType):
680678
paddle.assign(ret.values, out[0])
681679
paddle.assign(ret.indices, out[1])
682680
else:
683681
paddle.assign(ret, out)
682+
return ret
684683

685684

686685
@ForbidKeywordsDecorator(
@@ -823,11 +822,10 @@ def max(
823822
_check_out_status(out, False)
824823
ret = _C_ops.maximum(input, dim_or_other)
825824

826-
if out is None:
827-
return ret
828-
else:
825+
if out is not None:
829826
if isinstance(ret, MinMaxRetType):
830827
paddle.assign(ret.values, out[0])
831828
paddle.assign(ret.indices, out[1])
832829
else:
833830
paddle.assign(ret, out)
831+
return ret

0 commit comments

Comments
 (0)