LMMC
Lamina Mathematic core
载入中...
搜索中...
未找到
tensor_nd_storage.c 文件参考

N 维张量的分配、释放与元素访问。 更多...

#include "internal/tensor_nd_internal.h"
#include <string.h>
tensor_nd_storage.c 的引用(Include)关系图:

浏览该文件的源代码.

函数

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_tensor_nd_create()

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输出张量结构体(调用方提供存储).
返回
LMMC_STATUS_OK 成功; LMMC_STATUS_INVALID_ARGUMENT 若 ndim 超出范围,dims 含零,元素数或字节数溢出,或指针为 NULL; LMMC_STATUS_ALLOCATION_FAILED 若内存分配失败.
注解
覆写 out 的全部字段;堆分配的数据缓冲区由调用方 调用 lmmc_tensor_nd_destroy 释放。

在文件 tensor_nd_storage.c 第 9 行定义.

引用了 lmmc_tensor_nd_create().

被这些函数引用 lmmc_tensor3_create() , 以及 lmmc_tensor_nd_create().

函数调用图:
这是这个函数的调用关系图:

◆ lmmc_tensor_nd_get()

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_tensor_nd_set()

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().

函数调用图:
这是这个函数的调用关系图:

◆ lmmc_tensor_nd_destroy()

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().

函数调用图:
这是这个函数的调用关系图: