---
title: make_tiled_store
description: "创建tiled_store策略，用于后续矩阵写回操作。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpckit/devg/KunpengHPCKit_developer_110.html
sourcePath: /source/zh/kunpenghpcs/hpckit/devg/KunpengHPCKit_developer_110.html
indexId: 5087744b9a3fae031f5aca15a1b9bbc15c5b88c53d542df66b45a68dbbf47ca067
---
# make_tiled_store

创建tiled_store策略，用于后续矩阵写回操作。

涉及store_atom原子矩阵写回方法和atom_shape原子方法扩展shape输入，其中store_atom写回矩阵大小与atom_shape相应m/n相乘所得乘积结果表示实际tiled_store方法写回矩阵大小。

当前atom_shape中m/n不支持任意扩展，只能设置为1。

#### 接口定义

template<typename StoreAtom, typename Shape>

TiledStore<StoreAtom, Shape> make_tiled_store( StoreAtom store_atom, Shape atom_shape);


#### 模板参数


**表1 模板参数定义**

| 参数名 | 类型 | 描述 |
| --- | --- | --- |
| StoreAtom | typename | store原子策略类型。 |
| Shape | typename | 形状类型。 |


#### 参数


**表2 参数定义**

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| store\_atom | StoreAtom，Ops<枚举store\_atom\_t> | store原子策略，当前store\_atom\_t可设置为： KP36\_32x16\_F64\_STORE，表示写回尺寸为32\*16，其中写回矩阵为行主序、计算步长为Stride<16, 1>，写回精度为float64的store原子行为 KP36\_16x64\_F32\_STORE，表示写回尺寸为16\*64，其中写回矩阵为行主序、计算步长为Stride<64, 1>，写回精度为float32的store原子行为 KP36\_16x64\_INT32\_STORE，表示写回尺寸为16\*64，其中写回矩阵为行主序、计算步长为Stride<64, 1>，写回精度为int32的store原子行为 KP36\_32x32\_INT32\_STORE，表示写回尺寸为32\*32，其中写回矩阵为行主序、计算步长为Stride<32, 1>，写回精度为int32的store原子行为 | 输入 |
| atom\_shape | Shape | 原子策略在各维度执行次数，包含m和n两个数值。 | 输入 |


#### 返回值

返回TiledStore<StoreAtom, Shape>对象


#### 示例

```
#include "stdlib.h"
#include "kupl_mma.h"
using namespace kupl::tensor;
int main()
{
constexpr int MATRIX_M  = 32;
constexpr int MATRIX_N  = 16;
constexpr int MATRIX_K = 512;
double *data_a = (double *)malloc(sizeof(double) * MATRIX_M * MATRIX_K);
double *data_b = (double *)malloc(sizeof(double) * MATRIX_K * MATRIX_N);
double *data_c = (double *)malloc(sizeof(double) * MATRIX_M * MATRIX_N);
auto shape_a = make_shape(Int<32>{}, Int<512>{});
auto shape_b = make_shape(Int<512>{}, Int<16>{});
auto shape_c = make_shape(Int<32>{}, Int<16>{});
auto stride_a = make_stride(Int<1>{}, Int<32>{});
auto stride_b = make_stride(Int<16>{}, Int<1>{});
auto stride_c = make_stride(Int<16>{}, Int<1>{});
auto layout_a = make_layout(shape_a, stride_a);
auto layout_b = make_layout(shape_b, stride_b);
auto layout_c = make_layout(shape_c, stride_c);
auto mma_atom_shape = make_shape(Int<1>{}, Int<1>{}, Int<1>{});
auto tiled_mma = make_tiled_mma(Ops<KP36_32x16x512_F64F64F64>{}, mma_atom_shape);
auto store_atom_shape = make_shape(Int<1>{}, Int<1>{});
auto tiled_store =
make_tiled_store
(Ops<KP36_32x16_F64_STORE>{}, store_atom_shape);
auto tensor_a = make_tensor(data_a, layout_a);
auto tensor_b = make_tensor(data_b, layout_b);
auto tensor_c = make_tensor(data_c, layout_c);
mma(tiled_mma, tensor_c, tensor_a, tensor_b, tensor_c);
store(tiled_store, tensor_c);
free(data_a);
free(data_b);
free(data_c);
return 0;
}
```

上述示例演示了基于32*16*512_F64F64F64矩阵形状的mma流程，其中通过make_tiled_store创建store tile策略。
