Skip to content
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

【Hackathon 5th No.1】 为 Paddle 新增 copysign API 中文文档 #6417

Merged
merged 12 commits into from
Jan 12, 2024
1 change: 1 addition & 0 deletions docs/api/paddle/Overview_cn.rst
Copy link
Collaborator

Choose a reason for hiding this comment

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

overview里也要加上 copysign_

Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ tensor 数学操作
" :ref:`paddle.conj <cn_api_paddle_conj>` ", "逐元素计算 Tensor 的共轭运算"
" :ref:`paddle.cos <cn_api_paddle_cos>` ", "余弦函数"
" :ref:`paddle.cosh <cn_api_paddle_cosh>` ", "双曲余弦函数"
" :ref:`paddle.cosh <cn_api_paddle_copysign>` ", "按照元素计算两个输入 Tensor 的 copysign 大小,由数值和符号组成,其数值部分来自于第一个 Tensor 中的元素,符号部分来自于第二个 Tensor 中的元素。"
cocoshe marked this conversation as resolved.
Show resolved Hide resolved
" :ref:`paddle.count_nonzero <cn_api_paddle_count_nonzero>` ", "沿给定的轴 axis 统计非零元素的数量"
" :ref:`paddle.cumsum <cn_api_paddle_cumsum>` ", "沿给定 axis 计算 Tensor x 的累加和"
" :ref:`paddle.cummax <cn_api_paddle_cummax>` ", "沿给定 axis 计算 Tensor x 的累计最大值"
Expand Down
12 changes: 12 additions & 0 deletions docs/api/paddle/copysign__cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. _cn_api_paddle_copysign_:

copysign\_
-------------------------------

.. py:function:: paddle.copysign_(x, y, name=None)

Inplace 版本的 :ref:`cn_api_paddle_copysign` 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
57 changes: 57 additions & 0 deletions docs/api/paddle/copysign_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
.. _cn_api_paddle_copysign:

copysign
-------------------------------

.. py:function:: paddle.copysign(x, y, name=None)


按照元素计算两个输入 Tensor 的 copysign 大小,由数值和符号组成,其数值部分来自于第一个 Tensor 中的元素,符号部分来自于第二个 Tensor 中的元素。

.. math::

copysign(x_{i},y_{i})=\left\{\begin{matrix}
& -|x_{i}| & if \space y_{i} <= -0.0\\
& |x_{i}| & if \space y_{i} >= 0.0
\end{matrix}\right.


参数
::::::::::::

- **x** (Tensor) - 输入的复数值的 Tensor,数据类型为:bool, uint8, int8, int16, int32, int64, bfloat16, float16, float32, float64。
- **y** (Tensor) - 输入的复数值的 Tensor,数据类型为:bool, uint8, int8, int16, int32, int64, bfloat16, float16, float32, float64。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
::::::::::::

Tensor,输出数据类型与输入数据类型相同。


代码示例1
::::::::::::

COPY-FROM: paddle.copysign:example1


代码示例2
::::::::::::

支持广播机制

COPY-FROM: paddle.copysign:example2

代码示例3
::::::::::::

y为+0.0时
Copy link
Collaborator

Choose a reason for hiding this comment

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

中英文、数字间得有空格,这个应该 pre-commit 会在你 commit 的时候自动检查并修复, 是不是没装(doge


COPY-FROM: paddle.copysign:example_zero1

代码示例4
::::::::::::

y为-0.0时
Copy link
Collaborator

Choose a reason for hiding this comment

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

中英文、数字间得有空格


COPY-FROM: paddle.copysign:example_zero2