Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/api/paddle/Overview_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ tensor 数学操作
" :ref:`paddle.stanh <cn_api_paddle_stanh>` ", "stanh 激活函数"
" :ref:`paddle.std <cn_api_paddle_std>` ", "沿给定的轴 axis 计算 x 中元素的标准差"
" :ref:`paddle.subtract <cn_api_paddle_subtract>` ", "逐元素相减算子"
" :ref:`paddle.sub <cn_api_paddle_sub>` ", "逐元素相减算子"
" :ref:`paddle.remainder <cn_api_paddle_remainder>` ", "逐元素取模算子"
" :ref:`paddle.sum <cn_api_paddle_sum>` ", "对指定维度上的 Tensor 元素进行求和运算"
" :ref:`paddle.tan <cn_api_paddle_tan>` ", "三角函数 tangent"
Expand Down Expand Up @@ -245,11 +246,13 @@ tensor 数学操作原位(inplace)版本
" :ref:`paddle.sinc_ <cn_api_paddle_sinc_>` ", "Inplace 版本的 sinc API,对输入 x 采用 Inplace 策略"
" :ref:`paddle.sinh_ <cn_api_paddle_sinh_>` ", "Inplace 版本的 sinh API,对输入 x 采用 Inplace 策略"
" :ref:`paddle.subtract_ <cn_api_paddle_subtract_>` ", "Inplace 版本的 subtract API,对输入 x 采用 Inplace 策略"
" :ref:`paddle.sub_ <cn_api_paddle_sub_>` ", "Inplace 版本的 sub API,对输入 x 采用 Inplace 策略"
" :ref:`paddle.tan_ <cn_api_paddle_tan_>` ", "Inplace 版本的 tan API,对输入 x 采用 Inplace 策略"
" :ref:`paddle.cos_ <cn_api_paddle_cos_>` ", "Inplace 版本的 cos API,对输入 x 采用 Inplace 策略"
" :ref:`paddle.atan_ <cn_api_paddle_atan_>` ", "Inplace 版本的 atan API,对输入 x 采用 Inplace 策略"
" :ref:`paddle.acos_ <cn_api_paddle_acos_>` ", "Inplace 版本的 acos API,对输入 x 采用 Inplace 策略"
" :ref:`paddle.uniform_ <cn_api_paddle_uniform_>` ", "Inplace 版本的 uniform API,对输入 x 采用 Inplace 策略"
" :ref:`paddle.random_ <cn_api_paddle_random_>` ", "Inplace 版本的 random API,对输入 x 采用 Inplace 策略"
" :ref:`paddle.lerp_ <cn_api_paddle_lerp_>` ", "Inplace 版本的 lerp API,对输入 x 采用 Inplace 策略"
" :ref:`paddle.hypot_ <cn_api_paddle_hypot_>` ", "Inplace 版本的 hypot API,对输入 x 采用 Inplace 策略"
" :ref:`paddle.multigammaln_ <cn_api_paddle_multigammaln_>` ", "Inplace 版本的 multigammaln API,对输入 x 采用 Inplace 策略"
Expand Down Expand Up @@ -331,6 +334,7 @@ tensor 属性相关
" :ref:`paddle.broadcast_shape <cn_api_paddle_broadcast_shape>` ", "返回对 x_shape 大小的 Tensor 和 y_shape 大小的 Tensor 做 broadcast 操作后得到的 shape"
" :ref:`paddle.broadcast_shapes <cn_api_paddle_broadcast_shapes>` ", "返回对多个 shape 做 broadcast 操作后得到的 shape"
" :ref:`paddle.is_floating_point <cn_api_paddle_is_floating_point>` ", "判断输入 Tensor 的数据类型是否为浮点类型"
" :ref:`paddle.Size <cn_api_paddle_Size>` ", "tuple 的子类, paddle.Tensor.size() 的返回类型,用于描述张量的维度大小。"

.. _tensor_creation:

Expand Down
20 changes: 20 additions & 0 deletions docs/api/paddle/Size_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. _cn_api_paddle_Size:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

问题描述见 PaddlePaddle/Paddle#44671 ,rename 成带有 __upper 后缀以避免冲突

Suggested change
.. _cn_api_paddle_Size:
.. _cn_api_paddle_Size__upper:
  • 文件名也改成 Size__upper_cn.rst
  • overview 对应的引用也改一下

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改


Size
-------------------------------

.. py:class:: paddle.Size()
``paddle.Tensor.size()`` 的返回类型,用于描述张量的维度大小。作为 ``tuple`` 的子类,支持所有常见的序列操作(如索引、切片、拼接等)。

**参数**
:::::::::
- ``*args``:表示维度的整数序列或多个整数参数。

**返回**
:::::::::
- ``Size``:表示张量维度的特殊元组子类。

**代码示例**
:::::::::

COPY-FROM: paddle.Size
40 changes: 38 additions & 2 deletions docs/api/paddle/Tensor_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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()
:::::::::
Expand Down Expand Up @@ -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
Expand All @@ -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)
:::::::::

Expand Down Expand Up @@ -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)
:::::::::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ rand_like
代码示例
:::::::::::

COPY-FROM: paddle.rand_like
COPY-FROM: paddle.rand_like
28 changes: 28 additions & 0 deletions docs/api/paddle/random__cn.rst
Original file line number Diff line number Diff line change
@@ -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_
7 changes: 7 additions & 0 deletions docs/api/paddle/sub__cn.rst
Original file line number Diff line number Diff line change
@@ -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_` 。
7 changes: 7 additions & 0 deletions docs/api/paddle/sub_cn.rst
Original file line number Diff line number Diff line change
@@ -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`。
2 changes: 1 addition & 1 deletion docs/api/paddle/subtract__cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 策略。

Expand Down
11 changes: 9 additions & 2 deletions docs/api/paddle/subtract_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 介绍`_ .
Expand All @@ -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。

返回
:::::::::
Expand Down