我要评分
获取效率
正确性
完整性
易理解

tensor_tiled_store

Write back matrix data.

This interface involves the TiledStore policy and the tensor D matrix input, where the shape and stride of tensor D must be consistent with those defined in the TiledStore policy.

Interface Definition

template<typename TiledStore, typename dtype, typename Layout>

void tensor_tiled_store(TiledStore store, Tensor<dtype, Layout> tensor);

Template Parameters

Table 1 Template parameter definition

Parameter

Type

Description

TiledStore

typename

Store tiling policy type.

dtype

typename

Precision type.

Layout

typename

Layout type.

Parameters

Table 2 Parameter definition

Parameter

Type

Description

Input/Output

store

TiledStore

Store tiling policy.

Input

tensor

Tensor<dtype, Layout>

Output matrix.

Output

Return Value

void

Examples

#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 tile_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);

    tensor_tiled_mma(tiled_mma, tensor_c, tensor_a, tensor_b, tensor_c);
    tensor_tiled_store(tile_store, tensor_c);

    free(data_a);
    free(data_b);
    free(data_c);
    return 0;
}

The preceding example demonstrates the MMA process based on the 32*16*512_F64F64F64 matrix shape, where tensor_tiled_store is used to write back the matrix operation results to the memory.