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 6th No. 7】Add sinc / sinc_ API to Paddle #6634

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions docs/api/paddle/Overview_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ tensor 数学操作
" :ref:`paddle.signbit <cn_api_paddle_signbit>` ", "对输入 x 的每个元素符号位进行判断"
" :ref:`paddle.sgn <cn_api_paddle_sgn>` ", "对输入 x 中每个元素进行正负判断,对于复数则输出单位向量"
" :ref:`paddle.sin <cn_api_paddle_sin>` ", "计算输入的正弦值"
" :ref:`paddle.sinc <cn_api_paddle_sinc>` ", "计算输入的归一化 sinc 值"
" :ref:`paddle.sinh <cn_api_paddle_sinh>` ", "双曲正弦函数"
" :ref:`paddle.sqrt <cn_api_paddle_sqrt>` ", "计算输入的算数平方根"
" :ref:`paddle.square <cn_api_paddle_square>` ", "逐元素取平方运算"
Expand Down Expand Up @@ -207,6 +208,7 @@ tensor 数学操作原位(inplace)版本
" :ref:`paddle.sqrt_ <cn_api_paddle_sqrt_>` ", "Inplace 版本的 sqrt API,对输入 x 采用 Inplace 策略"
" :ref:`paddle.square_ <cn_api_paddle_square_>` ", "Inplace 版本的 square API,对输入 x 采用 Inplace 策略"
" :ref:`paddle.sin_ <cn_api_paddle_sin_>` ", "Inplace 版本的 sin API,对输入 x 采用 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.tan_ <cn_api_paddle_tan_>` ", "Inplace 版本的 tan API,对输入 x 采用 Inplace 策略"
Expand Down
2 changes: 2 additions & 0 deletions docs/api/paddle/Tensor/Overview_en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ Methods
sign
sgn
sin
sinc
sinc_
sinh
slice
solve
Expand Down
12 changes: 12 additions & 0 deletions docs/api/paddle/sinc__cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. _cn_api_paddle_sinc_:

sinc\_
-------------------------------

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

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

sinc
-------------------------------

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

计算输入的归一化 sinc 值。

计算公式为:

.. math::

out_i =
\left\{
\begin{aligned}
&1 & \text{ if $x_i = 0$} \\
&\frac{\sin(\pi x_i)}{\pi x_i} & \text{ otherwise}
\end{aligned}
\right.

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

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

返回
::::::::::::
返回类型为 Tensor,数据类型同输入一致。

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

COPY-FROM: paddle.sinc