Skip to content

Commit

Permalink
【Hackathon 6th No. 7】Add sinc / sinc_ API to Paddle (#6634)
Browse files Browse the repository at this point in the history
* add sinc docs

* Update docs/api/paddle/sinc_cn.rst

---------

Co-authored-by: zachary sun <70642955+sunzhongkai588@users.noreply.github.com>
  • Loading branch information
NKNaN and sunzhongkai588 authored May 16, 2024
1 parent 7f3d854 commit d715da6
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
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 @@ -232,6 +232,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

0 comments on commit d715da6

Please sign in to comment.