Skip to content

Commit 17f080e

Browse files
committed
[API-Compat] Fixed min/max out mechanism
1 parent 822e8d7 commit 17f080e

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
@@ -672,14 +672,13 @@ def min(
672672
_check_out_status(out, False)
673673
ret = _C_ops.minimum(input, dim_or_other)
674674

675-
if out is None:
676-
return ret
677-
else:
675+
if out is not None:
678676
if isinstance(ret, MinMaxRetType):
679677
paddle.assign(ret.values, out[0])
680678
paddle.assign(ret.indices, out[1])
681679
else:
682680
paddle.assign(ret, out)
681+
return ret
683682

684683

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

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

0 commit comments

Comments
 (0)