LMMC
Lamina Mathematic core
Toggle main menu visibility
载入中...
搜索中...
未找到
tensor_nd.h
浏览该文件的文档.
1
5
#ifndef LMMC_TENSOR_ND_H
6
#define LMMC_TENSOR_ND_H
7
8
#include <stddef.h>
9
#include "
lmmc/dense.h
"
10
#include "
lmmc/status.h
"
11
12
#ifdef __cplusplus
13
extern
"C"
{
14
#endif
15
17
#define LMMC_TENSOR_MAX_NDIM 8
18
25
typedef
struct
{
26
size_t
ndim
;
27
size_t
dims
[
LMMC_TENSOR_MAX_NDIM
];
28
size_t
strides
[
LMMC_TENSOR_MAX_NDIM
];
29
lmmc_real_t
*
data
;
30
int
owns_data
;
31
}
lmmc_tensor_nd_t
;
32
50
lmmc_status_t
lmmc_tensor_nd_create
(
size_t
ndim,
const
size_t
* dims,
lmmc_tensor_nd_t
* out);
51
53
lmmc_status_t
lmmc_tensor_nd_get
(
const
lmmc_tensor_nd_t
* t,
const
size_t
* idx,
lmmc_real_t
* out);
54
56
lmmc_status_t
lmmc_tensor_nd_set
(
lmmc_tensor_nd_t
* t,
const
size_t
* idx,
lmmc_real_t
value);
57
74
lmmc_status_t
lmmc_tensor_nd_permute
(
const
lmmc_tensor_nd_t
* in,
const
size_t
* perm,
lmmc_tensor_nd_t
* out);
75
77
lmmc_status_t
lmmc_tensor_nd_contract
(
const
lmmc_tensor_nd_t
* a,
const
lmmc_tensor_nd_t
* b,
78
const
size_t
* axes_a,
const
size_t
* axes_b,
size_t
naxes,
lmmc_tensor_nd_t
* out);
79
81
lmmc_status_t
lmmc_tensor_nd_mode_n_product
(
const
lmmc_tensor_nd_t
* t,
const
lmmc_mat_t
* mat,
82
size_t
mode,
lmmc_tensor_nd_t
* out);
83
101
lmmc_status_t
lmmc_tensor_nd_reshape_view
(
const
lmmc_tensor_nd_t
* src,
102
size_t
new_ndim,
const
size_t
* new_dims,
lmmc_tensor_nd_t
* out_view);
103
105
void
lmmc_tensor_nd_destroy
(
lmmc_tensor_nd_t
* t);
106
107
#ifdef __cplusplus
108
}
109
#endif
110
111
#endif
lmmc_real_t
double lmmc_real_t
Public and internal LMMC real type.
定义
config.h:28
dense.h
lmmc_mat_t
行优先存储的稠密矩阵。
定义
dense_types.h:18
status.h
LMMC 通用状态码定义.
lmmc_status_t
lmmc_status_t
LMMC 库统一返回的状态码.
定义
status.h:22
lmmc_tensor_nd_permute
lmmc_status_t lmmc_tensor_nd_permute(const lmmc_tensor_nd_t *in, const size_t *perm, lmmc_tensor_nd_t *out)
按指定轴顺序置换张量,生成独立数据副本(转置的推广)。
定义
tensor_nd_views.c:42
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::owns_data
int owns_data
定义
tensor_nd.h:30
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_mode_n_product
lmmc_status_t lmmc_tensor_nd_mode_n_product(const lmmc_tensor_nd_t *t, const lmmc_mat_t *mat, size_t mode, lmmc_tensor_nd_t *out)
模-n 乘积:沿指定模与矩阵收缩.
定义
tensor_nd_products.c:282
lmmc_tensor_nd_contract
lmmc_status_t lmmc_tensor_nd_contract(const lmmc_tensor_nd_t *a, const lmmc_tensor_nd_t *b, const size_t *axes_a, const size_t *axes_b, size_t naxes, lmmc_tensor_nd_t *out)
张量收缩:沿匹配轴对求和.
定义
tensor_nd_products.c:196
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::ndim
size_t ndim
定义
tensor_nd.h:26
LMMC_TENSOR_MAX_NDIM
#define LMMC_TENSOR_MAX_NDIM
支持的最大张量维度.
定义
tensor_nd.h:17
lmmc_tensor_nd_t::data
lmmc_real_t * data
定义
tensor_nd.h:29
lmmc_tensor_nd_reshape_view
lmmc_status_t lmmc_tensor_nd_reshape_view(const lmmc_tensor_nd_t *src, size_t new_ndim, const size_t *new_dims, lmmc_tensor_nd_t *out_view)
零拷贝重塑 N-D 张量,返回共享缓冲区的非拥有视图。
定义
tensor_nd_views.c:97
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 张量,行优先连续存储,元素初始化为零.
定义
tensor_nd_storage.c:9
lmmc_tensor_nd_t::dims
size_t dims[LMMC_TENSOR_MAX_NDIM]
定义
tensor_nd.h:27
lmmc_tensor_nd_t::strides
size_t strides[LMMC_TENSOR_MAX_NDIM]
定义
tensor_nd.h:28
lmmc_tensor_nd_t
N-D 张量结构.
定义
tensor_nd.h:25
lmmc
tensor_nd.h
生成于
, 为 LMMC使用
1.18.0