Skip to content

Commit f51b3fb

Browse files
[API Compatiblity] Refine creation.py (#74711)
* refine creation.py * fix reason
1 parent 9edea54 commit f51b3fb

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

python/paddle/tensor/creation.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import paddle
2727
from paddle import _C_ops
28+
from paddle.utils import deprecated
2829
from paddle.utils.decorator_utils import ParamAliasDecorator, SizeArgsDecorator
2930
from paddle.utils.inplace_utils import inplace_apis_in_dygraph_only
3031

@@ -1543,8 +1544,8 @@ def zeros_like(
15431544

15441545

15451546
def eye(
1546-
num_rows: int,
1547-
num_columns: int | None = None,
1547+
num_rows: int | paddle.Tensor,
1548+
num_columns: int | paddle.Tensor | None = None,
15481549
dtype: DTypeLike | None = None,
15491550
name: str | None = None,
15501551
*,
@@ -1557,8 +1558,8 @@ def eye(
15571558
This function constructs 2-D Tensor with ones on the diagonal and zeros elsewhere.
15581559
15591560
Args:
1560-
num_rows(int): the number of rows in each batch Tensor.
1561-
num_columns(int|None, optional): the number of columns in each batch Tensor.
1561+
num_rows(int | paddle.Tensor): the number of rows in each batch Tensor.
1562+
num_columns(int | paddle.Tensor | None, optional): the number of columns in each batch Tensor.
15621563
If None, default: num_rows.
15631564
dtype(np.dtype|str, optional): The data type of the returned Tensor.
15641565
It should be int32, int64, float16, float32, float64, complex64, complex128. Default: if None, the data type
@@ -1953,6 +1954,12 @@ def arange(
19531954
return out
19541955

19551956

1957+
@deprecated(
1958+
reason=(
1959+
"paddle.range is deprecated and will be removed in a future release because its behavior is inconsistent with Python's range builtin."
1960+
"Instead, use paddle.arange, which produces values in [start, end)"
1961+
)
1962+
)
19561963
def range(
19571964
start: float | paddle.Tensor = 0,
19581965
end: float | paddle.Tensor | None = None,
@@ -2829,6 +2836,7 @@ def diag(
28292836
return out
28302837

28312838

2839+
@SizeArgsDecorator()
28322840
def empty(
28332841
shape: ShapeLike,
28342842
dtype: DTypeLike | None = None,

0 commit comments

Comments
 (0)