gemm_dl_fp32.cpp 4.96 KB
Newer Older
1
2
3
4
5
6
7
8
#include <algorithm>
#include <cstdlib>
#include <half.hpp>
#include <iostream>
#include <numeric>
#include <tuple>
#include <vector>

Jianfeng Yan's avatar
Jianfeng Yan committed
9
#include "../gemm/gemm_util.hpp"
10
11
12
13
14
15
16
#include "config.hpp"
#include "print.hpp"
#include "device.hpp"
#include "host_tensor.hpp"
#include "host_tensor_generator.hpp"
#include "host_gemm.hpp"
#include "device_tensor.hpp"
Jianfeng Yan's avatar
Jianfeng Yan committed
17
#include "device_gemm_dl.hpp"
18
19
20
21
22
23
#include "element_wise_operation.hpp"
#include "reference_gemm.hpp"
#include "gemm_specialization.hpp"

using PassThrough = ck::tensor_operation::element_wise::PassThrough;

24
using DeviceGemmNoOpPtr =
25
26
27
28
29
30
31
32
    ck::tensor_operation::device::DeviceGemmPtr<ck::tensor_operation::element_wise::PassThrough,
                                                ck::tensor_operation::element_wise::PassThrough,
                                                ck::tensor_operation::element_wise::PassThrough>;

namespace ck {
namespace tensor_operation {
namespace device {
namespace device_gemm_instance {
Jianfeng Yan's avatar
Jianfeng Yan committed
33
34
35
36
37
38

void add_device_gemm_dl_f32_f32_f32_km_kn_mn_instances(std::vector<DeviceGemmNoOpPtr>&);
void add_device_gemm_dl_f32_f32_f32_km_nk_mn_instances(std::vector<DeviceGemmNoOpPtr>&);
void add_device_gemm_dl_f32_f32_f32_mk_nk_mn_instances(std::vector<DeviceGemmNoOpPtr>&);
void add_device_gemm_dl_f32_f32_f32_mk_kn_mn_instances(std::vector<DeviceGemmNoOpPtr>&);

Chao Liu's avatar
Chao Liu committed
39
} // namespace device_gemm_instance
40
41
42
43
} // namespace device
} // namespace tensor_operation
} // namespace ck

44
45
int main()
{
46
47
48
49
    using ADataType   = float;
    using BDataType   = float;
    using CDataType   = float;
    using AccDataType = float;
50

51
52
    using RowMajor    = ck::tensor_layout::gemm::RowMajor;
    using ColumnMajor = ck::tensor_layout::gemm::ColumnMajor;
53

54
    bool res = true;
Jianfeng Yan's avatar
Jianfeng Yan committed
55
    std::vector<DeviceGemmNoOpPtr> gemmPtrs;
56
    ck::tensor_operation::device::device_gemm_instance::
Jianfeng Yan's avatar
Jianfeng Yan committed
57
        add_device_gemm_dl_f32_f32_f32_km_kn_mn_instances(gemmPtrs);
58

59
60
61
62
63
64
    for(auto& gemmPtr : gemmPtrs)
    {
        res &= ck::gemm_util::TestGemm<DeviceGemmNoOpPtr,
                                       ADataType,
                                       BDataType,
                                       CDataType,
65
                                       AccDataType,
66
67
68
69
70
71
72
                                       ColumnMajor,
                                       RowMajor,
                                       RowMajor,
                                       PassThrough,
                                       PassThrough,
                                       PassThrough>{}(gemmPtr);
    }
73

74
75
    gemmPtrs.clear();
    ck::tensor_operation::device::device_gemm_instance::
Jianfeng Yan's avatar
Jianfeng Yan committed
76
        add_device_gemm_dl_f32_f32_f32_km_nk_mn_instances(gemmPtrs);
77

78
79
80
81
82
83
    for(auto& gemmPtr : gemmPtrs)
    {
        res &= ck::gemm_util::TestGemm<DeviceGemmNoOpPtr,
                                       ADataType,
                                       BDataType,
                                       CDataType,
84
                                       AccDataType,
85
86
87
88
89
90
91
92
93
                                       ColumnMajor,
                                       ColumnMajor,
                                       RowMajor,
                                       PassThrough,
                                       PassThrough,
                                       PassThrough>{}(gemmPtr);
    }

    gemmPtrs.clear();
94
    ck::tensor_operation::device::device_gemm_instance::
Jianfeng Yan's avatar
Jianfeng Yan committed
95
        add_device_gemm_dl_f32_f32_f32_mk_kn_mn_instances(gemmPtrs);
96

97
98
99
100
101
102
    for(auto& gemmPtr : gemmPtrs)
    {
        res &= ck::gemm_util::TestGemm<DeviceGemmNoOpPtr,
                                       ADataType,
                                       BDataType,
                                       CDataType,
103
                                       AccDataType,
104
105
106
107
108
109
110
111
112
113
                                       RowMajor,
                                       RowMajor,
                                       RowMajor,
                                       PassThrough,
                                       PassThrough,
                                       PassThrough>{}(gemmPtr);
    }

    gemmPtrs.clear();
    ck::tensor_operation::device::device_gemm_instance::
Jianfeng Yan's avatar
Jianfeng Yan committed
114
        add_device_gemm_dl_f32_f32_f32_mk_nk_mn_instances(gemmPtrs);
115
116
117

    for(auto& gemmPtr : gemmPtrs)
    {
118
119
120
121
        res &= ck::gemm_util::TestGemm<DeviceGemmNoOpPtr,
                                       ADataType,
                                       BDataType,
                                       CDataType,
122
                                       AccDataType,
123
124
125
126
127
128
                                       RowMajor,
                                       ColumnMajor,
                                       RowMajor,
                                       PassThrough,
                                       PassThrough,
                                       PassThrough>{}(gemmPtr);
129
130
131
    }

    std::cout << "TestGemm ..... " << (res ? "SUCCESS" : "FAILURE") << std::endl;
rocking5566's avatar
rocking5566 committed
132
    return res ? 0 : 1;
133
}