Skip to content

Commit 066b3a0

Browse files
support out (#74582)
1 parent 6e31ae0 commit 066b3a0

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

python/paddle/tensor/creation.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,7 @@ def ones(
12711271
shape: ShapeLike,
12721272
dtype: DTypeLike | None = None,
12731273
*,
1274+
out: paddle.Tensor | None = None,
12741275
device: PlaceLike | None = None,
12751276
requires_grad: bool = False,
12761277
name: str | None = None,
@@ -1284,6 +1285,7 @@ def ones(
12841285
If ``shape`` is an Tensor, it should be an 1-D Tensor which represents a list.
12851286
dtype (np.dtype|str, optional): Data type of output Tensor, it should be one of
12861287
bool, float16, float32, float64, int32 and int64. If it is set to None, the data type will be float32.
1288+
out(Tensor, optional): The output tensor.
12871289
device(PlaceLike|None, optional): The desired device of returned tensor.
12881290
if None, uses the current device for the default tensor type (see paddle.device.set_device()).
12891291
device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. Default: None.
@@ -1325,6 +1327,7 @@ def ones(
13251327
shape,
13261328
1,
13271329
dtype,
1330+
out=out,
13281331
device=device,
13291332
requires_grad=requires_grad,
13301333
name=name,
@@ -1390,6 +1393,7 @@ def zeros(
13901393
shape: ShapeLike,
13911394
dtype: DTypeLike | None = None,
13921395
*,
1396+
out: paddle.Tensor | None = None,
13931397
device: PlaceLike | None = None,
13941398
requires_grad: bool = False,
13951399
name: str | None = None,
@@ -1403,12 +1407,13 @@ def zeros(
14031407
If ``shape`` is an Tensor, it should be an 1-D Tensor which represents a list.
14041408
dtype(np.dtype|str, optional): Data type of output Tensor, it supports
14051409
bool, float16, float32, float64, int32 and int64. Default: if None, the data type is float32.
1406-
name(str|None, optional): The default value is None. Normally there is no need for user to set this
14071410
property. For more information, please refer to :ref:`api_guide_Name`.
1411+
out(Tensor, optional): The output tensor.
14081412
device(PlaceLike|None, optional): The desired device of returned tensor.
14091413
if None, uses the current device for the default tensor type (see paddle.device.set_device()).
14101414
device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. Default: None.
14111415
requires_grad(bool, optional): If autograd should record operations on the returned tensor. Default: False.
1416+
name(str|None, optional): The default value is None. Normally there is no need for user to set this
14121417
14131418
Returns:
14141419
Tensor: A tensor of data type :attr:`dtype` with shape :attr:`shape` and all elements set to 0.
@@ -1445,6 +1450,7 @@ def zeros(
14451450
shape,
14461451
0,
14471452
dtype,
1453+
out=out,
14481454
device=device,
14491455
requires_grad=requires_grad,
14501456
name=name,
@@ -1516,6 +1522,7 @@ def eye(
15161522
num_columns: int | None = None,
15171523
dtype: DTypeLike | None = None,
15181524
*,
1525+
out: paddle.Tensor | None = None,
15191526
device: PlaceLike | None = None,
15201527
requires_grad: bool = False,
15211528
name: str | None = None,
@@ -1531,6 +1538,7 @@ def eye(
15311538
dtype(np.dtype|str, optional): The data type of the returned Tensor.
15321539
It should be int32, int64, float16, float32, float64, complex64, complex128. Default: if None, the data type
15331540
is float32.
1541+
out(Tensor, optional): The output tensor.
15341542
device(PlaceLike|None, optional): The desired device of returned tensor.
15351543
if None, uses the current device for the default tensor type (see paddle.device.set_device()).
15361544
device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. Default: None.
@@ -1585,6 +1593,7 @@ def _check_attr(attr, message):
15851593
if device is not None
15861594
else _current_expected_place()
15871595
),
1596+
out=out,
15881597
)
15891598
if requires_grad is True:
15901599
tensor.stop_gradient = False
@@ -1629,6 +1638,7 @@ def full(
16291638
fill_value: bool | float | paddle.Tensor,
16301639
dtype: DTypeLike | None = None,
16311640
*,
1641+
out: paddle.Tensor | None = None,
16321642
device: PlaceLike | None = None,
16331643
requires_grad: bool = False,
16341644
name: str | None = None,
@@ -1651,6 +1661,7 @@ def full(
16511661
dtype(np.dtype|str, optional): Data type of the output Tensor
16521662
which can be float16, float32, float64, int32, int64, if dtype is `None`, the data
16531663
type of created Tensor is `float32`.
1664+
out(Tensor, optional): The output tensor.
16541665
device(PlaceLike|None, optional): The desired device of returned tensor.
16551666
if None, uses the current device for the default tensor type (see paddle.device.set_device()).
16561667
device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. Default: None.
@@ -1706,7 +1717,12 @@ def full(
17061717
dtype = paddle.get_default_dtype()
17071718

17081719
tensor = fill_constant(
1709-
shape=shape, dtype=dtype, value=fill_value, place=device, name=name
1720+
shape=shape,
1721+
dtype=dtype,
1722+
value=fill_value,
1723+
out=out,
1724+
place=device,
1725+
name=name,
17101726
)
17111727
if requires_grad is True:
17121728
tensor.stop_gradient = False
@@ -2576,6 +2592,7 @@ def empty(
25762592
shape: ShapeLike,
25772593
dtype: DTypeLike | None = None,
25782594
*,
2595+
out: paddle.Tensor | None = None,
25792596
device: PlaceLike | None = None,
25802597
requires_grad: bool = False,
25812598
name: str | None = None,
@@ -2591,6 +2608,7 @@ def empty(
25912608
which can be bool, float16, float32, float64, int32, int64, complex64, complex128 if dtype is `None`, the data
25922609
type of created Tensor use global default dtype (see ``get_default_dtype``
25932610
for details).
2611+
out(Tensor, optional): The output tensor.
25942612
device(PlaceLike|None, optional): The desired device of returned tensor.
25952613
if None, uses the current device for the default tensor type (see paddle.device.set_device()).
25962614
device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. Default: None.
@@ -2680,6 +2698,7 @@ def empty(
26802698
if device is not None
26812699
else _current_expected_place()
26822700
),
2701+
out=out,
26832702
)
26842703
if requires_grad is True:
26852704
tensor.stop_gradient = False
@@ -3201,7 +3220,7 @@ def complex(
32013220
real (Tensor): The real component. The data type should be 'float32' or 'float64'.
32023221
imag (Tensor): The image component. The data type should be the same as ``real``.
32033222
name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
3204-
out (Tensor|None, optional): The output tensor. Default: None.
3223+
out(Tensor|None, optional): The output tensor. Default: None.
32053224
32063225
Returns:
32073226
Tensor, The output tensor. The data type is 'complex64' or 'complex128', with the same precision as ``real`` and ``imag``.

0 commit comments

Comments
 (0)