gemm_xdl_fp16.cpp 3.31 KB
Newer Older
Chao Liu's avatar
Chao Liu committed
1
// SPDX-License-Identifier: MIT
Illia Silin's avatar
Illia Silin committed
2
// Copyright (c) 2018-2023, Advanced Micro Devices, Inc. All rights reserved.
Chao Liu's avatar
Chao Liu committed
3

4
#include "common.hpp"
Chao Liu's avatar
Chao Liu committed
5

6
7
#include "ck/tensor_operation/gpu/device/impl/device_gemm_xdl.hpp"
#include "ck/tensor_operation/gpu/device/impl/device_gemm_xdl_cshuffle.hpp"
Chao Liu's avatar
Chao Liu committed
8

9
10
11
12
13
using ADataType        = ck::half_t;
using BDataType        = ck::half_t;
using AccDataType      = float;
using CShuffleDataType = float;
using CDataType        = ck::half_t;
Chao Liu's avatar
Chao Liu committed
14

15
16
using F16 = ck::half_t;

17
18
19
using ALayout = Row;
using BLayout = Col;
using CLayout = Row;
Chao Liu's avatar
Chao Liu committed
20

21
22
23
using AElementOp = PassThrough;
using BElementOp = PassThrough;
using CElementOp = PassThrough;
Chao Liu's avatar
Chao Liu committed
24

25
static constexpr auto GemmDefault = ck::tensor_operation::device::GemmSpecialization::Default;
Chao Liu's avatar
Chao Liu committed
26

27
// clang-format off
Po Yen Chen's avatar
Po Yen Chen committed
28
using DeviceGemmInstance0 = ck::tensor_operation::device::DeviceGemmXdl
29
30
31
32
// ######|     AData|     BData|     CData|     AccData| ALayout| BLayout| CLayout|           A|           B|           C|          GEMM| Block|  MPer|  NPer| K0Per| K1| MPer| NPer| MXdl| NXdl|  ABlockTransfer| ABlockTransfer| ABlockTransfer| ABlockTransfer| ABlockTransfer| ABlockTransfer| ABlockLds|  BBlockTransfer| BBlockTransfer| BBlockTransfer| BlockTransfer| BBlockTransfer| BBlockTransfer| BBlockLds| CThreadTransfer| CThreadTransfer|
// ######|      Type|      Type|      Type|        Type|        |        |        | Elementwise| Elementwise| Elementwise|Spacialization|  Size| Block| Block| Block|   |  XDL|  XDL|  Per|  Per|   ThreadCluster|  ThreadCluster| SrcAccessOrder|   SrcVectorDim|      SrcScalar|      DstScalar| AddExtraM|   ThreadCluster|  ThreadCluster| SrcAccessOrder|  SrcVectorDim|      SrcScalar|      DstScalar| AddExtraN| SrcDstVectorDim|       DstScalar|
// ######|          |          |          |            |        |        |        |   Operation|   Operation|   Operation|              |      |      |      |      |   |     |     | Wave| Wave| Lengths_K0_M_K1|   ArrangeOrder|               |               |      PerVector|   PerVector_K1|          | Lengths_K0_N_K1|   ArrangeOrder|               |              |      PerVector|   PerVector_K1|          |                |       PerVector|
// ######|          |          |          |            |        |        |        |            |            |            |              |      |      |      |      |   |     |     |     |     |                |               |               |               |               |               |          |                |               |               |              |               |               |          |                |                |
Po-Yen, Chen's avatar
Po-Yen, Chen committed
33
         < ADataType, BDataType, CDataType, AccDataType, ALayout, BLayout, CLayout,  AElementOp,  BElementOp,  CElementOp,   GemmDefault,   256,   256,   128,     4,  8,   32,   32,    4,    2,     S<4, 64, 1>,     S<1, 0, 2>,     S<1, 0, 2>,              2,              8,              8,     false,     S<4, 64, 1>,     S<1, 0, 2>,     S<1, 0, 2>,             2,              8,              8,     false,               7,               1>;
34
// // clang-format on
Po Yen Chen's avatar
Po Yen Chen committed
35

Po-Yen, Chen's avatar
Po-Yen, Chen committed
36
using DeviceGemmInstance = DeviceGemmInstance0;
Po Yen Chen's avatar
Po Yen Chen committed
37

Chao Liu's avatar
Chao Liu committed
38
using ReferenceGemmInstance = ck::tensor_operation::host::
39
    ReferenceGemm<ADataType, BDataType, CDataType, AccDataType, AElementOp, BElementOp, CElementOp>;
40

41
#include "run_gemm_example.inc"
Jianfeng Yan's avatar
Jianfeng Yan committed
42

43
int main(int argc, char* argv[]) { return !run_gemm_example(argc, argv); }