FT_DSP.gitlink.net/master/html/_sources/functionlib/dsplib/erf.rst.txt

87 lines
2.1 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Erf
=================
逐元素计算误差函数Error Function, erf
误差函数在概率论与统计中广泛使用,其定义如下:
.. math::
\text{output}_i = \operatorname{erf}(\text{input}_i)
= \frac{2}{\sqrt{\pi}} \int_{0}^{\text{input}_i} e^{-t^2} \, dt
输入:
- **input** - 输入张量的数据地址。
- **length** - 输入张量的总元素数量。
- **core_mask** - 核掩码。
输出:
- **output** - 输出张量的数据地址,其大小与 ``input`` 相同。
支持平台:
``FT78NE``
``MT7004``
.. note::
- FT78NE 支持的数据类型fp32, fp64
- MT7004 支持的数据类型fp16, fp32
**共享存储版本:**
.. c:function:: void fp_erf_s(float* input, float* output, int length, int core_mask)
.. c:function:: void dp_erf_s(double* input, double* output, int length, int core_mask)
.. c:function:: void hp_erf_s(half* input, half* output, int length, int core_mask)
**C调用示例**
.. code-block:: c
:linenos:
:emphasize-lines: 12
// C6678 多核示例
#include <stdio.h>
#include <erf.h>
int main(int argc, char* argv[]) {
float *input = (float *)0xA0000000; // input 在 DDR 空间
float *output = (float *)0xB0000000; // output 在 DDR 空间
int length = 4096;
int core_mask = 0xff;
fp_erf_s(input, output, length, core_mask);
return 0;
}
**私有存储版本:**
.. c:function:: void fp_erf_p(float* input, float* output, int length)
.. c:function:: void dp_erf_p(double* input, double* output, int length)
.. c:function:: void hp_erf_p(half* input, half* output, int length)
**C调用示例**
.. code-block:: c
:linenos:
:emphasize-lines: 11
// MT7004 单核示例
#include <stdio.h>
#include <erf.h>
int main(int argc, char* argv[]) {
half *input = (half *)0x10000000; // input 在 L2 空间
half *output = (half *)0x10001000; // output 在 L2 空间
int length = 1024;
hp_erf_p(input, output, length);
return 0;
}