-
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
Changes from all commits
4a4a84b
6ddabd0
f3ad550
606b5d7
b8bcdf0
715cacd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,50 @@ | ||||||||||||
.. _api_paddle_logical_and__cn: | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
||||||||||||
logical_and_ | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
需要转义 |
||||||||||||
------------------------------- | ||||||||||||
|
||||||||||||
.. 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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
||||||||||||
该 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], | ||||||||||||
Comment on lines
+8
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||||||||
# [False, 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.
移到上面的 log_normal_ 下吧