Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
composable_kernel
Commits
289f15de
Commit
289f15de
authored
Dec 09, 2022
by
aska-0096
Browse files
Merge branch 'develop' of
https://github.com/ROCmSoftwarePlatform/composable_kernel
into wmma_gemm
parents
9bd44685
d58b7f51
Changes
371
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
251 additions
and
210 deletions
+251
-210
profiler/src/profile_conv_fwd_bias_relu.cpp
profiler/src/profile_conv_fwd_bias_relu.cpp
+8
-2
profiler/src/profile_conv_fwd_bias_relu_add.cpp
profiler/src/profile_conv_fwd_bias_relu_add.cpp
+8
-3
profiler/src/profile_gemm.cpp
profiler/src/profile_gemm.cpp
+8
-2
profiler/src/profile_gemm_add_add_fastgelu.cpp
profiler/src/profile_gemm_add_add_fastgelu.cpp
+8
-2
profiler/src/profile_gemm_bias_add_reduce.cpp
profiler/src/profile_gemm_bias_add_reduce.cpp
+8
-2
profiler/src/profile_gemm_bilinear.cpp
profiler/src/profile_gemm_bilinear.cpp
+8
-2
profiler/src/profile_gemm_reduce.cpp
profiler/src/profile_gemm_reduce.cpp
+8
-2
profiler/src/profile_gemm_splitk.cpp
profiler/src/profile_gemm_splitk.cpp
+8
-2
profiler/src/profile_grouped_conv_bwd_weight.cpp
profiler/src/profile_grouped_conv_bwd_weight.cpp
+54
-47
profiler/src/profile_grouped_conv_fwd.cpp
profiler/src/profile_grouped_conv_fwd.cpp
+8
-2
profiler/src/profile_grouped_gemm.cpp
profiler/src/profile_grouped_gemm.cpp
+8
-2
profiler/src/profile_groupnorm.cpp
profiler/src/profile_groupnorm.cpp
+9
-3
profiler/src/profile_layernorm.cpp
profiler/src/profile_layernorm.cpp
+5
-2
profiler/src/profile_reduce.cpp
profiler/src/profile_reduce.cpp
+5
-2
profiler/src/profile_softmax.cpp
profiler/src/profile_softmax.cpp
+4
-1
profiler/src/profiler.cpp
profiler/src/profiler.cpp
+9
-130
profiler/src/profiler_operation_registry.hpp
profiler/src/profiler_operation_registry.hpp
+79
-0
test/CMakeLists.txt
test/CMakeLists.txt
+4
-2
test/batched_gemm/batched_gemm_bf16.cpp
test/batched_gemm/batched_gemm_bf16.cpp
+1
-1
test/batched_gemm/batched_gemm_fp16.cpp
test/batched_gemm/batched_gemm_fp16.cpp
+1
-1
No files found.
profiler/src/profile_conv_fwd_bias_relu.cpp
View file @
289f15de
...
...
@@ -6,7 +6,8 @@
#include <initializer_list>
#include <cstdlib>
#include "profiler/include/profile_conv_fwd_bias_relu_impl.hpp"
#include "profiler/profile_conv_fwd_bias_relu_impl.hpp"
#include "profiler_operation_registry.hpp"
enum
struct
ConvDataType
{
...
...
@@ -32,11 +33,14 @@ enum struct ConvOutputLayout
NHWK
,
// 1
};
#define OP_NAME "conv_fwd_bias_relu"
#define OP_DESC "Convolution Forward+Bias+ReLU"
int
profile_conv_fwd_bias_relu
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
25
)
{
printf
(
"arg1: tensor operation (
conv_fwd_bias_relu: ForwardConvolution+Bias+ReLu
)
\n
"
);
printf
(
"arg1: tensor operation (
"
OP_NAME
": "
OP_DESC
"
)
\n
"
);
printf
(
"arg2: data type (0: fp32; 1: fp16)
\n
"
);
printf
(
"arg3: input tensor layout (0: NCHW; 1: NHWC)
\n
"
);
printf
(
"arg4: weight tensor layout (0: KCYX; 1: KYXC)
\n
"
);
...
...
@@ -114,3 +118,5 @@ int profile_conv_fwd_bias_relu(int argc, char* argv[])
return
0
;
}
REGISTER_PROFILER_OPERATION
(
OP_NAME
,
OP_DESC
,
profile_conv_fwd_bias_relu
);
profiler/src/profile_conv_fwd_bias_relu_add.cpp
View file @
289f15de
...
...
@@ -6,7 +6,8 @@
#include <initializer_list>
#include <cstdlib>
#include "profiler/include/profile_conv_fwd_bias_relu_add_impl.hpp"
#include "profiler/profile_conv_fwd_bias_relu_add_impl.hpp"
#include "profiler_operation_registry.hpp"
enum
struct
ConvDataType
{
...
...
@@ -32,12 +33,14 @@ enum struct ConvOutputLayout
NHWK
,
// 1
};
#define OP_NAME "conv_fwd_bias_relu_add"
#define OP_DESC "Convolution Forward+Bias+ReLU+Add"
int
profile_conv_fwd_bias_relu_add
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
25
)
{
printf
(
"arg1: tensor operation (conv_fwd_bias_relu_add: ForwardConvolution+Bias+ReLu+Add)
\n
"
);
printf
(
"arg1: tensor operation ("
OP_NAME
": "
OP_DESC
")
\n
"
);
printf
(
"arg2: data type (0: fp32; 1: fp16)
\n
"
);
printf
(
"arg3: input tensor layout (0: NCHW; 1: NHWC)
\n
"
);
printf
(
"arg4: weight tensor layout (0: KCYX; 1: KYXC)
\n
"
);
...
...
@@ -115,3 +118,5 @@ int profile_conv_fwd_bias_relu_add(int argc, char* argv[])
return
0
;
}
REGISTER_PROFILER_OPERATION
(
OP_NAME
,
OP_DESC
,
profile_conv_fwd_bias_relu_add
);
profiler/src/profile_gemm.cpp
View file @
289f15de
...
...
@@ -6,7 +6,8 @@
#include <initializer_list>
#include <cstdlib>
#include "profiler/include/profile_gemm_impl.hpp"
#include "profiler/profile_gemm_impl.hpp"
#include "profiler_operation_registry.hpp"
enum
struct
GemmMatrixLayout
{
...
...
@@ -24,9 +25,12 @@ enum struct GemmDataType
INT8_INT8_INT8
,
// 3
};
#define OP_NAME "gemm"
#define OP_DESC "GEMM"
static
void
print_helper_msg
()
{
std
::
cout
<<
"arg1: tensor operation (
gemm: GEMM
)
\n
"
std
::
cout
<<
"arg1: tensor operation (
"
OP_NAME
": "
OP_DESC
"
)
\n
"
<<
"arg2: data type (0: fp32; 1: fp16; 2: bf16; 3: int8)
\n
"
<<
"arg3: matrix layout (0: A[m, k] * B[k, n] = C[m, n];
\n
"
<<
" 1: A[m, k] * B[n, k] = C[m, n];
\n
"
...
...
@@ -184,3 +188,5 @@ int profile_gemm(int argc, char* argv[])
return
1
;
}
}
REGISTER_PROFILER_OPERATION
(
OP_NAME
,
OP_DESC
,
profile_gemm
);
profiler/src/profile_gemm_add_add_fastgelu.cpp
View file @
289f15de
...
...
@@ -6,7 +6,11 @@
#include <initializer_list>
#include <cstdlib>
#include "profiler/include/profile_gemm_add_add_fastgelu_impl.hpp"
#include "profiler/profile_gemm_add_add_fastgelu_impl.hpp"
#include "profiler_operation_registry.hpp"
#define OP_NAME "gemm_add_add_fastgelu"
#define OP_DESC "GEMM+Add+Add+FastGeLU"
int
profile_gemm_add_add_fastgelu
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -29,7 +33,7 @@ int profile_gemm_add_add_fastgelu(int argc, char* argv[])
if
(
argc
!=
16
)
{
// clang-format off
printf
(
"arg1: tensor operation (
gemm_add_add_fastgelu: GEMM+Add+Add+FastGeLU
)
\n
"
);
printf
(
"arg1: tensor operation (
"
OP_NAME
": "
OP_DESC
"
)
\n
"
);
printf
(
"arg2: data type (0: fp32; 1: fp16; 2: bf16; 3: int8)
\n
"
);
printf
(
"arg3: matrix layout (0: E[m, n] = FastGeLU(A[m, k] * B[k, n] + D0[m, n] + D1[m, n]);
\n
"
);
printf
(
" 1: E[m, n] = FastGeLU(A[m, k] * B[n, k] + D0[m, n] + D1[m, n]);
\n
"
);
...
...
@@ -150,3 +154,5 @@ int profile_gemm_add_add_fastgelu(int argc, char* argv[])
return
1
;
}
}
REGISTER_PROFILER_OPERATION
(
OP_NAME
,
OP_DESC
,
profile_gemm_add_add_fastgelu
);
profiler/src/profile_gemm_bias_add_reduce.cpp
View file @
289f15de
...
...
@@ -6,7 +6,11 @@
#include <initializer_list>
#include <cstdlib>
#include "profiler/include/profile_gemm_bias_add_reduce_impl.hpp"
#include "profiler/profile_gemm_bias_add_reduce_impl.hpp"
#include "profiler_operation_registry.hpp"
#define OP_NAME "gemm_bias_add_reduce"
#define OP_DESC "GEMM+Bias+Add+Reduce"
int
profile_gemm_bias_add_reduce
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -26,7 +30,7 @@ int profile_gemm_bias_add_reduce(int argc, char* argv[])
if
(
!
(
argc
==
14
||
argc
==
15
))
{
printf
(
"arg1: tensor operation (
gemm: GEMM+bias+add+Reduce
)
\n
"
);
printf
(
"arg1: tensor operation (
"
OP_NAME
": "
OP_DESC
"
)
\n
"
);
printf
(
"arg2: data type (0: fp32; 1: fp16)
\n
"
);
printf
(
"arg3: matrix layout (0: A[m, k] * B[k, n] = C[m, n];
\n
"
);
printf
(
" 1: A[m, k] * B[n, k] = C[m, n];
\n
"
);
...
...
@@ -159,3 +163,5 @@ int profile_gemm_bias_add_reduce(int argc, char* argv[])
return
0
;
}
REGISTER_PROFILER_OPERATION
(
OP_NAME
,
OP_DESC
,
profile_gemm_bias_add_reduce
);
profiler/src/profile_gemm_bilinear.cpp
View file @
289f15de
...
...
@@ -6,7 +6,11 @@
#include <initializer_list>
#include <cstdlib>
#include "profiler/include/profile_gemm_bilinear_impl.hpp"
#include "profiler/profile_gemm_bilinear_impl.hpp"
#include "profiler_operation_registry.hpp"
#define OP_NAME "gemm_bilinear"
#define OP_DESC "GEMM+Bilinear"
int
profile_gemm_bilinear
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -29,7 +33,7 @@ int profile_gemm_bilinear(int argc, char* argv[])
if
(
argc
!=
17
)
{
// clang-format off
printf
(
"arg1: tensor operation (
gemm_bilinear: GEMM+Bilinear
)
\n
"
);
printf
(
"arg1: tensor operation (
"
OP_NAME
": "
OP_DESC
"
)
\n
"
);
printf
(
"arg2: data type (0: fp32; 1: fp16; 2: bf16; 3: int8)
\n
"
);
printf
(
"arg3: matrix layout (0: E[m, n] = alpha * A[m, k] * B[k, n] + beta * D[m, n];
\n
"
);
printf
(
" 1: E[m, n] = alpha * A[m, k] * B[n, k] + beta * D[m, n];
\n
"
);
...
...
@@ -144,3 +148,5 @@ int profile_gemm_bilinear(int argc, char* argv[])
return
1
;
}
}
REGISTER_PROFILER_OPERATION
(
OP_NAME
,
OP_DESC
,
profile_gemm_bilinear
);
profiler/src/profile_gemm_reduce.cpp
View file @
289f15de
...
...
@@ -6,7 +6,11 @@
#include <initializer_list>
#include <cstdlib>
#include "profiler/include/profile_gemm_reduce_impl.hpp"
#include "profiler/profile_gemm_reduce_impl.hpp"
#include "profiler_operation_registry.hpp"
#define OP_NAME "gemm_reduce"
#define OP_DESC "GEMM+Reduce"
int
profile_gemm_reduce
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -26,7 +30,7 @@ int profile_gemm_reduce(int argc, char* argv[])
if
(
!
(
argc
==
14
||
argc
==
15
))
{
printf
(
"arg1: tensor operation (
gemm: GEMM+Reduce
)
\n
"
);
printf
(
"arg1: tensor operation (
"
OP_NAME
": "
OP_DESC
"
)
\n
"
);
printf
(
"arg2: data type (0: fp32; 1: fp16)
\n
"
);
printf
(
"arg3: matrix layout (0: A[m, k] * B[k, n] = C[m, n];
\n
"
);
printf
(
" 1: A[m, k] * B[n, k] = C[m, n];
\n
"
);
...
...
@@ -146,3 +150,5 @@ int profile_gemm_reduce(int argc, char* argv[])
return
0
;
}
REGISTER_PROFILER_OPERATION
(
OP_NAME
,
OP_DESC
,
profile_gemm_reduce
);
profiler/src/profile_gemm_splitk.cpp
View file @
289f15de
...
...
@@ -6,7 +6,8 @@
#include <initializer_list>
#include <cstdlib>
#include "profiler/include/profile_gemm_splitk_impl.hpp"
#include "profiler/profile_gemm_splitk_impl.hpp"
#include "profiler_operation_registry.hpp"
enum
struct
GemmMatrixLayout
{
...
...
@@ -24,11 +25,14 @@ enum struct GemmDataType
INT8_INT8_INT8
,
// 3
};
#define OP_NAME "gemm_splitk"
#define OP_DESC "Split-K GEMM"
int
profile_gemm_splitk
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
15
)
{
printf
(
"arg1: tensor operation (
gemm_splitk: Split-K GEMM
)
\n
"
);
printf
(
"arg1: tensor operation (
"
OP_NAME
": "
OP_DESC
"
)
\n
"
);
printf
(
"arg2: data type (0: fp32; 1: fp16; 2: bf16; 3: int8)
\n
"
);
printf
(
"arg3: matrix layout (0: A[m, k] * B[k, n] = C[m, n];
\n
"
);
printf
(
" 1: A[m, k] * B[n, k] = C[m, n];
\n
"
);
...
...
@@ -146,3 +150,5 @@ int profile_gemm_splitk(int argc, char* argv[])
return
1
;
}
}
REGISTER_PROFILER_OPERATION
(
OP_NAME
,
OP_DESC
,
profile_gemm_splitk
);
profiler/src/profile_conv_bwd_weight.cpp
→
profiler/src/profile_
grouped_
conv_bwd_weight.cpp
View file @
289f15de
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <cstdlib>
#include <initializer_list>
#include <iostream>
#include <numeric>
#include <initializer_list>
#include <cstdlib>
#include "profiler/include/profile_conv_bwd_weight_impl.hpp"
#include "profiler/profile_grouped_conv_bwd_weight_impl.hpp"
#include "profiler_operation_registry.hpp"
namespace
{
enum
struct
ConvLayout
{
NCHW_KCYX_NKHW
,
// 0
NHWC_KYXC_NHWK
,
// 1
G
NCHW_
G
KCYX_
G
NKHW
,
// 0
G
NHWC_
G
KYXC_
G
NHWK
,
// 1
};
enum
struct
ConvDataType
...
...
@@ -23,26 +24,30 @@ enum struct ConvDataType
BF16_F32_BF16
,
// 2
};
#define OP_NAME "grouped_conv_bwd_weight"
#define OP_DESC "Grouped Convolution Backward Weight"
static
void
print_helper_msg
()
{
std
::
cout
<<
"arg1: tensor operation (conv_bwd_weight: Convolution Backward Weight
\n
"
<<
"arg2: data type (0: Input fp32, Weight fp32, Output fp32
\n
"
<<
" 1: Input fp16, Weight fp16, Output fp16
\n
"
<<
" 2: Input bf16, Weight fp32, Output bf16)
\n
"
<<
"arg3: tensor layout (0: Input[N, C, Hi, Wi], Weight[K, C, Y, X], Output[N, K, Ho, Wo]
\n
"
<<
" 1: Input[N, Hi, Wi, C], Weight[K, Y, X, C], Output[N, Ho, Wo, K]
\n
"
<<
"arg4: verification (0: no, 1: yes)
\n
"
<<
"arg5: initialization (0: no init, 1: integer value, 2: decimal value)
\n
"
<<
"arg6: print tensor value (0: no; 1: yes)
\n
"
<<
"arg7: time kernel (0: no, 1: yes)
\n
"
<<
ck
::
utils
::
conv
::
get_conv_param_parser_helper_msg
()
<<
" SplitK
\n
"
<<
std
::
endl
;
std
::
cout
<<
"arg1: tensor operation ("
OP_NAME
": "
OP_DESC
")
\n
"
<<
"arg2: data type (0: Input fp32, Weight fp32, Output fp32
\n
"
<<
" 1: Input fp16, Weight fp16, Output fp16
\n
"
<<
" 2: Input bf16, Weight fp32, Output bf16)
\n
"
<<
"arg3: tensor layout (0: Input[G, N, C, Hi, Wi], Weight[G, K, C, Y, X], Output[G, "
"N, K, Ho, Wo]
\n
"
<<
" 1: Input[G, N, Hi, Wi, C], Weight[G, K, Y, X, C], Output[G, "
"N, Ho, Wo, K]
\n
"
<<
"arg4: verification (0: no, 1: yes)
\n
"
<<
"arg5: initialization (0: no init, 1: integer value, 2: decimal value)
\n
"
<<
"arg6: print tensor value (0: no; 1: yes)
\n
"
<<
"arg7: time kernel (0: no, 1: yes)
\n
"
<<
ck
::
utils
::
conv
::
get_conv_param_parser_helper_msg
()
<<
" SplitK
\n
"
<<
std
::
endl
;
}
}
// namespace
int
profile_conv_bwd_weight
(
int
argc
,
char
*
argv
[])
int
profile_
grouped_
conv_bwd_weight
(
int
argc
,
char
*
argv
[])
{
// 8 for control, 1 for num_dim_spatial
if
(
argc
<
9
)
...
...
@@ -75,17 +80,17 @@ int profile_conv_bwd_weight(int argc, char* argv[])
using
F16
=
ck
::
half_t
;
using
BF16
=
ck
::
bhalf_t
;
using
NWC
=
ck
::
tensor_layout
::
convolution
::
NWC
;
using
NHWC
=
ck
::
tensor_layout
::
convolution
::
NHWC
;
using
NDHWC
=
ck
::
tensor_layout
::
convolution
::
NDHWC
;
using
G
NWC
=
ck
::
tensor_layout
::
convolution
::
G
NWC
;
using
G
NHWC
=
ck
::
tensor_layout
::
convolution
::
G
NHWC
;
using
G
NDHWC
=
ck
::
tensor_layout
::
convolution
::
G
NDHWC
;
using
KXC
=
ck
::
tensor_layout
::
convolution
::
KXC
;
using
KYXC
=
ck
::
tensor_layout
::
convolution
::
KYXC
;
using
KZYXC
=
ck
::
tensor_layout
::
convolution
::
KZYXC
;
using
G
KXC
=
ck
::
tensor_layout
::
convolution
::
G
KXC
;
using
G
KYXC
=
ck
::
tensor_layout
::
convolution
::
G
KYXC
;
using
G
KZYXC
=
ck
::
tensor_layout
::
convolution
::
G
KZYXC
;
using
NWK
=
ck
::
tensor_layout
::
convolution
::
NWK
;
using
NHWK
=
ck
::
tensor_layout
::
convolution
::
NHWK
;
using
NDHWK
=
ck
::
tensor_layout
::
convolution
::
NDHWK
;
using
G
NWK
=
ck
::
tensor_layout
::
convolution
::
G
NWK
;
using
G
NHWK
=
ck
::
tensor_layout
::
convolution
::
G
NHWK
;
using
G
NDHWK
=
ck
::
tensor_layout
::
convolution
::
G
NDHWK
;
constexpr
auto
I1
=
ck
::
Number
<
1
>
{};
constexpr
auto
I2
=
ck
::
Number
<
2
>
{};
...
...
@@ -108,64 +113,64 @@ int profile_conv_bwd_weight(int argc, char* argv[])
using
WeiDataType
=
decltype
(
wei_type
);
using
OutDataType
=
decltype
(
out_type
);
bool
pass
=
ck
::
profiler
::
profile_conv_bwd_weight_impl
<
NDimSpatial
,
InLayout
,
WeiLayout
,
OutLayout
,
InDataType
,
WeiDataType
,
OutDataType
>
(
bool
pass
=
ck
::
profiler
::
profile_
grouped_
conv_bwd_weight_impl
<
NDimSpatial
,
InLayout
,
WeiLayout
,
OutLayout
,
InDataType
,
WeiDataType
,
OutDataType
>
(
do_verification
,
init_method
,
do_log
,
time_kernel
,
params
,
split_k
);
return
pass
?
0
:
1
;
};
if
(
num_dim_spatial
==
1
&&
layout
==
ConvLayout
::
NHWC_KYXC_NHWK
)
if
(
num_dim_spatial
==
1
&&
layout
==
ConvLayout
::
G
NHWC_
G
KYXC_
G
NHWK
)
{
if
(
data_type
==
ConvDataType
::
F32_F32_F32
)
{
return
profile
(
I1
,
NWC
{},
KXC
{},
NWK
{},
F32
{},
F32
{},
F32
{});
return
profile
(
I1
,
G
NWC
{},
G
KXC
{},
G
NWK
{},
F32
{},
F32
{},
F32
{});
}
else
if
(
data_type
==
ConvDataType
::
F16_F16_F16
)
{
return
profile
(
I1
,
NWC
{},
KXC
{},
NWK
{},
F16
{},
F16
{},
F16
{});
return
profile
(
I1
,
G
NWC
{},
G
KXC
{},
G
NWK
{},
F16
{},
F16
{},
F16
{});
}
else
if
(
data_type
==
ConvDataType
::
BF16_F32_BF16
)
{
// fp32 atomic add is used for weight tensor in bf16 kernel
return
profile
(
I1
,
NWC
{},
KXC
{},
NWK
{},
BF16
{},
F32
{},
BF16
{});
return
profile
(
I1
,
G
NWC
{},
G
KXC
{},
G
NWK
{},
BF16
{},
F32
{},
BF16
{});
}
}
else
if
(
num_dim_spatial
==
2
&&
layout
==
ConvLayout
::
NHWC_KYXC_NHWK
)
else
if
(
num_dim_spatial
==
2
&&
layout
==
ConvLayout
::
G
NHWC_
G
KYXC_
G
NHWK
)
{
if
(
data_type
==
ConvDataType
::
F32_F32_F32
)
{
return
profile
(
I2
,
NHWC
{},
KYXC
{},
NHWK
{},
F32
{},
F32
{},
F32
{});
return
profile
(
I2
,
G
NHWC
{},
G
KYXC
{},
G
NHWK
{},
F32
{},
F32
{},
F32
{});
}
else
if
(
data_type
==
ConvDataType
::
F16_F16_F16
)
{
return
profile
(
I2
,
NHWC
{},
KYXC
{},
NHWK
{},
F16
{},
F16
{},
F16
{});
return
profile
(
I2
,
G
NHWC
{},
G
KYXC
{},
G
NHWK
{},
F16
{},
F16
{},
F16
{});
}
else
if
(
data_type
==
ConvDataType
::
BF16_F32_BF16
)
{
// fp32 atomic add is used for weight tensor in bf16 kernel
return
profile
(
I2
,
NHWC
{},
KYXC
{},
NHWK
{},
BF16
{},
F32
{},
BF16
{});
return
profile
(
I2
,
G
NHWC
{},
G
KYXC
{},
G
NHWK
{},
BF16
{},
F32
{},
BF16
{});
}
}
else
if
(
num_dim_spatial
==
3
&&
layout
==
ConvLayout
::
NHWC_KYXC_NHWK
)
else
if
(
num_dim_spatial
==
3
&&
layout
==
ConvLayout
::
G
NHWC_
G
KYXC_
G
NHWK
)
{
if
(
data_type
==
ConvDataType
::
F32_F32_F32
)
{
return
profile
(
I3
,
NDHWC
{},
KZYXC
{},
NDHWK
{},
F32
{},
F32
{},
F32
{});
return
profile
(
I3
,
G
NDHWC
{},
G
KZYXC
{},
G
NDHWK
{},
F32
{},
F32
{},
F32
{});
}
else
if
(
data_type
==
ConvDataType
::
F16_F16_F16
)
{
return
profile
(
I3
,
NDHWC
{},
KZYXC
{},
NDHWK
{},
F16
{},
F16
{},
F16
{});
return
profile
(
I3
,
G
NDHWC
{},
G
KZYXC
{},
G
NDHWK
{},
F16
{},
F16
{},
F16
{});
}
else
if
(
data_type
==
ConvDataType
::
BF16_F32_BF16
)
{
// fp32 atomic add is used for weight tensor in bf16 kernel
return
profile
(
I3
,
NDHWC
{},
KZYXC
{},
NDHWK
{},
BF16
{},
F32
{},
BF16
{});
return
profile
(
I3
,
G
NDHWC
{},
G
KZYXC
{},
G
NDHWK
{},
BF16
{},
F32
{},
BF16
{});
}
}
...
...
@@ -173,3 +178,5 @@ int profile_conv_bwd_weight(int argc, char* argv[])
return
1
;
}
REGISTER_PROFILER_OPERATION
(
OP_NAME
,
OP_DESC
,
profile_grouped_conv_bwd_weight
);
profiler/src/profile_grouped_conv_fwd.cpp
View file @
289f15de
...
...
@@ -6,7 +6,8 @@
#include <initializer_list>
#include <cstdlib>
#include "profiler/include/profile_grouped_conv_fwd_impl.hpp"
#include "profiler/profile_grouped_conv_fwd_impl.hpp"
#include "profiler_operation_registry.hpp"
namespace
{
...
...
@@ -24,11 +25,14 @@ enum struct ConvDataType
INT8_INT8_INT8
,
// 3
};
#define OP_NAME "grouped_conv_fwd"
#define OP_DESC "Grouped Convolution Forward"
static
void
print_helper_msg
()
{
std
::
cout
// clang-format off
<<
"arg1: tensor operation (
grouped_conv_fwd: Grouped Convolution Forward
)
\n
"
<<
"arg1: tensor operation (
"
OP_NAME
": "
OP_DESC
"
)
\n
"
<<
"arg2: data type (0: Input fp32, Weight fp32, Output fp32
\n
"
<<
" 1: Input fp16, Weight fp16, Output fp16
\n
"
<<
" 2: Input bf16, Weight bf16, Output bf16
\n
"
...
...
@@ -252,3 +256,5 @@ int profile_grouped_conv_fwd(int argc, char* argv[])
return
1
;
}
REGISTER_PROFILER_OPERATION
(
OP_NAME
,
OP_DESC
,
profile_grouped_conv_fwd
);
profiler/src/profile_grouped_gemm.cpp
View file @
289f15de
...
...
@@ -6,7 +6,8 @@
#include <initializer_list>
#include <cstdlib>
#include "profiler/include/profile_grouped_gemm_impl.hpp"
#include "profiler/profile_grouped_gemm_impl.hpp"
#include "profiler_operation_registry.hpp"
enum
struct
GemmMatrixLayout
{
...
...
@@ -44,11 +45,14 @@ std::vector<int> argToIntArray(char* input)
return
out
;
}
#define OP_NAME "grouped_gemm"
#define OP_DESC "Grouped GEMM"
int
profile_grouped_gemm
(
int
argc
,
char
*
argv
[])
{
if
(
!
(
argc
==
14
))
{
printf
(
"arg1: tensor operation (
grouped_gemm: Grouped GEMM
)
\n
"
);
printf
(
"arg1: tensor operation (
"
OP_NAME
": "
OP_DESC
"
)
\n
"
);
printf
(
"arg2: data type (0: fp32; 1: fp16; 2: bf16; 3: int8)
\n
"
);
printf
(
"arg3: matrix layout (0: A[m, k] * B[k, n] = C[m, n];
\n
"
);
printf
(
" 1: A[m, k] * B[n, k] = C[m, n];
\n
"
);
...
...
@@ -161,3 +165,5 @@ int profile_grouped_gemm(int argc, char* argv[])
return
0
;
}
REGISTER_PROFILER_OPERATION
(
OP_NAME
,
OP_DESC
,
profile_grouped_gemm
);
profiler/src/profile_groupnorm.cpp
View file @
289f15de
...
...
@@ -5,8 +5,9 @@
#include <vector>
#include <unordered_map>
#include "profiler/include/data_type_enum.hpp"
#include "profiler/include/profile_groupnorm_impl.hpp"
#include "profiler/data_type_enum.hpp"
#include "profiler/profile_groupnorm_impl.hpp"
#include "profiler_operation_registry.hpp"
using
ck
::
index_t
;
...
...
@@ -43,9 +44,12 @@ struct GroupnormArgParser
}
};
#define OP_NAME "groupnorm"
#define OP_DESC "Group Normalization"
void
print_help_groupnorm
()
{
std
::
cout
<<
"arg1: tensor operation (
groupnorm: Group normalization
)
\n
"
std
::
cout
<<
"arg1: tensor operation (
"
OP_NAME
": "
OP_DESC
"
)
\n
"
<<
"arg2: data type (0: fp16; 1: fp32)
\n
"
<<
"arg3: verification (0: no; 1: yes)
\n
"
<<
"arg4: initialization (0: no init; 1: integer value; 2: decimal value)
\n
"
...
...
@@ -104,3 +108,5 @@ int profile_groupnorm(int argc, char* argv[])
return
0
;
}
REGISTER_PROFILER_OPERATION
(
OP_NAME
,
OP_DESC
,
profile_groupnorm
);
profiler/src/profile_layernorm.cpp
View file @
289f15de
...
...
@@ -5,8 +5,9 @@
#include <vector>
#include <unordered_map>
#include "profiler/include/data_type_enum.hpp"
#include "profiler/include/profile_layernorm_impl.hpp"
#include "profiler/data_type_enum.hpp"
#include "profiler/profile_layernorm_impl.hpp"
#include "profiler_operation_registry.hpp"
using
ck
::
index_t
;
...
...
@@ -96,3 +97,5 @@ int profile_layernorm(int argc, char* argv[])
return
0
;
}
REGISTER_PROFILER_OPERATION
(
"layernorm"
,
"Layer Normalization"
,
profile_layernorm
);
profiler/src/profile_reduce.cpp
View file @
289f15de
...
...
@@ -13,8 +13,9 @@
#include "ck/library/utility/host_common_util.hpp"
#include "profiler/include/profile_reduce_impl.hpp"
#include "profiler/include/data_type_enum.hpp"
#include "profiler/profile_reduce_impl.hpp"
#include "profiler/data_type_enum.hpp"
#include "profiler_operation_registry.hpp"
using
namespace
std
;
...
...
@@ -429,3 +430,5 @@ int profile_reduce(int argc, char* argv[])
return
(
0
);
};
REGISTER_PROFILER_OPERATION
(
"reduce"
,
"Reduce"
,
profile_reduce
);
profiler/src/profile_softmax.cpp
View file @
289f15de
...
...
@@ -5,7 +5,8 @@
#include <vector>
#include <unordered_map>
#include "profiler/include/profile_softmax_impl.hpp"
#include "profiler/profile_softmax_impl.hpp"
#include "profiler_operation_registry.hpp"
using
ck
::
index_t
;
using
ck
::
profiler
::
SoftmaxDataType
;
...
...
@@ -164,3 +165,5 @@ int profile_softmax(int argc, char* argv[])
// profile_normalization(argc, argv);
// return 0;
// }
REGISTER_PROFILER_OPERATION
(
"softmax"
,
"Softmax"
,
profile_softmax
);
profiler/src/profiler.cpp
View file @
289f15de
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <cstring>
#include <cstdlib>
#include <iostream>
int
profile_gemm
(
int
,
char
*
[]);
int
profile_gemm_splitk
(
int
,
char
*
[]);
int
profile_gemm_bilinear
(
int
,
char
*
[]);
int
profile_gemm_add_add_fastgelu
(
int
,
char
*
[]);
int
profile_gemm_reduce
(
int
,
char
*
[]);
int
profile_gemm_bias_add_reduce
(
int
,
char
*
[]);
int
profile_batched_gemm
(
int
,
char
*
[]);
int
profile_batched_gemm_gemm
(
int
,
char
*
[]);
int
profile_batched_gemm_add_relu_gemm_add
(
int
,
char
*
[]);
int
profile_batched_gemm_reduce
(
int
,
char
*
[]);
int
profile_grouped_gemm
(
int
,
char
*
[]);
int
profile_conv_fwd
(
int
,
char
*
[]);
int
profile_conv_fwd_bias_relu
(
int
,
char
*
[]);
int
profile_conv_fwd_bias_relu_add
(
int
,
char
*
[]);
int
profile_conv_bwd_data
(
int
,
char
*
[]);
int
profile_conv_bwd_weight
(
int
,
char
*
[]);
int
profile_grouped_conv_fwd
(
int
,
char
*
[]);
int
profile_softmax
(
int
,
char
*
[]);
int
profile_layernorm
(
int
,
char
*
[]);
int
profile_groupnorm
(
int
,
char
*
[]);
int
profile_reduce
(
int
,
char
*
[]);
#include "profiler_operation_registry.hpp"
static
void
print_helper_message
()
{
// clang-format off
printf
(
"arg1: tensor operation (gemm: GEMM
\n
"
" gemm_splitk: Split-K GEMM
\n
"
" gemm_bilinear: GEMM+Bilinear
\n
"
" gemm_add_add_fastgelu: GEMM+Add+Add+FastGeLU
\n
"
" gemm_reduce: GEMM+Reduce
\n
"
" gemm_bias_add_reduce: GEMM+Bias+Add+Reduce
\n
"
" batched_gemm: Batched GEMM
\n
"
" batched_gemm_gemm: Batched+GEMM+GEMM
\n
"
" batched_gemm_add_relu_gemm_add: Batched+GEMM+bias+gelu+GEMM+bias
\n
"
" batched_gemm_reduce: Batched GEMM+Reduce
\n
"
" grouped_gemm: Grouped GEMM
\n
"
" conv_fwd: Convolution Forward
\n
"
" conv_fwd_bias_relu: ForwardConvolution+Bias+ReLU
\n
"
" conv_fwd_bias_relu_add: ForwardConvolution+Bias+ReLU+Add
\n
"
" conv_bwd_data: Convolution Backward Data
\n
"
" conv_bwd_weight: Convolution Backward Weight
\n
"
" grouped_conv_fwd: Grouped Convolution Forward
\n
"
" softmax: Softmax
\n
"
" reduce: Reduce
\n
"
);
// clang-format on
std
::
cout
<<
"arg1: tensor operation "
<<
ProfilerOperationRegistry
::
GetInstance
()
<<
std
::
endl
;
}
int
main
(
int
argc
,
char
*
argv
[])
...
...
@@ -55,97 +16,15 @@ int main(int argc, char* argv[])
if
(
argc
==
1
)
{
print_helper_message
();
return
0
;
}
else
if
(
strcmp
(
argv
[
1
],
"gemm"
)
==
0
)
{
return
profile_gemm
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"gemm_splitk"
)
==
0
)
{
return
profile_gemm_splitk
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"gemm_bilinear"
)
==
0
)
{
return
profile_gemm_bilinear
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"gemm_add_add_fastgelu"
)
==
0
)
{
return
profile_gemm_add_add_fastgelu
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"gemm_reduce"
)
==
0
)
{
return
profile_gemm_reduce
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"gemm_bias_add_reduce"
)
==
0
)
else
if
(
const
auto
operation
=
ProfilerOperationRegistry
::
GetInstance
().
Get
(
argv
[
1
]);
operation
.
has_value
())
{
return
profile_gemm_bias_add_reduce
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"batched_gemm"
)
==
0
)
{
return
profile_batched_gemm
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"batched_gemm_gemm"
)
==
0
)
{
return
profile_batched_gemm_gemm
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"batched_gemm_add_relu_gemm_add"
)
==
0
)
{
return
profile_batched_gemm_add_relu_gemm_add
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"batched_gemm_reduce"
)
==
0
)
{
return
profile_batched_gemm_reduce
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"grouped_gemm"
)
==
0
)
{
return
profile_grouped_gemm
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"conv_fwd"
)
==
0
)
{
return
profile_conv_fwd
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"conv_fwd_bias_relu"
)
==
0
)
{
return
profile_conv_fwd_bias_relu
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"conv_fwd_bias_relu_add"
)
==
0
)
{
return
profile_conv_fwd_bias_relu_add
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"conv_bwd_data"
)
==
0
)
{
return
profile_conv_bwd_data
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"conv_bwd_weight"
)
==
0
)
{
return
profile_conv_bwd_weight
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"grouped_conv_fwd"
)
==
0
)
{
return
profile_grouped_conv_fwd
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"reduce"
)
==
0
)
{
return
profile_reduce
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"softmax"
)
==
0
)
{
return
profile_softmax
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"layernorm"
)
==
0
)
{
return
profile_layernorm
(
argc
,
argv
);
}
else
if
(
strcmp
(
argv
[
1
],
"groupnorm"
)
==
0
)
{
return
profile_groupnorm
(
argc
,
argv
);
return
(
*
operation
)(
argc
,
argv
);
}
else
{
print_helper_message
();
return
0
;
std
::
cerr
<<
"cannot find operation: "
<<
argv
[
1
]
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
}
profiler/src/profiler_operation_registry.hpp
0 → 100644
View file @
289f15de
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <optional>
#include <string_view>
#include <utility>
class
ProfilerOperationRegistry
final
{
ProfilerOperationRegistry
()
=
default
;
~
ProfilerOperationRegistry
()
=
default
;
public:
using
Operation
=
std
::
function
<
int
(
int
,
char
*
[])
>
;
private:
struct
Entry
final
{
explicit
Entry
(
std
::
string_view
description
,
Operation
operation
)
noexcept
:
description_
(
description
),
operation_
(
std
::
move
(
operation
))
{
}
std
::
string_view
description_
;
Operation
operation_
;
};
std
::
map
<
std
::
string_view
,
Entry
>
entries_
;
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
stream
,
const
ProfilerOperationRegistry
&
registry
)
{
stream
<<
"{
\n
"
;
for
(
auto
&
[
name
,
entry
]
:
registry
.
entries_
)
{
stream
<<
"
\t
"
<<
name
<<
": "
<<
entry
.
description_
<<
"
\n
"
;
}
stream
<<
"}"
;
return
stream
;
}
public:
static
ProfilerOperationRegistry
&
GetInstance
()
{
static
ProfilerOperationRegistry
registry
;
return
registry
;
}
std
::
optional
<
Operation
>
Get
(
std
::
string_view
name
)
const
{
const
auto
found
=
entries_
.
find
(
name
);
if
(
found
==
end
(
entries_
))
{
return
std
::
nullopt
;
}
return
(
found
->
second
).
operation_
;
}
bool
Add
(
std
::
string_view
name
,
std
::
string_view
description
,
Operation
operation
)
{
return
entries_
.
emplace
(
std
::
piecewise_construct
,
std
::
forward_as_tuple
(
name
),
std
::
forward_as_tuple
(
description
,
std
::
move
(
operation
)))
.
second
;
}
};
#define PP_CONCAT(x, y) PP_CONCAT_IMPL(x, y)
#define PP_CONCAT_IMPL(x, y) x##y
#define REGISTER_PROFILER_OPERATION(name, description, operation) \
static const bool PP_CONCAT(operation_registration_result_, __COUNTER__) = \
::ProfilerOperationRegistry::GetInstance().Add(name, description, operation)
test/CMakeLists.txt
View file @
289f15de
include_directories
(
BEFORE
${
PROJECT_SOURCE_DIR
}
/
${
PROJECT_SOURCE_DIR
}
/profiler/include
)
include
(
googletest
)
...
...
@@ -45,14 +46,15 @@ add_subdirectory(batched_gemm_softmax_gemm_permute)
add_subdirectory
(
grouped_gemm
)
add_subdirectory
(
reduce
)
add_subdirectory
(
convnd_fwd
)
add_subdirectory
(
convnd_bwd_weight
)
add_subdirectory
(
convnd_bwd_data
)
add_subdirectory
(
grouped_convnd_fwd
)
add_subdirectory
(
grouped_convnd_bwd_weight
)
add_subdirectory
(
block_to_ctile_map
)
add_subdirectory
(
softmax
)
add_subdirectory
(
normalization
)
add_subdirectory
(
data_type
)
add_subdirectory
(
elementwise_normalization
)
add_subdirectory
(
batchnorm
)
if
(
GPU_TARGETS MATCHES
"gfx1100"
)
add_subdirectory
(
wmma_op
)
endif
()
\ No newline at end of file
endif
()
test/batched_gemm/batched_gemm_bf16.cpp
View file @
289f15de
...
...
@@ -3,7 +3,7 @@
#include <iostream>
#include "profiler/
include/
profile_batched_gemm_impl.hpp"
#include "profiler/profile_batched_gemm_impl.hpp"
namespace
{
using
ADataType
=
ck
::
bhalf_t
;
...
...
test/batched_gemm/batched_gemm_fp16.cpp
View file @
289f15de
...
...
@@ -3,7 +3,7 @@
#include <iostream>
#include "profiler/
include/
profile_batched_gemm_impl.hpp"
#include "profiler/profile_batched_gemm_impl.hpp"
namespace
{
using
ADataType
=
ck
::
half_t
;
...
...
Prev
1
…
13
14
15
16
17
18
19
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment