tensor_layout.hpp 1.91 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef TENSOR_LAYOUT_HPP
#define TENSOR_LAYOUT_HPP

namespace ck {
namespace tensor_layout {

struct BaseTensorLayout
{
};

namespace gemm {

struct RowMajor : public BaseTensorLayout
{
15
    static constexpr const char* name = "RowMajor";
16
17
18
19
};

struct ColumnMajor : public BaseTensorLayout
{
20
    static constexpr const char* name = "ColumnMajor";
21
22
23
24
25
};
} // namespace gemm

namespace convolution {

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// 1D Conv
struct NWC : public BaseTensorLayout
{
    static constexpr const char* name = "NWC";
};

struct KXC : public BaseTensorLayout
{
    static constexpr const char* name = "KXC";
};

struct NWK : public BaseTensorLayout
{
    static constexpr const char* name = "NWK";
};

struct NCW : public BaseTensorLayout
{
    static constexpr const char* name = "NCW";
};

struct KCX : public BaseTensorLayout
{
    static constexpr const char* name = "KCX";
};

struct NKW : public BaseTensorLayout
{
    static constexpr const char* name = "NKW";
};

// 2D Conv
58
59
struct NHWC : public BaseTensorLayout
{
60
    static constexpr const char* name = "NHWC";
61
62
63
64
};

struct KYXC : public BaseTensorLayout
{
65
    static constexpr const char* name = "KYXC";
66
67
68
69
};

struct NHWK : public BaseTensorLayout
{
70
    static constexpr const char* name = "NHWK";
71
72
73
74
};

struct NCHW : public BaseTensorLayout
{
75
    static constexpr const char* name = "NCHW";
76
77
78
79
};

struct KCYX : public BaseTensorLayout
{
80
    static constexpr const char* name = "KCYX";
81
82
83
84
};

struct NKHW : public BaseTensorLayout
{
85
    static constexpr const char* name = "NKHW";
86
87
};

Jianfeng Yan's avatar
Jianfeng Yan committed
88
89
90
91
92
93
94
95
96
97
98
99
struct NDHWC : public BaseTensorLayout
{
};

struct KZYXC : public BaseTensorLayout
{
};

struct NDHWK : public BaseTensorLayout
{
};

100
101
} // namespace convolution

102
103
104
105
106
107
108
109
110
template <
    typename Layout,
    typename std::enable_if<std::is_base_of<BaseTensorLayout, Layout>::value, bool>::type = false>
std::ostream& operator<<(std::ostream& os, const Layout&)
{
    os << Layout::name;
    return os;
}

111
112
113
} // namespace tensor_layout
} // namespace ck
#endif