diff --git a/python/paddle/tensor/creation.py b/python/paddle/tensor/creation.py index b68f8e48df26d7..07c92fb2a26283 100644 --- a/python/paddle/tensor/creation.py +++ b/python/paddle/tensor/creation.py @@ -1267,6 +1267,7 @@ def ones( shape: ShapeLike, dtype: DTypeLike | None = None, *, + out: paddle.Tensor | None = None, device: PlaceLike | None = None, requires_grad: bool = False, name: str | None = None, @@ -1280,6 +1281,7 @@ def ones( If ``shape`` is an Tensor, it should be an 1-D Tensor which represents a list. dtype (np.dtype|str, optional): Data type of output Tensor, it should be one of bool, float16, float32, float64, int32 and int64. If it is set to None, the data type will be float32. + out(Tensor, optional): The output tensor. device(PlaceLike|None, optional): The desired device of returned tensor. if None, uses the current device for the default tensor type (see paddle.device.set_device()). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. Default: None. @@ -1321,6 +1323,7 @@ def ones( shape, 1, dtype, + out=out, device=device, requires_grad=requires_grad, name=name, @@ -1385,6 +1388,7 @@ def zeros( shape: ShapeLike, dtype: DTypeLike | None = None, *, + out: paddle.Tensor | None = None, device: PlaceLike | None = None, requires_grad: bool = False, name: str | None = None, @@ -1398,12 +1402,13 @@ def zeros( If ``shape`` is an Tensor, it should be an 1-D Tensor which represents a list. dtype(np.dtype|str, optional): Data type of output Tensor, it supports bool, float16, float32, float64, int32 and int64. Default: if None, the data type is float32. - name(str|None, optional): The default value is None. Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name`. + out(Tensor, optional): The output tensor. device(PlaceLike|None, optional): The desired device of returned tensor. if None, uses the current device for the default tensor type (see paddle.device.set_device()). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. Default: None. requires_grad(bool, optional): If autograd should record operations on the returned tensor. Default: False. + name(str|None, optional): The default value is None. Normally there is no need for user to set this Returns: Tensor: A tensor of data type :attr:`dtype` with shape :attr:`shape` and all elements set to 0. @@ -1440,6 +1445,7 @@ def zeros( shape, 0, dtype, + out=out, device=device, requires_grad=requires_grad, name=name, @@ -1505,6 +1511,7 @@ def eye( num_columns: int | None = None, dtype: DTypeLike | None = None, *, + out: paddle.Tensor | None = None, device: PlaceLike | None = None, requires_grad: bool = False, name: str | None = None, @@ -1520,6 +1527,7 @@ def eye( dtype(np.dtype|str, optional): The data type of the returned Tensor. It should be int32, int64, float16, float32, float64, complex64, complex128. Default: if None, the data type is float32. + out(Tensor, optional): The output tensor. device(PlaceLike|None, optional): The desired device of returned tensor. if None, uses the current device for the default tensor type (see paddle.device.set_device()). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. Default: None. @@ -1574,6 +1582,7 @@ def _check_attr(attr, message): if device is not None else _current_expected_place() ), + out=out, ) if requires_grad is True: tensor.stop_gradient = False @@ -1617,6 +1626,7 @@ def full( fill_value: bool | float | paddle.Tensor, dtype: DTypeLike | None = None, *, + out: paddle.Tensor | None = None, device: PlaceLike | None = None, requires_grad: bool = False, name: str | None = None, @@ -1634,6 +1644,7 @@ def full( dtype(np.dtype|str, optional): Data type of the output Tensor which can be float16, float32, float64, int32, int64, if dtype is `None`, the data type of created Tensor is `float32`. + out(Tensor, optional): The output tensor. device(PlaceLike|None, optional): The desired device of returned tensor. if None, uses the current device for the default tensor type (see paddle.device.set_device()). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. Default: None. @@ -1689,7 +1700,12 @@ def full( dtype = paddle.get_default_dtype() tensor = fill_constant( - shape=shape, dtype=dtype, value=fill_value, place=device, name=name + shape=shape, + dtype=dtype, + value=fill_value, + out=out, + place=device, + name=name, ) if requires_grad is True: tensor.stop_gradient = False @@ -2559,6 +2575,7 @@ def empty( shape: ShapeLike, dtype: DTypeLike | None = None, *, + out: paddle.Tensor | None = None, device: PlaceLike | None = None, requires_grad: bool = False, name: str | None = None, @@ -2574,6 +2591,7 @@ def empty( which can be bool, float16, float32, float64, int32, int64, complex64, complex128 if dtype is `None`, the data type of created Tensor use global default dtype (see ``get_default_dtype`` for details). + out(Tensor, optional): The output tensor. device(PlaceLike|None, optional): The desired device of returned tensor. if None, uses the current device for the default tensor type (see paddle.device.set_device()). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. Default: None. @@ -2663,6 +2681,7 @@ def empty( if device is not None else _current_expected_place() ), + out=out, ) if requires_grad is True: tensor.stop_gradient = False @@ -3178,7 +3197,7 @@ def complex( real (Tensor): The real component. The data type should be 'float32' or 'float64'. imag (Tensor): The image component. The data type should be the same as ``real``. name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None. - out (Tensor|None, optional): The output tensor. Default: None. + out(Tensor|None, optional): The output tensor. Default: None. Returns: Tensor, The output tensor. The data type is 'complex64' or 'complex128', with the same precision as ``real`` and ``imag``.