-
Notifications
You must be signed in to change notification settings - Fork 826
[Docathon][Add Inplace CN Doc No.31] #7187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-7187.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以参考一下别的 PR 是怎么改的 #7108
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
参考一下别的 PR 是怎么改的 #7108
好的,已修改,请再次审阅,谢谢 |
@@ -0,0 +1,50 @@ | |||
.. _api_paddle_logical_and__cn: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. _api_paddle_logical_and__cn: | |
.. _cn_api_paddle_logical_and_: |
@@ -0,0 +1,50 @@ | |||
.. _api_paddle_logical_and__cn: | |||
|
|||
logical_and_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logical_and_ | |
logical\_and\_ |
需要转义
logical_and_ | ||
------------------------------- | ||
|
||
.. py:function:: paddle.logical_and_(x: Tensor, y: Tensor, name: str|None = None) → Tensor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. py:function:: paddle.logical_and_(x: Tensor, y: Tensor, name: str|None = None) → Tensor | |
.. py:function:: paddle.logical_and_(x, y, name = None) |
该 API 是 `paddle.logical_and` 的 **Inplace 版本**,输出结果将直接覆盖输入 Tensor ``x`` 的内存,功能与非 Inplace 版本一致。 | ||
|
||
逐元素对 ``x`` 和 ``y`` 进行逻辑与运算,计算公式为: | ||
|
||
.. math:: | ||
\text{out}_i = \text{x}_i \ \&\& \ \text{y}_i | ||
|
||
.. note:: | ||
**Inplace 警告**:此操作会直接修改输入 Tensor ``x`` 的值,若需保留原始数据,请使用非 Inplace 版本 `paddle.logical_and`。 | ||
|
||
**广播机制**:``x`` 和 ``y`` 的形状需满足广播规则,如您想了解更多,请参考tensor介绍 `<../../guides/beginner/tensor_cn.html#id7>`_。 | ||
|
||
参数 | ||
::::::::: | ||
- **x** (Tensor) - 输入的 Tensor,支持的数据类型为 bool、int8、int16、int32、int64、bfloat16、float16、float32、float64、complex64、complex128。 | ||
- **y** (Tensor) - 输入的 Tensor,数据类型需与 ``x`` 一致。 | ||
- **name** (str|None, 可选) - 操作的名称,默认值为 None,表示自动命名。 | ||
|
||
返回 | ||
::::::::: | ||
**Tensor**,与输入 ``x`` 共享内存的 Tensor,存储运算后的布尔值结果(直接覆盖 ``x``)。 | ||
|
||
代码示例 | ||
::::::::: | ||
|
||
.. code-block:: python | ||
|
||
import paddle | ||
|
||
# 示例 1:基础用法 | ||
x = paddle.to_tensor([True, False, True, False]) | ||
y = paddle.to_tensor([True, True, False, False]) | ||
paddle.logical_and_(x, y) | ||
print(x) # 输出: [True, False, False, False] | ||
|
||
# 示例 2:广播机制 | ||
x = paddle.to_tensor([[True], [False]]) | ||
y = paddle.to_tensor([True, False]) | ||
paddle.logical_and_(x, y) # 广播为 [[True, False], [False, False]] | ||
print(x) | ||
# 输出: | ||
# [[True, False], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
文档内容直接参考其他 inplace API 的写法,如
docs/docs/api/paddle/clip__cn.rst
Lines 8 to 12 in 31f275f
Inplace 版本的 :ref:`cn_api_paddle_clip` API,对输入 x 采用 Inplace 策略。 | |
更多关于 inplace 操作的介绍请参考 `3.1.3 原位(Inplace)操作和非原位操作的区别`_ 了解详情。 | |
.. _3.1.3 原位(Inplace)操作和非原位操作的区别: https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/beginner/tensor_cn.html#id3 |
@@ -251,11 +251,13 @@ tensor 数学操作原位(inplace)版本 | |||
" :ref:`paddle.normal_ <cn_api_paddle_normal_>` ", "Inplace 版本的 normal API,对输入 x 采用 Inplace 策略" | |||
" :ref:`paddle.neg_ <cn_api_paddle_neg_>` ", "Inplace 版本的 neg API,对输入 x 采用 Inplace 策略" | |||
" :ref:`paddle.nan_to_num_ <cn_api_paddle_nan_to_num_>` ", "Inplace 版本的 nan_to_num API,对输入 x 采用 Inplace 策略" | |||
" :ref:`paddle.logical_and_ <cn_api_paddle_logical_and_>` ", "Inplace 版本的 logical_and API,对输入 x 采用 Inplace 策略)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
移到上面的 log_normal_ 下吧
@luotao1 The PR can be closed due to the following PR is merged: |
描述
为
paddle.logical_and_
添加中文文档增加
logical_and__cn.rst文件
修改
在Overview_cn.rst中新增新添加的API相关信息(在“tensor 数学操作原位(inplace)版本”标题下)
issue
Issue #7090
英文文档
logic_and_en: https://www.paddlepaddle.org.cn/documentation/docs/en/develop/api/paddle/logical_and__en.html
@sunzhongkai588 感谢审阅