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
b43ac5ef
Commit
b43ac5ef
authored
Sep 28, 2023
by
Jing Zhang
Browse files
merge conflict
parents
b892a14a
bc1108bb
Changes
139
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
1093 additions
and
339 deletions
+1093
-339
profiler/include/profiler/profile_conv_tensor_rearrange_impl.hpp
...r/include/profiler/profile_conv_tensor_rearrange_impl.hpp
+109
-31
profiler/include/profiler/profile_gemm_impl.hpp
profiler/include/profiler/profile_gemm_impl.hpp
+6
-0
profiler/src/CMakeLists.txt
profiler/src/CMakeLists.txt
+2
-1
profiler/src/profile_conv_tensor_rearrange.cpp
profiler/src/profile_conv_tensor_rearrange.cpp
+251
-0
profiler/src/profile_gemm.cpp
profiler/src/profile_gemm.cpp
+23
-1
test/CMakeLists.txt
test/CMakeLists.txt
+1
-1
test/batchnorm/batchnorm_bwd_rank_4.cpp
test/batchnorm/batchnorm_bwd_rank_4.cpp
+17
-4
test/batchnorm/batchnorm_fwd_rank_4.cpp
test/batchnorm/batchnorm_fwd_rank_4.cpp
+17
-4
test/batchnorm/batchnorm_infer_rank_4.cpp
test/batchnorm/batchnorm_infer_rank_4.cpp
+17
-4
test/conv_tensor_rearrange/CMakeLists.txt
test/conv_tensor_rearrange/CMakeLists.txt
+4
-0
test/conv_tensor_rearrange/test_conv_tensor_rearrange.cpp
test/conv_tensor_rearrange/test_conv_tensor_rearrange.cpp
+153
-0
test/conv_tensor_rearrange/test_conv_tensor_rearrange_interface.cpp
...tensor_rearrange/test_conv_tensor_rearrange_interface.cpp
+260
-0
test/data_type/CMakeLists.txt
test/data_type/CMakeLists.txt
+2
-0
test/data_type/type_convert_const.cpp
test/data_type/type_convert_const.cpp
+93
-0
test/gemm_split_k/test_gemm_splitk_ut_cases.inc
test/gemm_split_k/test_gemm_splitk_ut_cases.inc
+4
-4
test/grouped_convnd_fwd/CMakeLists.txt
test/grouped_convnd_fwd/CMakeLists.txt
+1
-1
test/grouped_convnd_fwd/grouped_convnd_fwd.cpp
test/grouped_convnd_fwd/grouped_convnd_fwd.cpp
+0
-284
test/grouped_convnd_fwd/test_grouped_convnd_fwd.cpp
test/grouped_convnd_fwd/test_grouped_convnd_fwd.cpp
+133
-0
test/image_to_column/CMakeLists.txt
test/image_to_column/CMakeLists.txt
+0
-4
No files found.
profiler/include/profiler/profile_
image_to_column
_impl.hpp
→
profiler/include/profiler/profile_
conv_tensor_rearrange
_impl.hpp
View file @
b43ac5ef
...
...
@@ -9,9 +9,11 @@
#include <limits>
#include "ck/ck.hpp"
#include "ck/tensor_operation/gpu/device/tensor_layout.hpp"
#include "ck/tensor_operation/gpu/device/device_image_to_column.hpp"
#include "ck/tensor_operation/gpu/device/device_conv_tensor_rearrange.hpp"
#include "ck/tensor_operation/gpu/device/conv_tensor_rearrange_op.hpp"
#include "ck/tensor_operation/gpu/device/impl/device_image_to_column_impl.hpp"
#include "ck/library/tensor_operation_instance/gpu/image_to_column.hpp"
#include "ck/tensor_operation/gpu/device/impl/device_column_to_image_impl.hpp"
#include "ck/library/tensor_operation_instance/gpu/conv_tensor_rearrange.hpp"
#include "ck/library/utility/check_err.hpp"
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/host_tensor.hpp"
...
...
@@ -19,22 +21,88 @@
#include "ck/library/utility/convolution_parameter.hpp"
#include "ck/library/utility/convolution_host_tensor_descriptor_helper.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_image_to_column.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_column_to_image.hpp"
namespace
ck
{
namespace
profiler
{
template
<
ck
::
index_t
...
Is
>
using
S
=
ck
::
Sequence
<
Is
...
>
;
using
namespace
conv_tensor_rearrange_op
;
template
<
typename
InputDataType
,
typename
ConvTensorRearrangeOp
>
Tensor
<
InputDataType
>
create_input
(
const
HostTensorDescriptor
&
image_desc
,
const
HostTensorDescriptor
&
gemm_desc
)
{
if
constexpr
(
std
::
is_same_v
<
ConvTensorRearrangeOp
,
ImageToColumn
>
)
{
Tensor
<
InputDataType
>
input
(
image_desc
);
return
input
;
}
else
if
constexpr
(
std
::
is_same_v
<
ConvTensorRearrangeOp
,
ColumnToImage
>
)
{
Tensor
<
InputDataType
>
input
(
gemm_desc
);
return
input
;
}
else
{
throw
std
::
runtime_error
(
"Unsupported op!"
);
}
}
template
<
typename
OutputDataType
,
typename
ConvTensorRearrangeOp
>
Tensor
<
OutputDataType
>
create_output
(
const
HostTensorDescriptor
&
image_desc
,
const
HostTensorDescriptor
&
gemm_desc
)
{
if
constexpr
(
std
::
is_same_v
<
ConvTensorRearrangeOp
,
ImageToColumn
>
)
{
Tensor
<
OutputDataType
>
output
(
gemm_desc
);
return
output
;
}
else
if
constexpr
(
std
::
is_same_v
<
ConvTensorRearrangeOp
,
ColumnToImage
>
)
{
Tensor
<
OutputDataType
>
output
(
image_desc
);
return
output
;
}
else
{
throw
std
::
runtime_error
(
"Unsupported op!"
);
}
}
template
<
index_t
NDimSpatial
,
typename
InputLayout
,
typename
InputDataType
,
typename
OutputDataType
,
typename
ConvTensorRearrangeOp
>
static
auto
make_ref_op
()
{
if
constexpr
(
std
::
is_same_v
<
ConvTensorRearrangeOp
,
ImageToColumn
>
)
{
return
ck
::
tensor_operation
::
host
::
ReferenceImageToColumn
<
NDimSpatial
,
InputLayout
,
InputDataType
,
OutputDataType
>
{};
}
else
if
constexpr
(
std
::
is_same_v
<
ConvTensorRearrangeOp
,
ColumnToImage
>
)
{
return
ck
::
tensor_operation
::
host
::
ReferenceColumnToImage
<
NDimSpatial
,
InputLayout
,
InputDataType
,
OutputDataType
>
{};
}
else
{
throw
std
::
runtime_error
(
"Unsupported op!"
);
}
}
template
<
index_t
NDimSpatial
,
typename
InputLayout
,
typename
InputDataType
,
typename
OutputDataType
>
bool
profile_image_to_column_impl
(
int
do_verification
,
int
init_method
,
bool
do_log
,
bool
time_kernel
,
const
ck
::
utils
::
conv
::
ConvParam
&
conv_param
)
typename
OutputDataType
,
typename
ConvTensorRearrangeOp
>
bool
profile_conv_tensor_rearrange_impl
(
int
do_verification
,
int
init_method
,
bool
do_log
,
bool
time_kernel
,
const
ck
::
utils
::
conv
::
ConvParam
&
conv_param
)
{
const
ck
::
index_t
NDoHoWo
=
conv_param
.
N_
*
...
...
@@ -45,16 +113,16 @@ bool profile_image_to_column_impl(int do_verification,
ck
::
accumulate_n
<
ck
::
index_t
>
(
conv_param
.
filter_spatial_lengths_
.
begin
(),
NDimSpatial
,
1
,
std
::
multiplies
<>
());
const
auto
i
n
_desc
=
const
auto
i
mage
_desc
=
ck
::
utils
::
conv
::
make_input_host_tensor_descriptor_g_n_c_wis_packed
<
InputLayout
>
(
conv_param
);
const
auto
out
_desc
=
HostTensorDescriptor
({
NDoHoWo
,
CZYX
});
const
auto
gemm
_desc
=
HostTensorDescriptor
({
NDoHoWo
,
CZYX
});
std
::
array
<
ck
::
index_t
,
NDimSpatial
>
input_spatial_lengths
{};
std
::
array
<
ck
::
index_t
,
NDimSpatial
>
filter_spatial_lengths
{};
std
::
array
<
ck
::
index_t
,
NDimSpatial
>
output_spatial_lengths
{};
std
::
array
<
ck
::
index_t
,
NDimSpatial
+
3
>
i
nput
_g_n_c_wis_strides
{};
std
::
array
<
ck
::
index_t
,
2
>
output
_m_k_strides
{};
std
::
array
<
ck
::
index_t
,
NDimSpatial
+
3
>
i
mage
_g_n_c_wis_strides
{};
std
::
array
<
ck
::
index_t
,
2
>
gemm
_m_k_strides
{};
std
::
array
<
ck
::
index_t
,
NDimSpatial
>
conv_filter_strides
{};
std
::
array
<
ck
::
index_t
,
NDimSpatial
>
conv_filter_dilations
{};
std
::
array
<
ck
::
index_t
,
NDimSpatial
>
input_left_pads
{};
...
...
@@ -65,16 +133,19 @@ bool profile_image_to_column_impl(int do_verification,
copy
(
conv_param
.
input_spatial_lengths_
,
input_spatial_lengths
);
copy
(
conv_param
.
filter_spatial_lengths_
,
filter_spatial_lengths
);
copy
(
conv_param
.
output_spatial_lengths_
,
output_spatial_lengths
);
copy
(
i
n
_desc
.
GetStrides
(),
i
nput
_g_n_c_wis_strides
);
copy
(
out
_desc
.
GetStrides
(),
output
_m_k_strides
);
copy
(
i
mage
_desc
.
GetStrides
(),
i
mage
_g_n_c_wis_strides
);
copy
(
gemm
_desc
.
GetStrides
(),
gemm
_m_k_strides
);
copy
(
conv_param
.
conv_filter_strides_
,
conv_filter_strides
);
copy
(
conv_param
.
conv_filter_dilations_
,
conv_filter_dilations
);
copy
(
conv_param
.
input_left_pads_
,
input_left_pads
);
copy
(
conv_param
.
input_right_pads_
,
input_right_pads
);
Tensor
<
InputDataType
>
input
(
in_desc
);
Tensor
<
OutputDataType
>
host_output
(
out_desc
);
Tensor
<
OutputDataType
>
device_output
(
out_desc
);
Tensor
<
InputDataType
>
input
=
create_input
<
InputDataType
,
ConvTensorRearrangeOp
>
(
image_desc
,
gemm_desc
);
Tensor
<
OutputDataType
>
device_output
=
create_output
<
OutputDataType
,
ConvTensorRearrangeOp
>
(
image_desc
,
gemm_desc
);
Tensor
<
OutputDataType
>
host_output
=
create_output
<
OutputDataType
,
ConvTensorRearrangeOp
>
(
image_desc
,
gemm_desc
);
std
::
cout
<<
"input: "
<<
input
.
mDesc
<<
std
::
endl
;
std
::
cout
<<
"output: "
<<
host_output
.
mDesc
<<
std
::
endl
;
...
...
@@ -94,17 +165,21 @@ bool profile_image_to_column_impl(int do_verification,
// run reference op
if
(
do_verification
)
{
auto
ref_image_to_column
=
ck
::
tensor_operation
::
host
::
ReferenceImageToColumn
<
NDimSpatial
,
InputLayout
,
InputDataType
,
OutputDataType
>
{};
auto
ref_conv_tensor_rearrange
=
make_ref_op
<
NDimSpatial
,
InputLayout
,
InputDataType
,
OutputDataType
,
ConvTensorRearrangeOp
>
();
auto
ref_invoker
=
ref_image_to_column
.
MakeInvoker
();
auto
ref_argument
=
ref_image_to_column
.
MakeArgument
(
input
,
host_output
,
conv_param
.
filter_spatial_lengths_
,
conv_param
.
conv_filter_strides_
,
conv_param
.
conv_filter_dilations_
,
conv_param
.
input_left_pads_
,
conv_param
.
input_right_pads_
);
auto
ref_invoker
=
ref_conv_tensor_rearrange
.
MakeInvoker
();
auto
ref_argument
=
ref_conv_tensor_rearrange
.
MakeArgument
(
input
,
host_output
,
conv_param
.
filter_spatial_lengths_
,
conv_param
.
conv_filter_strides_
,
conv_param
.
conv_filter_dilations_
,
conv_param
.
input_left_pads_
,
conv_param
.
input_right_pads_
);
// init host output to zero
host_output
.
SetZero
();
...
...
@@ -112,8 +187,11 @@ bool profile_image_to_column_impl(int do_verification,
ref_invoker
.
Run
(
ref_argument
);
}
using
DeviceOp
=
ck
::
tensor_operation
::
device
::
DeviceImageToColumn
<
NDimSpatial
,
InputLayout
,
InputDataType
,
OutputDataType
>
;
using
DeviceOp
=
ck
::
tensor_operation
::
device
::
DeviceConvTensorRearrange
<
NDimSpatial
,
InputLayout
,
InputDataType
,
OutputDataType
,
ConvTensorRearrangeOp
>
;
// get device op instances
const
auto
op_ptrs
=
ck
::
tensor_operation
::
device
::
instance
::
DeviceOperationInstanceFactory
<
...
...
@@ -139,8 +217,8 @@ bool profile_image_to_column_impl(int do_verification,
input_spatial_lengths
,
filter_spatial_lengths
,
output_spatial_lengths
,
i
nput
_g_n_c_wis_strides
,
output
_m_k_strides
,
i
mage
_g_n_c_wis_strides
,
gemm
_m_k_strides
,
conv_filter_strides
,
conv_filter_dilations
,
input_left_pads
,
...
...
profiler/include/profiler/profile_gemm_impl.hpp
View file @
b43ac5ef
...
...
@@ -223,6 +223,12 @@ int profile_gemm_impl(int do_verification,
{
std
::
cout
<<
"Best Perf for datatype = int8"
;
}
#if defined CK_ENABLE_FP8
else
if
constexpr
(
is_same
<
CDataType
,
f8_t
>::
value
)
{
std
::
cout
<<
"Best Perf for datatype = fp8"
;
}
#endif
if
constexpr
(
is_same
<
ALayout
,
tensor_layout
::
gemm
::
RowMajor
>::
value
)
{
...
...
profiler/src/CMakeLists.txt
View file @
b43ac5ef
...
...
@@ -28,7 +28,7 @@ set(PROFILER_SOURCES
profile_contraction_bilinear.cpp
profile_contraction_scale.cpp
profile_grouped_conv_bwd_data.cpp
profile_
image_to_column
.cpp
profile_
conv_tensor_rearrange
.cpp
)
if
(
DL_KERNELS
)
list
(
APPEND PROFILER_SOURCES profile_batched_gemm_multi_d.cpp
)
...
...
@@ -84,6 +84,7 @@ target_link_libraries(${PROFILER_EXECUTABLE} PRIVATE device_max_pool_bwd_instanc
target_link_libraries
(
${
PROFILER_EXECUTABLE
}
PRIVATE device_grouped_conv2d_bwd_data_instance
)
target_link_libraries
(
${
PROFILER_EXECUTABLE
}
PRIVATE device_grouped_conv3d_bwd_data_instance
)
target_link_libraries
(
${
PROFILER_EXECUTABLE
}
PRIVATE device_image_to_column_instance
)
target_link_libraries
(
${
PROFILER_EXECUTABLE
}
PRIVATE device_column_to_image_instance
)
if
(
DL_KERNELS
)
target_link_libraries
(
${
PROFILER_EXECUTABLE
}
PRIVATE device_batched_gemm_multi_d_instance
)
endif
()
...
...
profiler/src/profile_
image_to_column
.cpp
→
profiler/src/profile_
conv_tensor_rearrange
.cpp
View file @
b43ac5ef
// SPDX-License-Identifier: MIT
// Copyright (c)
2018-
2023, Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2023, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <numeric>
#include <initializer_list>
#include <cstdlib>
#include "profiler/profile_
image_to_column
_impl.hpp"
#include "profiler/profile_
conv_tensor_rearrange
_impl.hpp"
#include "profiler_operation_registry.hpp"
namespace
{
enum
struct
RearrangeOp
{
ImageToColumn
,
// 0
ColumnToImage
,
// 1
};
enum
struct
ConvLayout
{
NHWC
,
// 0
...
...
@@ -24,8 +30,8 @@ enum struct DataType
INT8_INT8
,
// 3
};
#define OP_NAME "
image_to_column
"
#define OP_DESC "
Image To Column
"
#define OP_NAME "
conv_tensor_rearrange
"
#define OP_DESC "
Conv Tensor Rearrange
"
static
void
print_helper_msg
()
{
...
...
@@ -41,16 +47,17 @@ static void print_helper_msg()
<<
"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
"
<<
"arg8: operation type (0: ImageToColumn, 1: ColumnToImage)
\n
"
<<
ck
::
utils
::
conv
::
get_conv_param_parser_helper_msg
()
<<
std
::
endl
;
// clang-format on
}
}
// namespace
int
profile_
image_to_column
(
int
argc
,
char
*
argv
[])
int
profile_
conv_tensor_rearrange
(
int
argc
,
char
*
argv
[])
{
//
8
for control, 1 for num_dim_spatial
if
(
argc
<
9
)
//
9
for control, 1 for num_dim_spatial
if
(
argc
<
10
)
{
print_helper_msg
();
return
1
;
...
...
@@ -62,16 +69,17 @@ int profile_image_to_column(int argc, char* argv[])
const
int
init_method
=
std
::
stoi
(
argv
[
5
]);
const
bool
do_log
=
std
::
stoi
(
argv
[
6
]);
const
bool
time_kernel
=
std
::
stoi
(
argv
[
7
]);
const
int
num_dim_spatial
=
std
::
stoi
(
argv
[
8
]);
const
auto
rearrange_op
=
static_cast
<
RearrangeOp
>
(
std
::
stoi
(
argv
[
8
]));
const
int
num_dim_spatial
=
std
::
stoi
(
argv
[
9
]);
//
8
for control, 1 for num_dim_spatial, 4 for G/N/K/C, and 6 * num_dim_spatial
if
(
argc
!=
8
+
1
+
4
+
6
*
num_dim_spatial
)
//
9
for control, 1 for num_dim_spatial, 4 for G/N/K/C, and 6 * num_dim_spatial
if
(
argc
!=
9
+
1
+
4
+
6
*
num_dim_spatial
)
{
print_helper_msg
();
return
1
;
}
const
auto
params
=
ck
::
utils
::
conv
::
parse_conv_param
(
num_dim_spatial
,
9
,
argv
);
const
auto
params
=
ck
::
utils
::
conv
::
parse_conv_param
(
num_dim_spatial
,
10
,
argv
);
using
F32
=
float
;
using
F16
=
ck
::
half_t
;
...
...
@@ -79,12 +87,17 @@ int profile_image_to_column(int argc, char* argv[])
using
INT8
=
int8_t
;
using
namespace
ck
::
tensor_layout
::
convolution
;
using
namespace
ck
::
conv_tensor_rearrange_op
;
constexpr
auto
I1
=
ck
::
Number
<
1
>
{};
constexpr
auto
I2
=
ck
::
Number
<
2
>
{};
constexpr
auto
I3
=
ck
::
Number
<
3
>
{};
auto
profile
=
[
&
](
auto
num_dim_spatial_tmp
,
auto
in_layout
,
auto
in_type
,
auto
out_type
)
{
auto
profile
=
[
&
](
auto
num_dim_spatial_tmp
,
auto
in_layout
,
auto
in_type
,
auto
out_type
,
auto
rearrange_op_type
)
{
constexpr
ck
::
index_t
NDimSpatial
=
num_dim_spatial_tmp
.
value
;
using
InLayout
=
decltype
(
in_layout
);
...
...
@@ -92,78 +105,147 @@ int profile_image_to_column(int argc, char* argv[])
using
InDataType
=
decltype
(
in_type
);
using
OutDataType
=
decltype
(
out_type
);
using
Op
=
decltype
(
rearrange_op_type
);
bool
pass
=
ck
::
profiler
::
profile_
image_to_column
_impl
<
NDimSpatial
,
InLayout
,
InDataType
,
OutDataType
>
(
profile_
conv_tensor_rearrange
_impl
<
NDimSpatial
,
InLayout
,
InDataType
,
OutDataType
,
Op
>
(
do_verification
,
init_method
,
do_log
,
time_kernel
,
params
);
return
pass
?
0
:
1
;
};
//
NHWC
if
(
layout
==
ConvLayout
::
NHWC
)
//
Image To Column
if
(
rearrange_op
==
RearrangeOp
::
ImageToColumn
)
{
if
(
num_dim_spatial
==
1
)
// NHWC
if
(
layout
==
ConvLayout
::
NHWC
)
{
if
(
data_type
==
DataType
::
F32_F32
)
{
return
profile
(
I1
,
GNWC
{},
F32
{},
F32
{});
}
else
if
(
data_type
==
DataType
::
F16_F16
)
if
(
num_dim_spatial
==
1
)
{
return
profile
(
I1
,
GNWC
{},
F16
{},
F16
{});
if
(
data_type
==
DataType
::
F32_F32
)
{
return
profile
(
I1
,
GNWC
{},
F32
{},
F32
{},
ImageToColumn
{});
}
else
if
(
data_type
==
DataType
::
F16_F16
)
{
return
profile
(
I1
,
GNWC
{},
F16
{},
F16
{},
ImageToColumn
{});
}
else
if
(
data_type
==
DataType
::
BF16_BF16
)
{
return
profile
(
I1
,
GNWC
{},
BF16
{},
BF16
{},
ImageToColumn
{});
}
else
if
(
data_type
==
DataType
::
INT8_INT8
)
{
return
profile
(
I1
,
GNWC
{},
INT8
{},
INT8
{},
ImageToColumn
{});
}
}
else
if
(
data_type
==
DataType
::
BF16_BF16
)
else
if
(
num_dim_spatial
==
2
)
{
return
profile
(
I1
,
GNWC
{},
BF16
{},
BF16
{});
if
(
data_type
==
DataType
::
F32_F32
)
{
return
profile
(
I2
,
GNHWC
{},
F32
{},
F32
{},
ImageToColumn
{});
}
else
if
(
data_type
==
DataType
::
F16_F16
)
{
return
profile
(
I2
,
GNHWC
{},
F16
{},
F16
{},
ImageToColumn
{});
}
else
if
(
data_type
==
DataType
::
BF16_BF16
)
{
return
profile
(
I2
,
GNHWC
{},
BF16
{},
BF16
{},
ImageToColumn
{});
}
else
if
(
data_type
==
DataType
::
INT8_INT8
)
{
return
profile
(
I2
,
GNHWC
{},
INT8
{},
INT8
{},
ImageToColumn
{});
}
}
else
if
(
data_type
==
DataType
::
INT8_INT8
)
else
if
(
num_dim_spatial
==
3
)
{
return
profile
(
I1
,
GNWC
{},
INT8
{},
INT8
{});
if
(
data_type
==
DataType
::
F32_F32
)
{
return
profile
(
I3
,
GNDHWC
{},
F32
{},
F32
{},
ImageToColumn
{});
}
else
if
(
data_type
==
DataType
::
F16_F16
)
{
return
profile
(
I3
,
GNDHWC
{},
F16
{},
F16
{},
ImageToColumn
{});
}
else
if
(
data_type
==
DataType
::
BF16_BF16
)
{
return
profile
(
I3
,
GNDHWC
{},
BF16
{},
BF16
{},
ImageToColumn
{});
}
else
if
(
data_type
==
DataType
::
INT8_INT8
)
{
return
profile
(
I3
,
GNDHWC
{},
INT8
{},
INT8
{},
ImageToColumn
{});
}
}
}
else
if
(
num_dim_spatial
==
2
)
{
if
(
data_type
==
DataType
::
F32_F32
)
{
return
profile
(
I2
,
GNHWC
{},
F32
{},
F32
{});
}
else
if
(
data_type
==
DataType
::
F16_F16
)
{
return
profile
(
I2
,
GNHWC
{},
F16
{},
F16
{});
}
else
if
(
data_type
==
DataType
::
BF16_BF16
)
{
return
profile
(
I2
,
GNHWC
{},
BF16
{},
BF16
{});
}
else
if
(
data_type
==
DataType
::
INT8_INT8
)
{
return
profile
(
I2
,
GNHWC
{},
INT8
{},
INT8
{});
}
}
else
if
(
num_dim_spatial
==
3
)
}
else
if
(
rearrange_op
==
RearrangeOp
::
ColumnToImage
)
{
// NHWC
if
(
layout
==
ConvLayout
::
NHWC
)
{
if
(
data_type
==
DataType
::
F32_F32
)
if
(
num_dim_spatial
==
1
)
{
return
profile
(
I3
,
GNDHWC
{},
F32
{},
F32
{});
if
(
data_type
==
DataType
::
F32_F32
)
{
return
profile
(
I1
,
GNWC
{},
F32
{},
F32
{},
ColumnToImage
{});
}
else
if
(
data_type
==
DataType
::
F16_F16
)
{
return
profile
(
I1
,
GNWC
{},
F16
{},
F16
{},
ColumnToImage
{});
}
else
if
(
data_type
==
DataType
::
BF16_BF16
)
{
return
profile
(
I1
,
GNWC
{},
BF16
{},
BF16
{},
ColumnToImage
{});
}
else
if
(
data_type
==
DataType
::
INT8_INT8
)
{
return
profile
(
I1
,
GNWC
{},
INT8
{},
INT8
{},
ColumnToImage
{});
}
}
else
if
(
data_type
==
DataType
::
F16_F16
)
else
if
(
num_dim_spatial
==
2
)
{
return
profile
(
I3
,
GNDHWC
{},
F16
{},
F16
{});
if
(
data_type
==
DataType
::
F32_F32
)
{
return
profile
(
I2
,
GNHWC
{},
F32
{},
F32
{},
ColumnToImage
{});
}
else
if
(
data_type
==
DataType
::
F16_F16
)
{
return
profile
(
I2
,
GNHWC
{},
F16
{},
F16
{},
ColumnToImage
{});
}
else
if
(
data_type
==
DataType
::
BF16_BF16
)
{
return
profile
(
I2
,
GNHWC
{},
BF16
{},
BF16
{},
ColumnToImage
{});
}
else
if
(
data_type
==
DataType
::
INT8_INT8
)
{
return
profile
(
I2
,
GNHWC
{},
INT8
{},
INT8
{},
ColumnToImage
{});
}
}
else
if
(
data_type
==
DataType
::
BF16_BF16
)
else
if
(
num_dim_spatial
==
3
)
{
return
profile
(
I3
,
GNDHWC
{},
BF16
{},
BF16
{});
}
else
if
(
data_type
==
DataType
::
INT8_INT8
)
{
return
profile
(
I3
,
GNDHWC
{},
INT8
{},
INT8
{});
if
(
data_type
==
DataType
::
F32_F32
)
{
return
profile
(
I3
,
GNDHWC
{},
F32
{},
F32
{},
ColumnToImage
{});
}
else
if
(
data_type
==
DataType
::
F16_F16
)
{
return
profile
(
I3
,
GNDHWC
{},
F16
{},
F16
{},
ColumnToImage
{});
}
else
if
(
data_type
==
DataType
::
BF16_BF16
)
{
return
profile
(
I3
,
GNDHWC
{},
BF16
{},
BF16
{},
ColumnToImage
{});
}
else
if
(
data_type
==
DataType
::
INT8_INT8
)
{
return
profile
(
I3
,
GNDHWC
{},
INT8
{},
INT8
{},
ColumnToImage
{});
}
}
}
}
std
::
cout
<<
"this data_type & layout is not implemented"
<<
std
::
endl
;
return
1
;
}
REGISTER_PROFILER_OPERATION
(
OP_NAME
,
OP_DESC
,
profile_
image_to_column
);
REGISTER_PROFILER_OPERATION
(
OP_NAME
,
OP_DESC
,
profile_
conv_tensor_rearrange
);
profiler/src/profile_gemm.cpp
View file @
b43ac5ef
...
...
@@ -23,6 +23,7 @@ enum struct GemmDataType
F16_F16_F16
,
// 1
BF16_BF16_BF16
,
// 2
INT8_INT8_INT8
,
// 3
F8_F8_F8
,
// 4
};
#define OP_NAME "gemm"
...
...
@@ -31,7 +32,7 @@ enum struct GemmDataType
static
void
print_helper_msg
()
{
std
::
cout
<<
"arg1: tensor operation ("
OP_NAME
": "
OP_DESC
")
\n
"
<<
"arg2: data type (0: fp32; 1: fp16; 2: bf16; 3: int8)
\n
"
<<
"arg2: data type (0: fp32; 1: fp16; 2: bf16; 3: int8
; 4: fp8
)
\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
"
<<
" 2: A[k, m] * B[k, n] = C[m, n];
\n
"
...
...
@@ -76,6 +77,9 @@ int profile_gemm(int argc, char* argv[])
using
INT8
=
int8_t
;
using
INT32
=
int32_t
;
#endif
#ifdef CK_ENABLE_FP8
using
F8
=
ck
::
f8_t
;
#endif
using
Row
=
ck
::
tensor_layout
::
gemm
::
RowMajor
;
using
Col
=
ck
::
tensor_layout
::
gemm
::
ColumnMajor
;
...
...
@@ -194,6 +198,24 @@ int profile_gemm(int argc, char* argv[])
{
return
profile
(
Col
{},
Col
{},
Row
{},
INT8
{},
INT8
{},
INT32
{},
INT8
{});
}
#endif
#ifdef CK_ENABLE_FP8
else
if
(
data_type
==
GemmDataType
::
F8_F8_F8
&&
layout
==
GemmMatrixLayout
::
MK_KN_MN
)
{
return
profile
(
Row
{},
Row
{},
Row
{},
F8
{},
F8
{},
F32
{},
F8
{});
}
else
if
(
data_type
==
GemmDataType
::
F8_F8_F8
&&
layout
==
GemmMatrixLayout
::
MK_NK_MN
)
{
return
profile
(
Row
{},
Col
{},
Row
{},
F8
{},
F8
{},
F32
{},
F8
{});
}
else
if
(
data_type
==
GemmDataType
::
F8_F8_F8
&&
layout
==
GemmMatrixLayout
::
KM_KN_MN
)
{
return
profile
(
Col
{},
Row
{},
Row
{},
F8
{},
F8
{},
F32
{},
F8
{});
}
else
if
(
data_type
==
GemmDataType
::
F8_F8_F8
&&
layout
==
GemmMatrixLayout
::
KM_NK_MN
)
{
return
profile
(
Col
{},
Col
{},
Row
{},
F8
{},
F8
{},
F32
{},
F8
{});
}
#endif
else
{
...
...
test/CMakeLists.txt
View file @
b43ac5ef
...
...
@@ -155,7 +155,7 @@ add_subdirectory(contraction)
add_subdirectory
(
pool
)
add_subdirectory
(
batched_gemm_multi_d
)
add_subdirectory
(
grouped_convnd_bwd_data
)
add_subdirectory
(
image_to_column
)
add_subdirectory
(
conv_tensor_rearrange
)
if
(
GPU_TARGETS MATCHES
"gfx11"
)
add_subdirectory
(
wmma_op
)
endif
()
test/batchnorm/batchnorm_bwd_rank_4.cpp
View file @
b43ac5ef
...
...
@@ -70,10 +70,23 @@ class TestBatchNormBwdRank4 : public ::testing::Test
}
};
using
KernelTypes
=
::
testing
::
Types
<
std
::
tuple
<
F16
,
F32
,
F32
,
F32
,
F16
,
F32
,
F32
>
,
std
::
tuple
<
F32
,
F32
,
F32
,
F32
,
F32
,
F32
,
F32
>
,
std
::
tuple
<
BF16
,
F32
,
F32
,
F32
,
BF16
,
F32
,
F32
>
,
std
::
tuple
<
F64
,
F64
,
F64
,
F64
,
F64
,
F64
,
F64
>>
;
using
KernelTypes
=
::
testing
::
Types
<
#ifdef CK_ENABLE_FP16
std
::
tuple
<
F16
,
F32
,
F32
,
F32
,
F16
,
F32
,
F32
>
#endif
#ifdef CK_ENABLE_FP32
,
std
::
tuple
<
F32
,
F32
,
F32
,
F32
,
F32
,
F32
,
F32
>
#endif
#ifdef CK_ENABLE_BF16
,
std
::
tuple
<
BF16
,
F32
,
F32
,
F32
,
BF16
,
F32
,
F32
>
#endif
#ifdef CK_ENABLE_FP64
,
std
::
tuple
<
F64
,
F64
,
F64
,
F64
,
F64
,
F64
,
F64
>
#endif
>
;
TYPED_TEST_SUITE
(
TestBatchNormBwdRank4
,
KernelTypes
);
...
...
test/batchnorm/batchnorm_fwd_rank_4.cpp
View file @
b43ac5ef
...
...
@@ -87,10 +87,23 @@ class TestBatchNormFwdRank4 : public ::testing::Test
}
};
using
KernelTypes
=
::
testing
::
Types
<
std
::
tuple
<
F16
,
F16
,
F32
,
F16
,
F16
,
F32
>
,
std
::
tuple
<
F32
,
F32
,
F32
,
F32
,
F32
,
F32
>
,
std
::
tuple
<
BF16
,
BF16
,
F32
,
BF16
,
BF16
,
F32
>
,
std
::
tuple
<
F64
,
F64
,
F64
,
F64
,
F64
,
F64
>>
;
using
KernelTypes
=
::
testing
::
Types
<
#ifdef CK_ENABLE_FP16
std
::
tuple
<
F16
,
F16
,
F32
,
F16
,
F16
,
F32
>
#endif
#ifdef CK_ENABLE_FP32
,
std
::
tuple
<
F32
,
F32
,
F32
,
F32
,
F32
,
F32
>
#endif
#ifdef CK_ENABLE_BF16
,
std
::
tuple
<
BF16
,
BF16
,
F32
,
BF16
,
BF16
,
F32
>
#endif
#ifdef CK_ENABLE_FP64
,
std
::
tuple
<
F64
,
F64
,
F64
,
F64
,
F64
,
F64
>
#endif
>
;
TYPED_TEST_SUITE
(
TestBatchNormFwdRank4
,
KernelTypes
);
...
...
test/batchnorm/batchnorm_infer_rank_4.cpp
View file @
b43ac5ef
...
...
@@ -67,10 +67,23 @@ class TestBatchNormInferRank4 : public ::testing::Test
}
};
using
KernelTypes
=
::
testing
::
Types
<
std
::
tuple
<
F16
,
F16
,
F32
,
F16
,
F16
,
F32
>
,
std
::
tuple
<
F32
,
F32
,
F32
,
F32
,
F32
,
F32
>
,
std
::
tuple
<
BF16
,
BF16
,
F32
,
BF16
,
BF16
,
F32
>
,
std
::
tuple
<
F64
,
F64
,
F64
,
F64
,
F64
,
F64
>>
;
using
KernelTypes
=
::
testing
::
Types
<
#ifdef CK_ENABLE_FP16
std
::
tuple
<
F16
,
F16
,
F32
,
F16
,
F16
,
F32
>
#endif
#ifdef CK_ENABLE_FP32
,
std
::
tuple
<
F32
,
F32
,
F32
,
F32
,
F32
,
F32
>
#endif
#ifdef CK_ENABLE_BF16
,
std
::
tuple
<
BF16
,
BF16
,
F32
,
BF16
,
BF16
,
F32
>
#endif
#ifdef CK_ENABLE_FP64
,
std
::
tuple
<
F64
,
F64
,
F64
,
F64
,
F64
,
F64
>
#endif
>
;
TYPED_TEST_SUITE
(
TestBatchNormInferRank4
,
KernelTypes
);
...
...
test/conv_tensor_rearrange/CMakeLists.txt
0 → 100644
View file @
b43ac5ef
add_gtest_executable
(
test_conv_tensor_rearrange test_conv_tensor_rearrange.cpp
)
target_link_libraries
(
test_conv_tensor_rearrange PRIVATE utility device_image_to_column_instance device_column_to_image_instance
)
add_gtest_executable
(
test_conv_tensor_rearrange_interface test_conv_tensor_rearrange_interface.cpp
)
target_link_libraries
(
test_conv_tensor_rearrange_interface PRIVATE utility
)
test/
image_to_column/test_image_to_column
.cpp
→
test/
conv_tensor_rearrange/test_conv_tensor_rearrange
.cpp
View file @
b43ac5ef
// SPDX-License-Identifier: MIT
// Copyright (c)
2018-
2023, Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2023, Advanced Micro Devices, Inc. All rights reserved.
#include <cstdlib>
#include <iostream>
...
...
@@ -9,29 +9,29 @@
#include <gtest/gtest.h>
#include "profiler/profile_
image_to_column
_impl.hpp"
#include "profiler/profile_
conv_tensor_rearrange
_impl.hpp"
template
<
typename
Tuple
>
class
Test
ImageToColumn
:
public
::
testing
::
Test
class
Test
ConvTensorRearrange
:
public
::
testing
::
Test
{
protected:
using
InDataType
=
std
::
tuple_element_t
<
0
,
Tuple
>
;
using
OutDataType
=
std
::
tuple_element_t
<
1
,
Tuple
>
;
using
InLayout
=
std
::
tuple_element_t
<
2
,
Tuple
>
;
using
ImLayout
=
std
::
tuple_element_t
<
0
,
Tuple
>
;
using
ConvTensorRearrangeOp
=
std
::
tuple_element_t
<
1
,
Tuple
>
;
std
::
vector
<
ck
::
utils
::
conv
::
ConvParam
>
conv_params
;
template
<
ck
::
index_t
NDimSpatial
>
template
<
ck
::
index_t
NDimSpatial
,
typename
InDataType
,
typename
OutDataType
>
void
Run
()
{
EXPECT_FALSE
(
conv_params
.
empty
());
bool
pass
=
true
;
for
(
auto
&
param
:
conv_params
)
{
pass
=
pass
&&
ck
::
profiler
::
profile_image_to_column_impl
<
NDimSpatial
,
InLayout
,
InDataType
,
OutDataType
>
(
pass
=
pass
&&
ck
::
profiler
::
profile_conv_tensor_rearrange_impl
<
NDimSpatial
,
ImLayout
,
InDataType
,
OutDataType
,
ConvTensorRearrangeOp
>
(
true
,
// do_verification
1
,
// init_method: integer value
false
,
// do_log
...
...
@@ -43,48 +43,43 @@ class TestImageToColumn : public ::testing::Test
};
using
namespace
ck
::
tensor_layout
::
convolution
;
using
namespace
ck
::
conv_tensor_rearrange_op
;
using
KernelTypes1d
=
::
testing
::
Types
<
std
::
tuple
<
float
,
float
,
GNWC
>
,
std
::
tuple
<
ck
::
bhalf_t
,
ck
::
bhalf_t
,
GNWC
>
,
std
::
tuple
<
ck
::
half_t
,
ck
::
half_t
,
GNWC
>
,
std
::
tuple
<
int8_t
,
int8_t
,
GNWC
>>
;
using
KernelTypes1d
=
::
testing
::
Types
<
std
::
tuple
<
GNWC
,
ImageToColumn
>
,
std
::
tuple
<
GNWC
,
ColumnToImage
>>
;
using
KernelTypes2d
=
::
testing
::
Types
<
std
::
tuple
<
float
,
float
,
GNHWC
>
,
std
::
tuple
<
ck
::
bhalf_t
,
ck
::
bhalf_t
,
GNHWC
>
,
std
::
tuple
<
ck
::
half_t
,
ck
::
half_t
,
GNHWC
>
,
std
::
tuple
<
int8_t
,
int8_t
,
GNHWC
>>
;
using
KernelTypes2d
=
::
testing
::
Types
<
std
::
tuple
<
GNHWC
,
ImageToColumn
>
,
std
::
tuple
<
GNHWC
,
ColumnToImage
>>
;
using
KernelTypes3d
=
::
testing
::
Types
<
std
::
tuple
<
float
,
float
,
GNDHWC
>
,
std
::
tuple
<
ck
::
bhalf_t
,
ck
::
bhalf_t
,
GNDHWC
>
,
std
::
tuple
<
ck
::
half_t
,
ck
::
half_t
,
GNDHWC
>
,
std
::
tuple
<
int8_t
,
int8_t
,
GNDHWC
>>
;
using
KernelTypes3d
=
::
testing
::
Types
<
std
::
tuple
<
GNDHWC
,
ImageToColumn
>
,
std
::
tuple
<
GNDHWC
,
ColumnToImage
>>
;
template
<
typename
Tuple
>
class
Test
ImageToColumn1d
:
public
TestImageToColumn
<
Tuple
>
class
Test
ConvTensorRearrange1d
:
public
TestConvTensorRearrange
<
Tuple
>
{
};
template
<
typename
Tuple
>
class
Test
ImageToColumn2d
:
public
TestImageToColumn
<
Tuple
>
class
Test
ConvTensorRearrange2d
:
public
TestConvTensorRearrange
<
Tuple
>
{
};
template
<
typename
Tuple
>
class
Test
ImageToColumn3d
:
public
TestImageToColumn
<
Tuple
>
class
Test
ConvTensorRearrange3d
:
public
TestConvTensorRearrange
<
Tuple
>
{
};
TYPED_TEST_SUITE
(
Test
ImageToColumn
1d
,
KernelTypes1d
);
TYPED_TEST_SUITE
(
Test
ImageToColumn
2d
,
KernelTypes2d
);
TYPED_TEST_SUITE
(
Test
ImageToColumn
3d
,
KernelTypes3d
);
TYPED_TEST_SUITE
(
Test
ConvTensorRearrange
1d
,
KernelTypes1d
);
TYPED_TEST_SUITE
(
Test
ConvTensorRearrange
2d
,
KernelTypes2d
);
TYPED_TEST_SUITE
(
Test
ConvTensorRearrange
3d
,
KernelTypes3d
);
TYPED_TEST
(
Test
ImageToColumn
1d
,
Test1D
)
TYPED_TEST
(
Test
ConvTensorRearrange
1d
,
Test1D
)
{
this
->
conv_params
.
clear
();
this
->
conv_params
.
push_back
({
1
,
1
,
4
,
1
,
192
,
{
3
},
{
28
},
{
1
},
{
1
},
{
1
},
{
1
}});
this
->
conv_params
.
push_back
({
1
,
1
,
64
,
1
,
64
,
{
3
},
{
14
},
{
1
},
{
1
},
{
1
},
{
1
}});
this
->
conv_params
.
push_back
({
1
,
1
,
64
,
1
,
64
,
{
1
},
{
7
},
{
2
},
{
1
},
{
0
},
{
0
}});
this
->
conv_params
.
push_back
({
1
,
1
,
64
,
1
,
64
,
{
1
},
{
7
},
{
3
},
{
1
},
{
0
},
{
0
}});
this
->
conv_params
.
push_back
({
1
,
1
,
64
,
1
,
64
,
{
1
},
{
3
},
{
1
},
{
1
},
{
0
},
{
0
}});
// ScalarPerVector should be 1
this
->
conv_params
.
push_back
({
1
,
1
,
4
,
1
,
1
,
{
3
},
{
28
},
{
1
},
{
1
},
{
1
},
{
1
}});
...
...
@@ -92,10 +87,21 @@ TYPED_TEST(TestImageToColumn1d, Test1D)
this
->
conv_params
.
push_back
({
1
,
1
,
1
,
1
,
4
,
{
3
},
{
28
},
{
2
},
{
1
},
{
1
},
{
1
}});
// dilation != 1
this
->
conv_params
.
push_back
({
1
,
1
,
1
,
1
,
4
,
{
3
},
{
28
},
{
1
},
{
2
},
{
1
},
{
1
}});
this
->
template
Run
<
1
>();
#ifdef CK_ENABLE_FP32
this
->
template
Run
<
1
,
float
,
float
>();
#endif
#ifdef CK_ENABLE_BF16
this
->
template
Run
<
1
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>();
#endif
#ifdef CK_ENABLE_FP16
this
->
template
Run
<
1
,
ck
::
half_t
,
ck
::
half_t
>();
#endif
#ifdef CK_ENABLE_INT8
this
->
template
Run
<
1
,
int8_t
,
int8_t
>();
#endif
}
TYPED_TEST
(
Test
ImageToColumn
2d
,
Test2D
)
TYPED_TEST
(
Test
ConvTensorRearrange
2d
,
Test2D
)
{
this
->
conv_params
.
clear
();
...
...
@@ -103,19 +109,45 @@ TYPED_TEST(TestImageToColumn2d, Test2D)
{
2
,
1
,
4
,
1
,
192
,
{
3
,
3
},
{
28
,
28
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
this
->
conv_params
.
push_back
(
{
2
,
1
,
64
,
1
,
64
,
{
3
,
3
},
{
14
,
14
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
this
->
conv_params
.
push_back
({
2
,
1
,
64
,
1
,
64
,
{
1
,
1
},
{
7
,
7
},
{
2
,
2
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
this
->
conv_params
.
push_back
({
2
,
1
,
64
,
1
,
64
,
{
1
,
1
},
{
7
,
7
},
{
3
,
3
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
this
->
conv_params
.
push_back
({
2
,
1
,
64
,
1
,
64
,
{
1
,
1
},
{
3
,
3
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
this
->
template
Run
<
2
>();
this
->
conv_params
.
push_back
(
{
2
,
1
,
64
,
1
,
64
,
{
3
,
3
},
{
28
,
28
},
{
2
,
2
},
{
2
,
2
},
{
1
,
1
},
{
1
,
1
}});
#ifdef CK_ENABLE_FP32
this
->
template
Run
<
2
,
float
,
float
>();
#endif
#ifdef CK_ENABLE_BF16
this
->
template
Run
<
2
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>();
#endif
#ifdef CK_ENABLE_FP16
this
->
template
Run
<
2
,
ck
::
half_t
,
ck
::
half_t
>();
#endif
#ifdef CK_ENABLE_INT8
this
->
template
Run
<
2
,
int8_t
,
int8_t
>();
#endif
}
TYPED_TEST
(
Test
ImageToColumn
3d
,
Test3D
)
TYPED_TEST
(
Test
ConvTensorRearrange
3d
,
Test3D
)
{
this
->
conv_params
.
clear
();
this
->
conv_params
.
push_back
(
{
3
,
1
,
16
,
1
,
64
,
{
1
,
1
,
1
},
{
7
,
7
,
7
},
{
2
,
2
,
2
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}});
{
3
,
1
,
16
,
1
,
64
,
{
1
,
1
,
1
},
{
7
,
7
,
7
},
{
2
,
2
,
2
},
{
3
,
3
,
3
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}});
this
->
conv_params
.
push_back
(
{
3
,
1
,
2
,
1
,
64
,
{
3
,
3
,
3
},
{
14
,
14
,
3
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
}});
this
->
conv_params
.
push_back
(
{
3
,
1
,
32
,
1
,
64
,
{
1
,
1
,
1
},
{
3
,
3
,
3
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}});
this
->
template
Run
<
3
>();
this
->
conv_params
.
push_back
(
{
3
,
1
,
64
,
1
,
64
,
{
3
,
3
,
3
},
{
14
,
14
,
14
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
1
,
1
,
1
},
{
1
,
1
,
1
}});
#ifdef CK_ENABLE_FP32
this
->
template
Run
<
3
,
float
,
float
>();
#endif
#ifdef CK_ENABLE_BF16
this
->
template
Run
<
3
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>();
#endif
#ifdef CK_ENABLE_FP16
this
->
template
Run
<
3
,
ck
::
half_t
,
ck
::
half_t
>();
#endif
#ifdef CK_ENABLE_INT8
this
->
template
Run
<
3
,
int8_t
,
int8_t
>();
#endif
}
test/
image_to_column/test_image_to_column
_interface.cpp
→
test/
conv_tensor_rearrange/test_conv_tensor_rearrange
_interface.cpp
View file @
b43ac5ef
// SPDX-License-Identifier: MIT
// Copyright (c)
2018-
2023, Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2023, Advanced Micro Devices, Inc. All rights reserved.
#include <cstdlib>
#include <iostream>
...
...
@@ -10,6 +10,8 @@
#include "ck/ck.hpp"
#include "ck/tensor_operation/gpu/device/tensor_layout.hpp"
#include "ck/tensor_operation/gpu/device/impl/device_image_to_column_impl.hpp"
#include "ck/tensor_operation/gpu/device/impl/device_column_to_image_impl.hpp"
#include "ck/tensor_operation/gpu/device/conv_tensor_rearrange_op.hpp"
#include "ck/library/utility/convolution_parameter.hpp"
#include "ck/library/utility/algorithm.hpp"
...
...
@@ -18,28 +20,37 @@
#include <gtest/gtest.h>
using
DataType
=
float
;
using
I
n
Layout
=
ck
::
tensor_layout
::
convolution
::
GNWC
;
using
I
m
Layout
=
ck
::
tensor_layout
::
convolution
::
GNWC
;
template
<
ck
::
index_t
...
Is
>
using
S
=
ck
::
Sequence
<
Is
...
>
;
using
namespace
ck
::
conv_tensor_rearrange_op
;
template
<
ck
::
index_t
ScalarPerVector
,
bool
IsCPacked
>
class
Test
ImageToColumn
Interface
:
public
::
testing
::
Test
class
Test
ConvTensorRearrange
Interface
:
public
::
testing
::
Test
{
protected:
static
constexpr
ck
::
index_t
NDimSpatial
=
1
;
// clang-format off
using
DeviceImgToColInstance
=
ck
::
tensor_operation
::
device
::
DeviceImageToColumnImpl
//#####################| Num| InLayout| InDataType| OutDataType| Block| MPer| KPer| Thread| Scalar|
//#####################| Dim| | | | Size| Block| Block| Cluster| Per|
//#####################| Spatial| | | | | | | Lengths| Vector|
//#####################| | | | | | | | | |
<
NDimSpatial
,
InLayout
,
DataType
,
DataType
,
256
,
128
,
128
,
S
<
16
,
16
>
,
ScalarPerVector
>
;
// Num| ImLayout| InDataType| OutDataType| Block| MPer| KPer| Thread| Scalar|
// Dim| | | | Size| Block| Block| Cluster| Per|
// Spatial| | | | | | | Lengths| Vector|
// | | | | | | | | |
<
NDimSpatial
,
ImLayout
,
DataType
,
DataType
,
256
,
128
,
128
,
S
<
16
,
16
>
,
ScalarPerVector
>
;
using
DeviceColToimgInstance
=
ck
::
tensor_operation
::
device
::
DeviceColumnToImageImpl
// Num| ImLayout| InDataType| OutDataType| Block| MPer| KPer| Thread| Scalar|
// Dim| | | | Size| Block| Block| Cluster| Per|
// Spatial| | | | | | | Lengths| Vector|
// | | | | | | | | |
<
NDimSpatial
,
ImLayout
,
DataType
,
DataType
,
256
,
128
,
128
,
S
<
16
,
16
>
,
ScalarPerVector
>
;
// clang-format on
ck
::
utils
::
conv
::
ConvParam
conv_param
;
template
<
typename
ConvTensorRearrangeOp
>
bool
Run
()
{
...
...
@@ -57,10 +68,10 @@ class TestImageToColumnInterface : public ::testing::Test
ck
::
accumulate_n
<
ck
::
index_t
>
(
conv_param
.
filter_spatial_lengths_
.
begin
(),
NDimSpatial
,
1
,
std
::
multiplies
<>
());
const
auto
i
n
_desc
=
ck
::
utils
::
conv
::
make_input_host_tensor_descriptor_g_n_c_wis_packed
<
I
n
Layout
>
(
const
auto
i
mage
_desc
=
ck
::
utils
::
conv
::
make_input_host_tensor_descriptor_g_n_c_wis_packed
<
I
m
Layout
>
(
conv_param
);
const
auto
out
_desc
=
HostTensorDescriptor
({
NDoHoWo
,
CZYX
});
const
auto
gemm
_desc
=
HostTensorDescriptor
({
NDoHoWo
,
CZYX
});
std
::
array
<
ck
::
index_t
,
NDimSpatial
>
input_spatial_lengths
{};
std
::
array
<
ck
::
index_t
,
NDimSpatial
>
filter_spatial_lengths
{};
...
...
@@ -77,120 +88,173 @@ class TestImageToColumnInterface : public ::testing::Test
copy
(
conv_param
.
input_spatial_lengths_
,
input_spatial_lengths
);
copy
(
conv_param
.
filter_spatial_lengths_
,
filter_spatial_lengths
);
copy
(
conv_param
.
output_spatial_lengths_
,
output_spatial_lengths
);
copy
(
i
n
_desc
.
GetStrides
(),
input_g_n_c_wis_strides
);
copy
(
out
_desc
.
GetStrides
(),
output_m_k_strides
);
copy
(
i
mage
_desc
.
GetStrides
(),
input_g_n_c_wis_strides
);
copy
(
gemm
_desc
.
GetStrides
(),
output_m_k_strides
);
copy
(
conv_param
.
conv_filter_strides_
,
conv_filter_strides
);
copy
(
conv_param
.
conv_filter_dilations_
,
conv_filter_dilations
);
copy
(
conv_param
.
input_left_pads_
,
input_left_pads
);
copy
(
conv_param
.
input_right_pads_
,
input_right_pads
);
auto
img2col
=
DeviceImgToColInstance
{};
auto
argument
=
img2col
.
MakeArgument
(
nullptr
,
nullptr
,
N
,
IsCPacked
?
C
:
FakeC
,
input_spatial_lengths
,
filter_spatial_lengths
,
output_spatial_lengths
,
input_g_n_c_wis_strides
,
output_m_k_strides
,
conv_filter_strides
,
conv_filter_dilations
,
input_left_pads
,
input_right_pads
);
return
img2col
.
IsSupportedArgument
(
argument
);
if
constexpr
(
std
::
is_same_v
<
ConvTensorRearrangeOp
,
ImageToColumn
>
)
{
auto
img2col
=
DeviceImgToColInstance
{};
auto
argument
=
img2col
.
MakeArgument
(
nullptr
,
nullptr
,
N
,
IsCPacked
?
C
:
FakeC
,
input_spatial_lengths
,
filter_spatial_lengths
,
output_spatial_lengths
,
input_g_n_c_wis_strides
,
output_m_k_strides
,
conv_filter_strides
,
conv_filter_dilations
,
input_left_pads
,
input_right_pads
);
return
img2col
.
IsSupportedArgument
(
argument
);
}
else
if
constexpr
(
std
::
is_same_v
<
ConvTensorRearrangeOp
,
ColumnToImage
>
)
{
auto
col2img
=
DeviceColToimgInstance
{};
auto
argument
=
col2img
.
MakeArgument
(
nullptr
,
nullptr
,
N
,
IsCPacked
?
C
:
FakeC
,
input_spatial_lengths
,
filter_spatial_lengths
,
output_spatial_lengths
,
input_g_n_c_wis_strides
,
output_m_k_strides
,
conv_filter_strides
,
conv_filter_dilations
,
input_left_pads
,
input_right_pads
);
return
col2img
.
IsSupportedArgument
(
argument
);
}
}
};
class
TestImageToColumnInterface1ScalarPerVector
:
public
TestImageToColumnInterface
<
1
,
true
>
class
TestConvTensorRearrangeInterface1ScalarPerVector
:
public
TestConvTensorRearrangeInterface
<
1
,
true
>
{
};
class
TestImageToColumnInterface4ScalarPerVector
:
public
TestImageToColumnInterface
<
4
,
true
>
class
TestConvTensorRearrangeInterface4ScalarPerVector
:
public
TestConvTensorRearrangeInterface
<
4
,
true
>
{
};
class
TestImageToColumnInterface4ScalarPerVectorFakeC
:
public
TestImageToColumnInterface
<
4
,
false
>
class
TestConvTensorRearrangeInterface4ScalarPerVectorFakeC
:
public
TestConvTensorRearrangeInterface
<
4
,
false
>
{
};
TEST_F
(
Test
ImageToColumn
Interface1ScalarPerVector
,
X1ScalarPerVector
)
TEST_F
(
Test
ConvTensorRearrange
Interface1ScalarPerVector
,
X1ScalarPerVector
)
{
// vector load C * X % ScalarPerVector
this
->
conv_param
=
{
1
,
1
,
1
,
1
,
1
,
{
3
},
{
3
},
{
1
},
{
1
},
{
0
},
{
0
}};
bool
is_supported
=
this
->
Run
();
bool
is_supported
=
this
->
template
Run
<
ImageToColumn
>();
EXPECT_TRUE
(
is_supported
);
is_supported
=
this
->
template
Run
<
ColumnToImage
>();
EXPECT_TRUE
(
is_supported
);
// vector load C * left_pad_x % ScalarPerVector
this
->
conv_param
=
{
1
,
1
,
1
,
1
,
1
,
{
4
},
{
3
},
{
1
},
{
1
},
{
3
},
{
0
}};
is_supported
=
this
->
Run
();
is_supported
=
this
->
template
Run
<
ImageToColumn
>();
EXPECT_TRUE
(
is_supported
);
is_supported
=
this
->
template
Run
<
ColumnToImage
>();
EXPECT_TRUE
(
is_supported
);
// vector load C * right_pad_x % ScalarPerVector
this
->
conv_param
=
{
1
,
1
,
1
,
1
,
1
,
{
4
},
{
3
},
{
1
},
{
1
},
{
0
},
{
3
}};
is_supported
=
this
->
Run
();
is_supported
=
this
->
template
Run
<
ImageToColumn
>();
EXPECT_TRUE
(
is_supported
);
is_supported
=
this
->
template
Run
<
ColumnToImage
>();
EXPECT_TRUE
(
is_supported
);
// vector load C % ScalarPerVector, right_pad and stride
this
->
conv_param
=
{
1
,
1
,
1
,
1
,
1
,
{
4
},
{
3
},
{
2
},
{
1
},
{
0
},
{
3
}};
is_supported
=
this
->
Run
();
is_supported
=
this
->
template
Run
<
ImageToColumn
>();
EXPECT_TRUE
(
is_supported
);
is_supported
=
this
->
template
Run
<
ColumnToImage
>();
EXPECT_TRUE
(
is_supported
);
// vector load C % ScalarPerVector, left_pad and stride
this
->
conv_param
=
{
1
,
1
,
1
,
1
,
1
,
{
4
},
{
3
},
{
2
},
{
1
},
{
3
},
{
0
}};
is_supported
=
this
->
Run
();
is_supported
=
this
->
template
Run
<
ImageToColumn
>();
EXPECT_TRUE
(
is_supported
);
is_supported
=
this
->
template
Run
<
ColumnToImage
>();
EXPECT_TRUE
(
is_supported
);
// vector load C % ScalarPerVector, dilation
this
->
conv_param
=
{
1
,
1
,
1
,
1
,
1
,
{
4
},
{
3
},
{
1
},
{
2
},
{
0
},
{
0
}};
is_supported
=
this
->
Run
();
is_supported
=
this
->
template
Run
<
ImageToColumn
>();
EXPECT_TRUE
(
is_supported
);
is_supported
=
this
->
template
Run
<
ColumnToImage
>();
EXPECT_TRUE
(
is_supported
);
// C = 4
this
->
conv_param
=
{
1
,
1
,
1
,
1
,
4
,
{
3
},
{
3
},
{
1
},
{
1
},
{
3
},
{
3
}};
is_supported
=
this
->
Run
();
is_supported
=
this
->
template
Run
<
ImageToColumn
>();
EXPECT_TRUE
(
is_supported
);
is_supported
=
this
->
template
Run
<
ColumnToImage
>();
EXPECT_TRUE
(
is_supported
);
}
TEST_F
(
Test
ImageToColumn
Interface4ScalarPerVector
,
X4ScalarPerVector
)
TEST_F
(
Test
ConvTensorRearrange
Interface4ScalarPerVector
,
X4ScalarPerVector
)
{
// vector load C * X % ScalarPerVector
this
->
conv_param
=
{
1
,
1
,
1
,
1
,
1
,
{
3
},
{
3
},
{
1
},
{
1
},
{
0
},
{
0
}};
bool
is_supported
=
this
->
Run
();
bool
is_supported
=
this
->
template
Run
<
ImageToColumn
>();
EXPECT_FALSE
(
is_supported
);
is_supported
=
this
->
template
Run
<
ColumnToImage
>();
EXPECT_FALSE
(
is_supported
);
// vector load C * left_pad_x % ScalarPerVector
this
->
conv_param
=
{
1
,
1
,
1
,
1
,
1
,
{
4
},
{
3
},
{
1
},
{
1
},
{
3
},
{
0
}};
is_supported
=
this
->
Run
();
is_supported
=
this
->
template
Run
<
ImageToColumn
>();
EXPECT_FALSE
(
is_supported
);
is_supported
=
this
->
template
Run
<
ColumnToImage
>();
EXPECT_FALSE
(
is_supported
);
// vector load C * right_pad_x % ScalarPerVector
this
->
conv_param
=
{
1
,
1
,
1
,
1
,
1
,
{
4
},
{
3
},
{
1
},
{
1
},
{
0
},
{
3
}};
is_supported
=
this
->
Run
();
is_supported
=
this
->
template
Run
<
ImageToColumn
>();
EXPECT_FALSE
(
is_supported
);
is_supported
=
this
->
template
Run
<
ColumnToImage
>();
EXPECT_FALSE
(
is_supported
);
// vector load C % ScalarPerVector, right_pad and stride
this
->
conv_param
=
{
1
,
1
,
1
,
1
,
1
,
{
4
},
{
3
},
{
2
},
{
1
},
{
0
},
{
3
}};
is_supported
=
this
->
Run
();
is_supported
=
this
->
template
Run
<
ImageToColumn
>();
EXPECT_FALSE
(
is_supported
);
is_supported
=
this
->
template
Run
<
ColumnToImage
>();
EXPECT_FALSE
(
is_supported
);
// vector load C % ScalarPerVector, left_pad and stride
this
->
conv_param
=
{
1
,
1
,
1
,
1
,
1
,
{
4
},
{
3
},
{
2
},
{
1
},
{
3
},
{
0
}};
is_supported
=
this
->
Run
();
is_supported
=
this
->
template
Run
<
ImageToColumn
>();
EXPECT_FALSE
(
is_supported
);
is_supported
=
this
->
template
Run
<
ColumnToImage
>();
EXPECT_FALSE
(
is_supported
);
// vector load C % ScalarPerVector, dilation
this
->
conv_param
=
{
1
,
1
,
1
,
1
,
1
,
{
4
},
{
3
},
{
1
},
{
2
},
{
0
},
{
0
}};
is_supported
=
this
->
Run
();
is_supported
=
this
->
template
Run
<
ImageToColumn
>();
EXPECT_FALSE
(
is_supported
);
is_supported
=
this
->
template
Run
<
ColumnToImage
>();
EXPECT_FALSE
(
is_supported
);
// C = 4
this
->
conv_param
=
{
1
,
1
,
1
,
1
,
4
,
{
3
},
{
3
},
{
1
},
{
1
},
{
3
},
{
3
}};
is_supported
=
this
->
Run
();
is_supported
=
this
->
template
Run
<
ImageToColumn
>();
EXPECT_TRUE
(
is_supported
);
is_supported
=
this
->
template
Run
<
ColumnToImage
>();
EXPECT_TRUE
(
is_supported
);
}
TEST_F
(
Test
ImageToColumn
Interface4ScalarPerVectorFakeC
,
X4ScalarPerVectorFakeC
)
TEST_F
(
Test
ConvTensorRearrange
Interface4ScalarPerVectorFakeC
,
X4ScalarPerVectorFakeC
)
{
// C = 3
this
->
conv_param
=
{
1
,
1
,
1
,
1
,
3
,
{
4
},
{
3
},
{
1
},
{
1
},
{
0
},
{
0
}};
bool
is_supported
=
this
->
Run
();
bool
is_supported
=
this
->
template
Run
<
ImageToColumn
>();
EXPECT_FALSE
(
is_supported
);
is_supported
=
this
->
template
Run
<
ColumnToImage
>();
EXPECT_FALSE
(
is_supported
);
// C = 4
this
->
conv_param
=
{
1
,
1
,
1
,
1
,
8
,
{
4
},
{
3
},
{
1
},
{
1
},
{
0
},
{
0
}};
is_supported
=
this
->
Run
();
is_supported
=
this
->
template
Run
<
ImageToColumn
>();
EXPECT_TRUE
(
is_supported
);
is_supported
=
this
->
template
Run
<
ColumnToImage
>();
EXPECT_TRUE
(
is_supported
);
}
test/data_type/CMakeLists.txt
View file @
b43ac5ef
...
...
@@ -13,3 +13,5 @@ add_gtest_executable(test_bf8 bf8.cpp)
if
(
result EQUAL 0
)
target_link_libraries
(
test_bf8 PRIVATE utility
)
endif
()
add_gtest_executable
(
test_type_convert_const type_convert_const.cpp
)
test/data_type/type_convert_const.cpp
0 → 100644
View file @
b43ac5ef
// SPDX-License-Identifier: MIT
// Copyright (c) 2023, Advanced Micro Devices, Inc. All rights reserved.
#include "gtest/gtest.h"
#include "ck/utility/data_type.hpp"
#include "ck/utility/type_convert.hpp"
using
ck
::
bhalf_t
;
using
ck
::
type_convert
;
TEST
(
TypeConvertConst
,
ConvertToConst
)
{
constexpr
float
bf16_epsilon
=
0.0078125
;
constexpr
float
rel_tol
=
2
*
bf16_epsilon
;
const
std
::
vector
<
float
>
cases
=
{
0.0
,
-
123.
f
,
3.981323
f
,
0.2429
f
};
for
(
float
x
:
cases
)
{
const
float
abs_tol
=
std
::
abs
(
rel_tol
*
x
);
{
bhalf_t
y
=
type_convert
<
bhalf_t
>
(
x
);
// Test non-const bhalf to const float.
const
float
y_float
=
type_convert
<
const
float
>
(
y
);
ASSERT_NEAR
(
y_float
,
x
,
abs_tol
);
}
{
// Test non-const float to const bhalf.
const
bhalf_t
y
=
type_convert
<
const
bhalf_t
>
(
x
);
// Remove the constness manually to not rely on const casts anymore since the
// possible issue could hide after two casts.
bhalf_t
&
y_nonconst
=
const_cast
<
bhalf_t
&>
(
y
);
float
y_float
=
type_convert
<
float
>
(
y_nonconst
);
ASSERT_NEAR
(
y_float
,
x
,
abs_tol
);
}
}
}
TEST
(
TypeConvertConst
,
ConvertFromConst
)
{
constexpr
float
bf16_epsilon
=
0.0078125
;
constexpr
float
rel_tol
=
2
*
bf16_epsilon
;
const
std
::
vector
<
float
>
cases
=
{
0.0
,
-
123.
f
,
3.981323
f
,
0.2429
f
};
for
(
const
float
x
:
cases
)
{
const
float
abs_tol
=
std
::
abs
(
rel_tol
*
x
);
{
// Test const float to const bhalf_t.
const
bhalf_t
y
=
type_convert
<
const
bhalf_t
>
(
x
);
// Remove the constness manually to not rely on const casts anymore since the
// possible issue could hide after two casts.
bhalf_t
&
y_nonconst
=
const_cast
<
bhalf_t
&>
(
y
);
float
y_float
=
type_convert
<
float
>
(
y_nonconst
);
ASSERT_NEAR
(
y_float
,
x
,
abs_tol
);
}
{
// Test const float to non-const bhalf.
bhalf_t
y
=
type_convert
<
bhalf_t
>
(
x
);
float
y_float
=
type_convert
<
float
>
(
y
);
ASSERT_NEAR
(
y_float
,
x
,
abs_tol
);
}
{
const
bhalf_t
y
=
type_convert
<
const
bhalf_t
>
(
x
);
// Test const bhalf to non-const float.
float
y_float
=
type_convert
<
float
>
(
y
);
ASSERT_NEAR
(
y_float
,
x
,
abs_tol
);
}
// Tests with full type specializations for X.
{
// Test const float to const bhalf_t.
const
bhalf_t
y
=
type_convert
<
const
bhalf_t
,
const
float
>
(
x
);
// Remove the constness manually to not rely on const casts anymore since the
// possible issue could hide after two casts.
bhalf_t
&
y_nonconst
=
const_cast
<
bhalf_t
&>
(
y
);
float
y_float
=
type_convert
<
float
>
(
y_nonconst
);
ASSERT_NEAR
(
y_float
,
x
,
abs_tol
);
}
{
// Test const float to non-const bhalf.
bhalf_t
y
=
type_convert
<
bhalf_t
,
const
float
>
(
x
);
float
y_float
=
type_convert
<
float
>
(
y
);
ASSERT_NEAR
(
y_float
,
x
,
abs_tol
);
}
{
const
bhalf_t
y
=
type_convert
<
const
bhalf_t
,
const
float
>
(
x
);
// Test const bhalf to non-const float.
float
y_float
=
type_convert
<
float
,
const
bhalf_t
>
(
y
);
ASSERT_NEAR
(
y_float
,
x
,
abs_tol
);
}
}
}
test/gemm_split_k/test_gemm_splitk_ut_cases.inc
View file @
b43ac5ef
...
...
@@ -2,7 +2,7 @@
TYPED_TEST
(
TestGemmSplitK_MK_KN
,
SmallM
)
{
std
::
vector
<
int
>
Ms
{
0
,
1
,
2
,
3
,
4
,
5
,
6
};
std
::
vector
<
int
>
Ms
{
1
,
2
,
3
,
4
,
5
,
6
};
constexpr
int
N
=
512
;
constexpr
int
K
=
320
;
...
...
@@ -16,7 +16,7 @@ TYPED_TEST(TestGemmSplitK_MK_KN, SmallM)
TYPED_TEST
(
TestGemmSplitK_MK_NK
,
SmallM
)
{
std
::
vector
<
int
>
Ms
{
0
,
1
,
2
,
3
,
4
,
5
,
6
};
std
::
vector
<
int
>
Ms
{
1
,
2
,
3
,
4
,
5
,
6
};
constexpr
int
N
=
512
;
constexpr
int
K
=
320
;
...
...
@@ -30,7 +30,7 @@ TYPED_TEST(TestGemmSplitK_MK_NK, SmallM)
TYPED_TEST
(
TestGemmSplitK_KM_KN
,
SmallM
)
{
std
::
vector
<
int
>
Ms
{
0
,
1
,
2
,
3
,
4
,
5
,
6
};
std
::
vector
<
int
>
Ms
{
1
,
2
,
3
,
4
,
5
,
6
};
constexpr
int
N
=
512
;
constexpr
int
K
=
320
;
...
...
@@ -43,7 +43,7 @@ TYPED_TEST(TestGemmSplitK_KM_KN, SmallM)
TYPED_TEST
(
TestGemmSplitK_KM_NK
,
SmallM
)
{
std
::
vector
<
int
>
Ms
{
0
,
1
,
2
,
3
,
4
,
5
,
6
};
std
::
vector
<
int
>
Ms
{
1
,
2
,
3
,
4
,
5
,
6
};
constexpr
int
N
=
512
;
constexpr
int
K
=
320
;
...
...
test/grouped_convnd_fwd/CMakeLists.txt
View file @
b43ac5ef
add_gtest_executable
(
test_grouped_convnd_fwd grouped_convnd_fwd.cpp
)
add_gtest_executable
(
test_grouped_convnd_fwd
test_
grouped_convnd_fwd.cpp
)
target_link_libraries
(
test_grouped_convnd_fwd PRIVATE utility device_grouped_conv1d_fwd_instance device_grouped_conv2d_fwd_instance device_grouped_conv3d_fwd_instance
)
test/grouped_convnd_fwd/grouped_convnd_fwd.cpp
deleted
100644 → 0
View file @
b892a14a
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2023, Advanced Micro Devices, Inc. All rights reserved.
#include <cstdlib>
#include <iostream>
#include <initializer_list>
#include <vector>
#include <gtest/gtest.h>
#include "profiler/profile_grouped_conv_fwd_impl.hpp"
class
TestGroupedConvNdFwd
:
public
::
testing
::
Test
{
protected:
std
::
vector
<
ck
::
utils
::
conv
::
ConvParam
>
conv_params
;
};
// 1d GNWC/GKXC/GNWK
TEST_F
(
TestGroupedConvNdFwd
,
GroupedConv1dFwdGNWC
)
{
conv_params
.
clear
();
conv_params
.
push_back
({
1
,
2
,
128
,
128
,
256
,
{
1
},
{
14
},
{
2
},
{
1
},
{
0
},
{
0
}});
conv_params
.
push_back
({
1
,
2
,
128
,
128
,
256
,
{
3
},
{
28
},
{
1
},
{
1
},
{
1
},
{
1
}});
conv_params
.
push_back
({
1
,
2
,
128
,
128
,
256
,
{
1
},
{
3
},
{
1
},
{
1
},
{
0
},
{
0
}});
conv_params
.
push_back
({
1
,
1
,
1
,
1
,
32
,
{
3
},
{
32
},
{
1
},
{
1
},
{
1
},
{
1
}});
conv_params
.
push_back
({
1
,
1
,
1
,
64
,
3
,
{
3
},
{
32
},
{
1
},
{
1
},
{
1
},
{
1
}});
for
(
auto
&
param
:
conv_params
)
{
bool
pass
;
// fp32
pass
=
ck
::
profiler
::
profile_grouped_conv_fwd_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
GNWC
,
ck
::
tensor_layout
::
convolution
::
GKXC
,
ck
::
tensor_layout
::
convolution
::
GNWK
,
float
,
float
,
float
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
// fp16
pass
=
ck
::
profiler
::
profile_grouped_conv_fwd_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
GNWC
,
ck
::
tensor_layout
::
convolution
::
GKXC
,
ck
::
tensor_layout
::
convolution
::
GNWK
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
// bf16
pass
=
ck
::
profiler
::
profile_grouped_conv_fwd_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
GNWC
,
ck
::
tensor_layout
::
convolution
::
GKXC
,
ck
::
tensor_layout
::
convolution
::
GNWK
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
// int8
pass
=
ck
::
profiler
::
profile_grouped_conv_fwd_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
GNWC
,
ck
::
tensor_layout
::
convolution
::
GKXC
,
ck
::
tensor_layout
::
convolution
::
GNWK
,
int8_t
,
int8_t
,
int8_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
}
}
// 2d GNHWC/GKYXC/GNHWK
TEST_F
(
TestGroupedConvNdFwd
,
GroupedConv2dFwdGNHWC
)
{
conv_params
.
clear
();
conv_params
.
push_back
({
2
,
2
,
128
,
128
,
256
,
{
1
,
1
},
{
7
,
7
},
{
2
,
2
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
conv_params
.
push_back
({
2
,
2
,
128
,
128
,
256
,
{
3
,
3
},
{
14
,
14
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
conv_params
.
push_back
({
2
,
2
,
128
,
128
,
256
,
{
1
,
1
},
{
3
,
3
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
conv_params
.
push_back
({
2
,
1
,
1
,
1
,
32
,
{
3
,
3
},
{
32
,
32
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
conv_params
.
push_back
({
2
,
1
,
1
,
64
,
3
,
{
3
,
3
},
{
32
,
32
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
conv_params
.
push_back
({
2
,
1
,
1
,
1
,
1
,
{
3
,
3
},
{
32
,
32
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
for
(
auto
&
param
:
conv_params
)
{
bool
pass
;
// fp32
pass
=
ck
::
profiler
::
profile_grouped_conv_fwd_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
GNHWC
,
ck
::
tensor_layout
::
convolution
::
GKYXC
,
ck
::
tensor_layout
::
convolution
::
GNHWK
,
float
,
float
,
float
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
// fp16
pass
=
ck
::
profiler
::
profile_grouped_conv_fwd_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
GNHWC
,
ck
::
tensor_layout
::
convolution
::
GKYXC
,
ck
::
tensor_layout
::
convolution
::
GNHWK
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
// bf16
pass
=
ck
::
profiler
::
profile_grouped_conv_fwd_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
GNHWC
,
ck
::
tensor_layout
::
convolution
::
GKYXC
,
ck
::
tensor_layout
::
convolution
::
GNHWK
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
// int8
pass
=
ck
::
profiler
::
profile_grouped_conv_fwd_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
GNHWC
,
ck
::
tensor_layout
::
convolution
::
GKYXC
,
ck
::
tensor_layout
::
convolution
::
GNHWK
,
int8_t
,
int8_t
,
int8_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
}
}
// 3d GNDHWC/GKZYXC/GNDHWK
TEST_F
(
TestGroupedConvNdFwd
,
GroupedConv3dFwdGNDHWC
)
{
conv_params
.
clear
();
conv_params
.
push_back
(
{
3
,
2
,
128
,
128
,
256
,
{
1
,
1
,
1
},
{
7
,
7
,
7
},
{
2
,
2
,
2
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}});
conv_params
.
push_back
(
{
3
,
2
,
128
,
128
,
256
,
{
3
,
3
,
3
},
{
14
,
14
,
3
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
}});
conv_params
.
push_back
(
{
3
,
2
,
128
,
128
,
256
,
{
1
,
1
,
1
},
{
3
,
3
,
3
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}});
conv_params
.
push_back
(
{
3
,
1
,
1
,
1
,
32
,
{
3
,
3
,
3
},
{
32
,
32
,
32
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
}});
this
->
conv_params
.
push_back
(
{
3
,
1
,
1
,
64
,
3
,
{
3
,
3
,
3
},
{
32
,
32
,
32
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
}});
conv_params
.
push_back
(
{
3
,
1
,
1
,
1
,
1
,
{
3
,
3
,
3
},
{
32
,
32
,
32
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
}});
for
(
auto
&
param
:
conv_params
)
{
bool
pass
;
// fp32
pass
=
ck
::
profiler
::
profile_grouped_conv_fwd_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
GNDHWC
,
ck
::
tensor_layout
::
convolution
::
GKZYXC
,
ck
::
tensor_layout
::
convolution
::
GNDHWK
,
float
,
float
,
float
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
// fp16
pass
=
ck
::
profiler
::
profile_grouped_conv_fwd_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
GNDHWC
,
ck
::
tensor_layout
::
convolution
::
GKZYXC
,
ck
::
tensor_layout
::
convolution
::
GNDHWK
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
// bf16
pass
=
ck
::
profiler
::
profile_grouped_conv_fwd_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
GNDHWC
,
ck
::
tensor_layout
::
convolution
::
GKZYXC
,
ck
::
tensor_layout
::
convolution
::
GNDHWK
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
// int8
pass
=
ck
::
profiler
::
profile_grouped_conv_fwd_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
GNDHWC
,
ck
::
tensor_layout
::
convolution
::
GKZYXC
,
ck
::
tensor_layout
::
convolution
::
GNDHWK
,
int8_t
,
int8_t
,
int8_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
}
}
// 2d NHWGC/KYXGC/NHWGK
TEST_F
(
TestGroupedConvNdFwd
,
GroupedConv2dFwdNHWGC
)
{
conv_params
.
clear
();
conv_params
.
push_back
({
2
,
2
,
128
,
128
,
256
,
{
1
,
1
},
{
7
,
7
},
{
2
,
2
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
conv_params
.
push_back
({
2
,
2
,
128
,
128
,
256
,
{
3
,
3
},
{
14
,
14
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
conv_params
.
push_back
({
2
,
2
,
128
,
128
,
256
,
{
1
,
1
},
{
3
,
3
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
conv_params
.
push_back
({
2
,
1
,
1
,
1
,
32
,
{
3
,
3
},
{
32
,
32
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
conv_params
.
push_back
({
2
,
1
,
1
,
64
,
3
,
{
3
,
3
},
{
32
,
32
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
conv_params
.
push_back
({
2
,
1
,
1
,
1
,
1
,
{
3
,
3
},
{
32
,
32
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
for
(
auto
&
param
:
conv_params
)
{
bool
pass
;
// fp16
pass
=
ck
::
profiler
::
profile_grouped_conv_fwd_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWGC
,
ck
::
tensor_layout
::
convolution
::
GKYXC
,
ck
::
tensor_layout
::
convolution
::
NHWGK
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
}
}
test/grouped_convnd_fwd/test_grouped_convnd_fwd.cpp
0 → 100644
View file @
b43ac5ef
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2023, Advanced Micro Devices, Inc. All rights reserved.
#include <cstdlib>
#include <iostream>
#include <initializer_list>
#include <vector>
#include <gtest/gtest.h>
#include "profiler/profile_grouped_conv_fwd_impl.hpp"
template
<
typename
Tuple
>
class
TestGroupedConvndFwd
:
public
::
testing
::
Test
{
protected:
using
DataType
=
std
::
tuple_element_t
<
0
,
Tuple
>
;
using
InLayout
=
std
::
tuple_element_t
<
1
,
Tuple
>
;
using
WeiLayout
=
std
::
tuple_element_t
<
2
,
Tuple
>
;
using
OutLayout
=
std
::
tuple_element_t
<
3
,
Tuple
>
;
std
::
vector
<
ck
::
utils
::
conv
::
ConvParam
>
conv_params
;
template
<
ck
::
index_t
NDimSpatial
>
void
Run
()
{
EXPECT_FALSE
(
conv_params
.
empty
());
bool
pass
=
true
;
for
(
auto
&
param
:
conv_params
)
{
pass
=
pass
&&
ck
::
profiler
::
profile_grouped_conv_fwd_impl
<
NDimSpatial
,
InLayout
,
WeiLayout
,
OutLayout
,
DataType
,
DataType
,
DataType
>
(
true
,
// do_verification
1
,
// init_method: integer value
false
,
// do_log
false
,
// time_kernel
param
);
}
EXPECT_TRUE
(
pass
);
}
};
using
namespace
ck
::
tensor_layout
::
convolution
;
using
KernelTypes1d
=
::
testing
::
Types
<
std
::
tuple
<
float
,
GNWC
,
GKXC
,
GNWK
>
,
std
::
tuple
<
ck
::
half_t
,
GNWC
,
GKXC
,
GNWK
>
,
std
::
tuple
<
ck
::
bhalf_t
,
GNWC
,
GKXC
,
GNWK
>
,
std
::
tuple
<
int8_t
,
GNWC
,
GKXC
,
GNWK
>>
;
using
KernelTypes2d
=
::
testing
::
Types
<
std
::
tuple
<
float
,
GNHWC
,
GKYXC
,
GNHWK
>
,
std
::
tuple
<
ck
::
half_t
,
GNHWC
,
GKYXC
,
GNHWK
>
,
std
::
tuple
<
ck
::
bhalf_t
,
GNHWC
,
GKYXC
,
GNHWK
>
,
std
::
tuple
<
int8_t
,
GNHWC
,
GKYXC
,
GNHWK
>
,
std
::
tuple
<
float
,
NHWGC
,
GKYXC
,
NHWGK
>
,
std
::
tuple
<
ck
::
half_t
,
NHWGC
,
GKYXC
,
NHWGK
>
,
std
::
tuple
<
ck
::
bhalf_t
,
NHWGC
,
GKYXC
,
NHWGK
>
,
std
::
tuple
<
int8_t
,
NHWGC
,
GKYXC
,
NHWGK
>>
;
using
KernelTypes3d
=
::
testing
::
Types
<
std
::
tuple
<
float
,
GNDHWC
,
GKZYXC
,
GNDHWK
>
,
std
::
tuple
<
ck
::
half_t
,
GNDHWC
,
GKZYXC
,
GNDHWK
>
,
std
::
tuple
<
ck
::
bhalf_t
,
GNDHWC
,
GKZYXC
,
GNDHWK
>
,
std
::
tuple
<
int8_t
,
GNDHWC
,
GKZYXC
,
GNDHWK
>
,
std
::
tuple
<
float
,
NDHWGC
,
GKZYXC
,
NDHWGK
>
,
std
::
tuple
<
ck
::
half_t
,
NDHWGC
,
GKZYXC
,
NDHWGK
>
,
std
::
tuple
<
ck
::
bhalf_t
,
NDHWGC
,
GKZYXC
,
NDHWGK
>
,
std
::
tuple
<
int8_t
,
NDHWGC
,
GKZYXC
,
NDHWGK
>>
;
template
<
typename
Tuple
>
class
TestGroupedConvndFwd1d
:
public
TestGroupedConvndFwd
<
Tuple
>
{
};
template
<
typename
Tuple
>
class
TestGroupedConvndFwd2d
:
public
TestGroupedConvndFwd
<
Tuple
>
{
};
template
<
typename
Tuple
>
class
TestGroupedConvndFwd3d
:
public
TestGroupedConvndFwd
<
Tuple
>
{
};
TYPED_TEST_SUITE
(
TestGroupedConvndFwd1d
,
KernelTypes1d
);
TYPED_TEST_SUITE
(
TestGroupedConvndFwd2d
,
KernelTypes2d
);
TYPED_TEST_SUITE
(
TestGroupedConvndFwd3d
,
KernelTypes3d
);
TYPED_TEST
(
TestGroupedConvndFwd1d
,
Test1D
)
{
this
->
conv_params
.
clear
();
this
->
conv_params
.
push_back
({
1
,
2
,
32
,
128
,
256
,
{
1
},
{
14
},
{
2
},
{
1
},
{
0
},
{
0
}});
this
->
conv_params
.
push_back
({
1
,
2
,
32
,
128
,
256
,
{
3
},
{
28
},
{
1
},
{
1
},
{
1
},
{
1
}});
this
->
conv_params
.
push_back
({
1
,
2
,
32
,
128
,
256
,
{
1
},
{
3
},
{
1
},
{
1
},
{
0
},
{
0
}});
this
->
conv_params
.
push_back
({
1
,
1
,
1
,
1
,
32
,
{
3
},
{
32
},
{
1
},
{
1
},
{
1
},
{
1
}});
this
->
conv_params
.
push_back
({
1
,
1
,
1
,
64
,
3
,
{
3
},
{
32
},
{
1
},
{
1
},
{
1
},
{
1
}});
this
->
template
Run
<
1
>();
}
TYPED_TEST
(
TestGroupedConvndFwd2d
,
Test2D
)
{
this
->
conv_params
.
clear
();
this
->
conv_params
.
push_back
(
{
2
,
2
,
32
,
128
,
256
,
{
1
,
1
},
{
7
,
7
},
{
2
,
2
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
this
->
conv_params
.
push_back
(
{
2
,
2
,
32
,
128
,
256
,
{
3
,
3
},
{
14
,
14
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
this
->
conv_params
.
push_back
(
{
2
,
2
,
32
,
128
,
256
,
{
1
,
1
},
{
3
,
3
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
this
->
conv_params
.
push_back
({
2
,
1
,
1
,
1
,
32
,
{
3
,
3
},
{
32
,
32
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
this
->
conv_params
.
push_back
({
2
,
1
,
1
,
64
,
3
,
{
3
,
3
},
{
32
,
32
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
this
->
conv_params
.
push_back
({
2
,
1
,
1
,
1
,
1
,
{
3
,
3
},
{
32
,
32
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
this
->
template
Run
<
2
>();
}
TYPED_TEST
(
TestGroupedConvndFwd3d
,
Test3D
)
{
this
->
conv_params
.
clear
();
this
->
conv_params
.
push_back
(
{
3
,
2
,
32
,
128
,
256
,
{
1
,
1
,
1
},
{
7
,
7
,
7
},
{
2
,
2
,
2
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}});
this
->
conv_params
.
push_back
(
{
3
,
2
,
32
,
128
,
256
,
{
3
,
3
,
3
},
{
14
,
14
,
3
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
}});
this
->
conv_params
.
push_back
(
{
3
,
2
,
32
,
128
,
256
,
{
1
,
1
,
1
},
{
3
,
3
,
3
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}});
this
->
conv_params
.
push_back
(
{
3
,
1
,
1
,
1
,
32
,
{
3
,
3
,
3
},
{
32
,
32
,
32
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
}});
this
->
conv_params
.
push_back
(
{
3
,
1
,
1
,
64
,
3
,
{
3
,
3
,
3
},
{
32
,
32
,
32
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
}});
this
->
conv_params
.
push_back
(
{
3
,
1
,
1
,
1
,
1
,
{
3
,
3
,
3
},
{
32
,
32
,
32
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
}});
this
->
template
Run
<
3
>();
}
test/image_to_column/CMakeLists.txt
deleted
100644 → 0
View file @
b892a14a
add_gtest_executable
(
test_image_to_column test_image_to_column.cpp
)
target_link_libraries
(
test_image_to_column PRIVATE utility device_image_to_column_instance
)
add_gtest_executable
(
test_image_to_column_interface test_image_to_column_interface.cpp
)
target_link_libraries
(
test_image_to_column_interface PRIVATE utility
)
Prev
1
…
3
4
5
6
7
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