Log
=================

逐元素计算自然对数（以 :math:`e` 为底）的对数函数。

.. math::

    \text{output}_i = \ln(\text{input}_i)

其中 :math:`\ln(\cdot)` 表示自然对数函数。  
当输入值小于等于 0 时，结果的行为依赖于具体平台和实现（可能产生 ``-inf`` 或 ``NaN``）。

输入：
    - **input** - 输入张量的数据地址。
    - **length** - 输入张量的总元素数量。
    - **core_mask** - 核掩码（仅共享存储版本需要）。

输出：
    - **output** - 输出张量的数据地址，其大小与 ``input`` 相同。

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

.. note::
    - FT78NE 支持的数据类型：fp32，fp64，int8，int16, int32
    - MT7004 支持的数据类型：fp16，fp32，int16, int32


**共享存储版本：**

.. c:function:: void fp_log_s(float* input, float* output, int length, int core_mask)
.. c:function:: void hp_log_s(half* input, half* output, int length, int core_mask)
.. c:function:: void dp_log_s(double* input, double* output, int length, int core_mask)
.. c:function:: void i8_log_s(int8_t* input, int8_t* output, int length, int core_mask)
.. c:function:: void i16_log_s(int16_t* input, float* output, int length, int core_mask)
.. c:function:: void i32_log_s(int* input, float* output, int length, int core_mask)

**C调用示例：**

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

    // FT78NE 多核示例
    #include <stdio.h>
    #include <log.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_log_s(input, output, length, core_mask);
        return 0;
    }


**私有存储版本：**

.. c:function:: void fp_log_p(float* input, float* output, int length)
.. c:function:: void hp_log_p(half* input, half* output, int length)
.. c:function:: void dp_log_p(double* input, double* output, int length)
.. c:function:: void i8_log_p(int8_t* input, int8_t* output, int length)
.. c:function:: void i16_log_p(int16_t* input, float* output, int length)
.. c:function:: void i32_log_p(int* input, float* output, int length)


**C调用示例：**

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

    // FT04 单核示例
    #include <stdio.h>
    #include <log.h>

    int main(int argc, char* argv[]) {
        float *input  = (float *)0x10000000;   // input 在 L2 空间
        float *output = (float *)0x10001000;   // output 在 L2 空间

        int length = 1024;

        fp_log_p(input, output, length);
        return 0;
    }
