|
LMMC
Lamina Mathematic core
|
N 维张量的分配、释放与元素访问。 更多...
函数 | |
| lmmc_status_t | lmmc_tensor_nd_create (size_t ndim, const size_t *dims, lmmc_tensor_nd_t *out) |
| 创建 N-D 张量,行优先连续存储,元素初始化为零. | |
| lmmc_status_t | lmmc_tensor_nd_get (const lmmc_tensor_nd_t *t, const size_t *idx, lmmc_real_t *out) |
| 读取 N-D 张量元素. | |
| lmmc_status_t | lmmc_tensor_nd_set (lmmc_tensor_nd_t *t, const size_t *idx, lmmc_real_t value) |
| 写入 N-D 张量元素. | |
| void | lmmc_tensor_nd_destroy (lmmc_tensor_nd_t *t) |
| 销毁 N-D 张量(仅当 owns_data 为 1 时释放缓冲区). | |
N 维张量的分配、释放与元素访问。
在文件 tensor_nd_storage.c 中定义.
| lmmc_status_t lmmc_tensor_nd_create | ( | size_t | ndim, |
| const size_t * | dims, | ||
| lmmc_tensor_nd_t * | out ) |
创建 N-D 张量,行优先连续存储,元素初始化为零.
分配 dims[0] x dims[1] x ... x dims[ndim-1] 个元素的连续缓冲区, 并设置行优先步距.输出张量的 owns_data 为 1.
| [in] | ndim | 维度数,范围 [1, LMMC_TENSOR_MAX_NDIM]. |
| [in] | dims | 各维大小数组,长度 ndim ,每个元素须 >= 1;可指向 out->dims. |
| [out] | out | 输出张量结构体(调用方提供存储). |
在文件 tensor_nd_storage.c 第 9 行定义.
被这些函数引用 lmmc_tensor3_create() , 以及 lmmc_tensor_nd_create().
| lmmc_status_t lmmc_tensor_nd_get | ( | const lmmc_tensor_nd_t * | t, |
| const size_t * | idx, | ||
| lmmc_real_t * | out ) |
读取 N-D 张量元素.
在文件 tensor_nd_storage.c 第 13 行定义.
引用了 lmmc_tensor_nd_t::data, lmmc_tensor_nd_t::dims, LMMC_REAL_SET, LMMC_STATUS_INVALID_ARGUMENT, LMMC_STATUS_OK, lmmc_tensor_nd_get(), lmmc_tensor_nd_t::ndim , 以及 lmmc_tensor_nd_t::strides.
被这些函数引用 lmmc_tensor_nd_get().
| lmmc_status_t lmmc_tensor_nd_set | ( | lmmc_tensor_nd_t * | t, |
| const size_t * | idx, | ||
| lmmc_real_t | value ) |
写入 N-D 张量元素.
在文件 tensor_nd_storage.c 第 32 行定义.
引用了 lmmc_tensor_nd_t::data, lmmc_tensor_nd_t::dims, LMMC_REAL_SET, LMMC_STATUS_INVALID_ARGUMENT, LMMC_STATUS_OK, lmmc_tensor_nd_set(), lmmc_tensor_nd_t::ndim , 以及 lmmc_tensor_nd_t::strides.
被这些函数引用 lmmc_tensor_nd_set().
| void lmmc_tensor_nd_destroy | ( | lmmc_tensor_nd_t * | t | ) |
销毁 N-D 张量(仅当 owns_data 为 1 时释放缓冲区).
在文件 tensor_nd_storage.c 第 51 行定义.
引用了 lmmc_tensor_nd_t::data, lmmc_tensor_nd_t::dims, lmmc_memory_free(), LMMC_REAL_CLEAR, LMMC_STATUS_OK, lmmc_tensor_nd_destroy(), lmmc_tensor_nd_t::ndim, lmmc_tensor_nd_t::owns_data , 以及 lmmc_tensor_nd_t::strides.
被这些函数引用 lmmc_tensor_nd_destroy().