diff --git a/docs/api/paddle/Overview_cn.rst b/docs/api/paddle/Overview_cn.rst index 34ec012907a..20076c7be4b 100755 --- a/docs/api/paddle/Overview_cn.rst +++ b/docs/api/paddle/Overview_cn.rst @@ -150,6 +150,7 @@ tensor 数学操作 " :ref:`paddle.stanh ` ", "stanh 激活函数" " :ref:`paddle.std ` ", "沿给定的轴 axis 计算 x 中元素的标准差" " :ref:`paddle.subtract ` ", "逐元素相减算子" + " :ref:`paddle.sub ` ", "逐元素相减算子" " :ref:`paddle.remainder ` ", "逐元素取模算子" " :ref:`paddle.sum ` ", "对指定维度上的 Tensor 元素进行求和运算" " :ref:`paddle.tan ` ", "三角函数 tangent" @@ -245,11 +246,13 @@ tensor 数学操作原位(inplace)版本 " :ref:`paddle.sinc_ ` ", "Inplace 版本的 sinc API,对输入 x 采用 Inplace 策略" " :ref:`paddle.sinh_ ` ", "Inplace 版本的 sinh API,对输入 x 采用 Inplace 策略" " :ref:`paddle.subtract_ ` ", "Inplace 版本的 subtract API,对输入 x 采用 Inplace 策略" + " :ref:`paddle.sub_ ` ", "Inplace 版本的 sub API,对输入 x 采用 Inplace 策略" " :ref:`paddle.tan_ ` ", "Inplace 版本的 tan API,对输入 x 采用 Inplace 策略" " :ref:`paddle.cos_ ` ", "Inplace 版本的 cos API,对输入 x 采用 Inplace 策略" " :ref:`paddle.atan_ ` ", "Inplace 版本的 atan API,对输入 x 采用 Inplace 策略" " :ref:`paddle.acos_ ` ", "Inplace 版本的 acos API,对输入 x 采用 Inplace 策略" " :ref:`paddle.uniform_ ` ", "Inplace 版本的 uniform API,对输入 x 采用 Inplace 策略" + " :ref:`paddle.random_ ` ", "Inplace 版本的 random API,对输入 x 采用 Inplace 策略" " :ref:`paddle.lerp_ ` ", "Inplace 版本的 lerp API,对输入 x 采用 Inplace 策略" " :ref:`paddle.hypot_ ` ", "Inplace 版本的 hypot API,对输入 x 采用 Inplace 策略" " :ref:`paddle.multigammaln_ ` ", "Inplace 版本的 multigammaln API,对输入 x 采用 Inplace 策略" @@ -331,6 +334,7 @@ tensor 属性相关 " :ref:`paddle.broadcast_shape ` ", "返回对 x_shape 大小的 Tensor 和 y_shape 大小的 Tensor 做 broadcast 操作后得到的 shape" " :ref:`paddle.broadcast_shapes ` ", "返回对多个 shape 做 broadcast 操作后得到的 shape" " :ref:`paddle.is_floating_point ` ", "判断输入 Tensor 的数据类型是否为浮点类型" + " :ref:`paddle.Size ` ", "tuple 的子类, paddle.Tensor.size() 的返回类型,用于描述张量的维度大小。" .. _tensor_creation: diff --git a/docs/api/paddle/Size_cn.rst b/docs/api/paddle/Size_cn.rst new file mode 100644 index 00000000000..75dbd743ced --- /dev/null +++ b/docs/api/paddle/Size_cn.rst @@ -0,0 +1,20 @@ +.. _cn_api_paddle_Size: + +Size +------------------------------- + +.. py:class:: paddle.Size() +``paddle.Tensor.size()`` 的返回类型,用于描述张量的维度大小。作为 ``tuple`` 的子类,支持所有常见的序列操作(如索引、切片、拼接等)。 + +**参数** +::::::::: + - ``*args``:表示维度的整数序列或多个整数参数。 + +**返回** +::::::::: + - ``Size``:表示张量维度的特殊元组子类。 + +**代码示例** +::::::::: + +COPY-FROM: paddle.Size diff --git a/docs/api/paddle/Tensor_cn.rst b/docs/api/paddle/Tensor_cn.rst index 96e628e18fd..a044b73a56a 100755 --- a/docs/api/paddle/Tensor_cn.rst +++ b/docs/api/paddle/Tensor_cn.rst @@ -329,6 +329,19 @@ data **代码示例** COPY-FROM: paddle.Tensor.data +is_cuda +::::::::: + +如果 Tensor 存储在 GPU 上,则为 True,否则为 False。 + +**代码示例** + + .. code-block:: python + + import paddle + d = torch.Tensor([1,2,3]) + d.is_cuda + numpy() ::::::::: @@ -2828,7 +2841,7 @@ strided_slice(axes, starts, ends, strides) 请参考 :ref:`cn_api_paddle_strided_slice` -subtract(y, name=None) +subtract(y, name=None, \*, alpha=1, out=None) ::::::::: 返回:计算后的 Tensor @@ -2837,11 +2850,25 @@ subtract(y, name=None) 请参考 :ref:`cn_api_paddle_subtract` -subtract_(y, name=None) +subtract_(y, name=None, \*, alpha=1) ::::::::: Inplace 版本的 :ref:`cn_api_paddle_subtract` API,对输入 `x` 采用 Inplace 策略。 +sub(y, name=None, \*, alpha=1, out=None) +::::::::: + +返回:计算后的 Tensor + +返回类型:Tensor + +请参考 :ref:`cn_api_paddle_sub` + +sub_(y, name=None, \*, alpha=1) +::::::::: + +Inplace 版本的 :ref:`cn_api_paddle_sub` API,对输入 `x` 采用 Inplace 策略。 + sum(axis=None, dtype=None, keepdim=False, name=None) ::::::::: @@ -3028,6 +3055,15 @@ unbind(axis=0) 请参考 :ref:`cn_api_paddle_unbind` +random_(from=0, to=None, generator=None) +::::::::: + +返回:一个从均匀分布采样的随机数填充的 Tensor。输出 Tensor 将被置于输入 x 的位置。 + +返回类型:Tensor + +请参考 :ref:`cn_api_paddle_random_` + uniform_(min=-1.0, max=1.0, seed=0, name=None) ::::::::: diff --git a/docs/api/paddle/rand_like.rst b/docs/api/paddle/rand_like_cn.rst similarity index 98% rename from docs/api/paddle/rand_like.rst rename to docs/api/paddle/rand_like_cn.rst index 4a602bcb3c6..a0210946bb3 100644 --- a/docs/api/paddle/rand_like.rst +++ b/docs/api/paddle/rand_like_cn.rst @@ -22,4 +22,4 @@ rand_like 代码示例 ::::::::::: -COPY-FROM: paddle.rand_like \ No newline at end of file +COPY-FROM: paddle.rand_like diff --git a/docs/api/paddle/random__cn.rst b/docs/api/paddle/random__cn.rst new file mode 100644 index 00000000000..56c5e6fda37 --- /dev/null +++ b/docs/api/paddle/random__cn.rst @@ -0,0 +1,28 @@ +.. _cn_api_paddle_random_: + +random\_ +------------------------------- + +.. py:function:: paddle.random_(x, from=0, to=None, *, generator=None) + +将张量自身填充为从离散均匀分布[``from``, ``to`` - 1]范围内采样的随机数。若未指定参数,数值范围通常仅受张量数据类型的限制。 +但对于浮点类型,若未指定范围,则默认范围为[0, 2^尾数位数],以确保每个值均可被精确表示。例如,paddle.to_tensor(1, dtype='float64').uniform_() 将在 [0, 2^53] 范围内均匀分布。 +random_ 为 Inplace 版本实现,对输入 `x` 采用 Inplace 策略。 + +参数 +:::::::::::: + + - **x** (Tensor) - 输入多维 Tensor,可选的数据类型为 'int32'、'int64'、'float32'、'float64'、'float16'、'bfloat16'。 + - **from** (int,可选) - 生成随机值的范围下限,默认为 0。。 + - **to** (int|None,可选) - 生成随机值的范围上限(开区间),默认为 None。 + - **generator** (None) - 随机数生成器的占位参数,当前未实现,保留未来使用。 + +返回 +:::::::::::: + +Tensor:数值服从范围[``from``, ``to`` - 1]内均匀分布的随机 Tensor。 + +代码示例 +:::::::::::: + +COPY-FROM: paddle.random_ diff --git a/docs/api/paddle/sub__cn.rst b/docs/api/paddle/sub__cn.rst new file mode 100644 index 00000000000..7f2e5126eb5 --- /dev/null +++ b/docs/api/paddle/sub__cn.rst @@ -0,0 +1,7 @@ +.. _cn_api_paddle_sub_: + +sub\_ +------------------------------- + +.. py:function:: paddle.sub_(x, y, name=None, *, alpha=1) +别名函数,功能与 :ref:`cn_api_paddle_subtract_` 完全相同,详情请参考 :ref:`cn_api_paddle_subtract_` 。 diff --git a/docs/api/paddle/sub_cn.rst b/docs/api/paddle/sub_cn.rst new file mode 100644 index 00000000000..001eea473ed --- /dev/null +++ b/docs/api/paddle/sub_cn.rst @@ -0,0 +1,7 @@ +.. _cn_api_paddle_sub: + +sub +------------------------------- + +.. py:function:: paddle.sub(x, y, name=None, *, alpha=1, out=None) +别名函数,功能与 :ref:`_cn_api_paddle_subtract` 完全相同,详情请参考 :ref:`_cn_api_paddle_subtract`。 diff --git a/docs/api/paddle/subtract__cn.rst b/docs/api/paddle/subtract__cn.rst index a125ff50674..833050950e7 100644 --- a/docs/api/paddle/subtract__cn.rst +++ b/docs/api/paddle/subtract__cn.rst @@ -3,7 +3,7 @@ subtract\_ ------------------------------- -.. py:function:: paddle.subtract_(x, y, name=None) +.. py:function:: paddle.subtract_(x, y, name=None, *, alpha=1) Inplace 版本的 :ref:`cn_api_paddle_subtract` API,对输入 `x` 采用 Inplace 策略。 diff --git a/docs/api/paddle/subtract_cn.rst b/docs/api/paddle/subtract_cn.rst index 774203fe0f1..4b48c93c51c 100644 --- a/docs/api/paddle/subtract_cn.rst +++ b/docs/api/paddle/subtract_cn.rst @@ -3,15 +3,18 @@ subtract ------------------------------- -.. py:function:: paddle.subtract(x, y, name=None) +.. py:function:: paddle.subtract(x, y, name=None, *, alpha=1, out=None) +.. note:: + 别名支持: 参数名 ``input`` 可替代 ``x``,参数名 ``other`` 可替代 ``y`` ,如 ``subtract(input=tensor_x, other=tensor_y, ...)`` 等价于 ``subtract(x=tensor_x, y=tensor_y, ...)``。 + 逐元素相减算子,输入 ``x`` 与输入 ``y`` 逐元素相减,并将各个位置的输出元素保存到返回结果中。 等式是: .. math:: - out = x - y + out = x - alpha \times y .. note:: ``paddle.subtract`` 遵守 broadcasting,如您想了解更多,请参见 `Tensor 介绍`_ . @@ -21,8 +24,12 @@ subtract 参数 ::::::::: - **x** (Tensor) - 输入的 Tensor。数据类型为 ``bfloat16`` 、 ``float16`` 、 ``float32`` 、 ``float64``、 ``int16`` 、 ``int32`` 、 ``int64`` 、 ``complex64`` 或 ``complex128`` 。 + ``别名: input`` - **y** (Tensor) - 输入的 Tensor。数据类型为 ``bfloat16`` 、 ``float16`` 、 ``float32`` 、 ``float64``、 ``int16`` 、 ``int32`` 、 ``int64`` 、 ``complex64`` 或 ``complex128`` 。 + ``别名: other`` - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 + - **alpha** (Number, 可选) - 对 ``y`` 的缩放因子,默认值为 1。 + - **out** (Tensor, 可选) - 输出 Tensor,默认值为 None。 返回 :::::::::