GatherNd
=================

根据索引张量中的坐标，从输入张量中收集切片或元素。

GatherNd 允许根据 ``indices`` 提供的多维索引，在 ``input`` 张量的指定轴上进行切片提取。如果 ``indices`` 的最后一个维度长度为 ``K``，则它代表从 ``input`` 的前 ``K`` 个维度中提取对应的子张量（切片）。

输入：
    - **input** - 输入数据张量地址。
    - **output** - 计算结果张量地址。
    - **input_shape** - 输入张量的形状数组地址。
    - **input_ndim** - 输入张量的维度数。
    - **indices** - 索引张量地址（类型固定为 int32）。
    - **indices_shape** - 索引张量的形状数组地址。
    - **indices_ndim** - 索引张量的维度数。
    - **core_mask(int, 可选)** - 核掩码（仅适用于共享存储版本）。

输出：
    - **output** - 收集后的数据存放地址。

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

.. note::
    - FT78NE 支持 int8, int16, int32, fp32, fp64, cplx64, cplx128
    - MT7004 支持 fp16, fp32, int16, int32, cplx64
    - 索引张量 (indices) 在所有平台上均使用 int32 类型。
    - 坐标索引必须在输入张量维度的合法范围内，否则行为未定义。

**共享存储版本:**

.. c:function:: void i8_gather_nd_s(int8_t* input, int8_t* output, int* input_shape, int input_ndim, int* indices, int* indices_shape, int indices_ndim, int core_mask)
.. c:function:: void i16_gather_nd_s(int16_t* input, int16_t* output, int* input_shape, int input_ndim, int* indices, int* indices_shape, int indices_ndim, int core_mask)
.. c:function:: void i32_gather_nd_s(int* input, int* output, int* input_shape, int input_ndim, int* indices, int* indices_shape, int indices_ndim, int core_mask)
.. c:function:: void hp_gather_nd_s(half* input, half* output, int* input_shape, int input_ndim, int* indices, int* indices_shape, int indices_ndim, int core_mask)
.. c:function:: void fp_gather_nd_s(float* input, float* output, int* input_shape, int input_ndim, int* indices, int* indices_shape, int indices_ndim, int core_mask)
.. c:function:: void dp_gather_nd_s(double* input, double* output, int* input_shape, int input_ndim, int* indices, int* indices_shape, int indices_ndim, int core_mask)
.. c:function:: void c64_gather_nd_s(float* input, float* output, int* input_shape, int input_ndim, int* indices, int* indices_shape, int indices_ndim, int core_mask)
.. c:function:: void c128_gather_nd_s(double* input, double* output, int* input_shape, int input_ndim, int* indices, int* indices_shape, int indices_ndim, int core_mask)

    **C调用示例：**

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

        // FT78NE 示例（共享存储）
        #include <stdio.h>
        #include "78NE/utils.h"

        int main() {
            float *input = (float *)0xA0000000;    // 输入在 DDR 空间
            float *output = (float *)0xB0000000;   // 输出在 DDR 空间
            int *indices = (int *)0xC0000000;      // 索引在 DDR 空间
            int input_shape[] = {10, 10, 5};
            int indices_shape[] = {3, 2};          // 提取3个坐标，每个坐标深度为2
            int input_ndim = 3;
            int indices_ndim = 2;
            int core_mask = 0xFF;

            fp_gather_nd_s(input, output, input_shape, input_ndim, indices, indices_shape, indices_ndim, core_mask);
            return 0;
        }

**私有存储版本:**

.. c:function:: void i8_gather_nd_p(int8_t* input, int8_t* output, int* input_shape, int input_ndim, int* indices, int* indices_shape, int indices_ndim)
.. c:function:: void i16_gather_nd_p(int16_t* input, int16_t* output, int* input_shape, int input_ndim, int* indices, int* indices_shape, int indices_ndim)
.. c:function:: void i32_gather_nd_p(int* input, int* output, int* input_shape, int input_ndim, int* indices, int* indices_shape, int indices_ndim)
.. c:function:: void hp_gather_nd_p(half* input, half* output, int* input_shape, int input_ndim, int* indices, int* indices_shape, int indices_ndim)
.. c:function:: void fp_gather_nd_p(float* input, float* output, int* input_shape, int input_ndim, int* indices, int* indices_shape, int indices_ndim)
.. c:function:: void dp_gather_nd_p(double* input, double* output, int* input_shape, int input_ndim, int* indices, int* indices_shape, int indices_ndim)
.. c:function:: void c64_gather_nd_p(float* input, float* output, int* input_shape, int input_ndim, int* indices, int* indices_shape, int indices_ndim)
.. c:function:: void c128_gather_nd_p(double* input, double* output, int* input_shape, int input_ndim, int* indices, int* indices_shape, int indices_ndim)

    **C调用示例：**

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

        // MT7004 示例（私有存储）
        #include <stdio.h>

        int main() {
            float *input = (float *)0x10000000;
            float *output = (float *)0x10010000;
            int *indices = (int *)0x10020000;
            int input_shape[] = {4, 5, 6};
            int indices_shape[] = {2, 2, 2}; 
            int input_ndim = 3;
            int indices_ndim = 3;

            fp_gather_nd_p(input, output, input_shape, input_ndim, indices, indices_shape, indices_ndim);
            return 0;
        }