tensor_tiled_copy(Prefetch)
Prefetch类型的tensor_tiled_copy接口表示针对矩阵的预取Copy操作,与上述Trans类型的tensor_tiled_copy接口相比主要差异在于入参上,采用了C++函数重载的特性进行实现。
涉及TiledCopy策略和Tensor src矩阵输入,其中Tensor src的形状Shape和跨度步长Stride必须与TiledCopy策略定义一致。
接口定义
template<typename TiledCopy,
typename dtypeS, typename LayoutS>
void tensor_tiled_copy(TiledCopy copy, Tensor<dtypeS, LayoutS> src);
模板参数
参数名 |
类型 |
描述 |
|---|---|---|
TiledStore |
typename |
copy tile策略类型。 |
dtypeS |
typename |
src精度类型。 |
LayoutS |
typename |
src布局类型。 |
参数
参数名 |
类型 |
描述 |
输入/输出 |
|---|---|---|---|
copy |
TiledCopy |
copy tile策略。 |
输入 |
src |
Tensor<dtypeS, LayoutS> |
转置源矩阵。 |
输入 |
返回值
void
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <stdio.h> #include <stdlib.h> #include "kupl_mma.h" using namespace kupl::tensor; int main() { double *src = (double*)malloc(sizeof(double) * 8); auto shape_s = make_shape(Int<8>{}); auto stride_s = make_stride(Int<1>{}); auto layout_s = make_layout(shape_s, stride_s); auto tensor_s = make_tensor(src, layout_s); auto atom_copy_shape = make_shape(Int<1>{}); auto tiled_copy = make_tiled_copy(Ops<KP36_PREFETCH_L1>, atom_copy_shape); tensor_tiled_copy(tiled_copy, tensor_s); free(src); return 0; } |
上述示例演示了double精度buffer对象的L1预取操作行为,其中一次预取操作可以处理8个double数据。
父主题: 矩阵编程接口函数