SmoothL1Loss
=================

计算平滑L1损失函数

.. math::

    \text{loss}(x_1, x_2) = \begin{cases}
        \frac{(x_1 - x_2)^2}{2\beta}, & \text{if } |x_1 - x_2| < \beta \\
        |x_1 - x_2| - \frac{\beta}{2}, & \text{otherwise}
    \end{cases}

其中 :math:`x_1` 为预测值，:math:`x_2` 为目标值，:math:`\beta` 为平滑参数。

输入：
    - **predict** - 预测值数据地址。
    - **target** - 目标值数据地址。
    - **length** - 计算长度。
    - **beta** - 平滑参数（FT78NE平台为float值，MT7004平台为half*指针）。
    - **core_mask(int, 可选)** - 核掩码（仅适用于共享存储版本）。
    
输出：
    - **out** - 计算结果地址。

支持平台：
    ``FT78NE``
    ``MT7004``

.. note::
    - FT78NE 支持int8, fp32
    - MT7004 支持fp16, fp32

**共享存储版本：**

.. c:function:: void i8_smoothl1loss_s(int8_t* out, int8_t* predict, int8_t* target, int length, float beta, int core_mask)
.. c:function:: void fp_smoothl1loss_s(float* out, float* predict, float* target, int length, float beta, int core_mask)
.. c:function:: void hp_smoothl1loss_s(half* out, half* predict, half* target, int length, half* beta, int core_mask)

    **C调用示例：**

    .. code-block:: c
        :linenos:
        :emphasize-lines: 11

        //FT78NE示例
        #include <stdio.h>
        #include <smoothl1loss.h>

        int main(int argc, char* argv[]) {
            float *predict = (float *)0xA0000000;   //predict在DDR空间
            float *target = (float *)0xB0000000;    //target在DDR空间
            float *out = (float *)0xC0000000;       //out在DDR空间
            int length = 1000;
            float beta = 1.0f;
            int core_mask = 0xff;
            fp_smoothl1loss_s(out, predict, target, length, beta, core_mask);
            return 0;
        }


**私有存储版本：**

.. c:function:: void i8_smoothl1loss_p(int8_t* out, int8_t* predict, int8_t* target, int length, float beta)
.. c:function:: void fp_smoothl1loss_p(float* out, float* predict, float* target, int length, float beta)
.. c:function:: void hp_smoothl1loss_p(half* out, half* predict, half* target, int length, half* beta)

    **C调用示例：**

    .. code-block:: c
        :linenos:
        :emphasize-lines: 10

        //FT78NE示例
        #include <stdio.h>
        #include <smoothl1loss.h>

        int main(int argc, char* argv[]) {
            float *predict = (float *)0x10810000;   //predict在L2空间
            float *target = (float *)0x10850000;    //target在L2空间
            float *out = (float *)0x108A0000;       //out在L2空间
            int length = 1000;
            float beta = 1.0f;
            fp_smoothl1loss_p(out, predict, target, length, beta);
            return 0;
        }
