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
35 changes: 35 additions & 0 deletions docs/api/paddle/copysign_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.. _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,输出数据类型与输入数据类型相同。


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

COPY-FROM: paddle.copysign
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 代码块,参考 中文API文档复制英文API文档示例代码

比如 COPY-FROM: paddle.copysign:example1