!45525 [MS][OP]bartlett_window blackman window

Merge pull request !45525 from mengyuanli/code_docs_export_primitive_bartlett_window
This commit is contained in:
i-robot 2022-11-15 03:50:23 +00:00 committed by Gitee
commit 9db1a6aaee
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 82 additions and 42 deletions

View File

@ -625,3 +625,14 @@ Parameter操作算子
mindspore.ops.Custom
光谱算子
----------
.. mscnautosummary::
:toctree: ops
:nosignatures:
:template: classtemplate.rst
mindspore.ops.BartlettWindow
mindspore.ops.BlackmanWindow

View File

@ -0,0 +1,8 @@
mindspore.ops.BartlettWindow
==============================
.. py:class:: mindspore.ops.BartlettWindow(periodic=True, dtype=mstype.float32)
巴特利特窗口函数。
更多参考详见 :func:`mindspore.ops.bartlett_window`

View File

@ -0,0 +1,8 @@
mindspore.ops.BlackmanWindow
==============================
.. py:class:: mindspore.ops.BlackmanWindow(periodic=True, dtype=mstype.float32)
布莱克曼窗口函数。
更多参考详见 :func:`mindspore.ops.blackman_window`

View File

@ -0,0 +1,37 @@
mindspore.ops.bartlett_window
=============================
.. py:function:: mindspore.ops.bartlett_window(window_length, periodic=True, *, dtype=mstype.float32)
巴特利特窗口函数。
`window_length` 是一个Tensor控制返回的窗口大小其数据类型必须是整数。特别的`window_length` 为1时返回的窗口只包含一个值`1``periodic` 决定返回的窗口是否会删除对称窗口的最后一个重复值,并准备用作带函数的周期窗口。因此,如果 `periodic` 为True :math:`N`:math:`window\_length + 1`
.. math::
w[n] = 1 - \left| \frac{2n}{N-1} - 1 \right| = \begin{cases}
\frac{2n}{N - 1} & \text{if } 0 \leq n \leq \frac{N - 1}{2} \\
2 - \frac{2n}{N - 1} & \text{if } \frac{N - 1}{2} < n < N \\
\end{cases},
\text{where : N is the full window size.}
其中N是总的窗口长度 `window_length` n为小于N的自然数 [0, 1, ..., N-1]。
参数:
- **window_length** (Tensor) - 返回窗口的大小数据类型为int32int64。输入数据的值为[0,1000000]的整数。
- **periodic** (bool可选) - 如果为True返回一个窗口作为周期函数使用。如果为False返回一个对称窗口。默认值True。
关键字参数:
- **dtype** (mindspore.dtype可选) - 输出数据类型目前只支持float16、float32和float64。默认值mindspore.float32。
返回:
1D Tensor大小为 `window_length` ,数据类型与 `dtype` 一致。
异常:
- **TypeError** - `window_length` 不是Tensor。
- **TypeError** - `window_length` 的数据类型不是int32、int64。
- **TypeError** - `periodic` 不是bool。
- **TypeError** - `dtype` 不是float16、float32、float64。
- **ValueError** - `window_length` 的值不在[0, 1000000]。
- **ValueError** - `window_length` 的维度不等于0。

View File

@ -14,10 +14,10 @@ mindspore.ops.blackman_window
参数:
- **window_length** (Tensor) - 返回窗口的大小数据类型为int32int64。输入数据的值为[0,1000000]的整数。
- **periodic** (bool) - 如果为True返回一个窗口作为周期函数使用。如果为False返回一个对称窗口。默认值True。
- **periodic** (bool,可选) - 如果为True返回一个窗口作为周期函数使用。如果为False返回一个对称窗口。默认值True。
关键字参数:
- **dtype** (mindspore.dtype) - 输出数据类型目前只支持float16、float32和float64。默认值None。
- **dtype** (mindspore.dtype,可选) - 输出数据类型目前只支持float16、float32和float64。默认值None。
返回:
1D Tensor大小为 `window_length` ,数据类型与 `dtype` 一致。

View File

@ -623,3 +623,14 @@ Customizing Operator
mindspore.ops.Custom
Spectral Operator
-----------------
.. autosummary::
:toctree: ops
:nosignatures:
:template: classtemplate.rst
mindspore.ops.BartlettWindow
mindspore.ops.BlackmanWindow

View File

@ -40,11 +40,11 @@ def blackman_window(window_length, periodic=True, *, dtype=None):
Args:
window_length (Tensor): the size of returned window, with data type int32, int64.
The input data should be an integer with a value of [0, 1000000].
periodic (bool): If True, returns a window to be used as periodic function.
periodic (bool, optional): If True, returns a window to be used as periodic function.
If False, return a symmetric window. Default: True.
Keyword args:
dtype (mindspore.dtype): the desired data type of returned tensor.
dtype (mindspore.dtype, optional): the desired data type of returned tensor.
Only float16, float32 and float64 is allowed. Default: None.
Returns:
@ -100,11 +100,11 @@ def bartlett_window(window_length, periodic=True, *, dtype=None):
Args:
window_length (Tensor): The size of returned window, with data type int32, int64.
The input data should be an integer with a value of [0, 1000000].
periodic (bool): If True, returns a window to be used as periodic function.
periodic (bool, optional): If True, returns a window to be used as periodic function.
If False, return a symmetric window. Default: True.
Keyword args:
dtype (mindspore.dtype): The desired datatype of returned tensor.
dtype (mindspore.dtype, optional): The desired datatype of returned tensor.
Only float16, float32 and float64 are allowed. Default: None.
Returns:

View File

@ -158,42 +158,7 @@ class BartlettWindow(Primitive):
r"""
Bartlett window function.
The input "window_length" is a tensor that datatype must be a integer, which controlling the returned window size.
In particular, If "window_length" = 1, the returned window contains a single value 1.
Attr "periodic" determines whether the returned window trims off the last duplicate value from the symmetric window
and is ready to be used as a periodic window with functions. Therefore, if attr "periodic" is true, the "N" in
formula is in fact "window_length" + 1.
.. math::
w[n] = 1 - \left| \frac{2n}{N-1} - 1 \right| = \begin{cases}
\frac{2n}{N - 1} & \text{if } 0 \leq n \leq \frac{N - 1}{2} \\
2 - \frac{2n}{N - 1} & \text{if } \frac{N - 1}{2} < n < N \\
\end{cases},
\text{where : N is the full window size.}
Args:
periodic(bool): If True, returns a window to be used as periodic function. If False, return a symmetric window.
Default: True.
dtype(mindspore.dtype): The desired datatype of returned tensor. Only float16, float32 and float64 is allowed.
Default: mstype.float32.
Inputs:
- **window_length** (Tensor) - The size of returned window, with data type int32, int64.
The input data should be an integer with a value of [0, 1000000].
Outputs:
A 1-D tensor of size "window_length" containing the window. Its datatype is set by the attr 'dtype'.
Raises:
TypeError: If "window_length" is not a Tensor.
TypeError: If the type of "window_length" is not one of: int32, int64.
TypeError: If "periodic" is not a bool.
TypeError: If "dtype" is not one of: float16, float32, float64.
ValueError: If the value range of "window_length" is not [0,1000000].
ValueError: If the dimension of "window_length" is not 0.
Refer to :func:`mindspore.ops.bartlett_window` for more details.
Supported Platforms:
``GPU``