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
a1841d55
Commit
a1841d55
authored
Aug 01, 2022
by
Chao Liu
Browse files
Merge remote-tracking branch 'origin/develop' into lwpck-367
parents
127bf7f4
500fa995
Changes
373
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
674 additions
and
1558 deletions
+674
-1558
test/convnd_bwd_data/convnd_bwd_data.cpp
test/convnd_bwd_data/convnd_bwd_data.cpp
+220
-310
test/convnd_bwd_weight/CMakeLists.txt
test/convnd_bwd_weight/CMakeLists.txt
+2
-2
test/convnd_bwd_weight/convnd_bwd_weight.cpp
test/convnd_bwd_weight/convnd_bwd_weight.cpp
+172
-250
test/convnd_fwd/CMakeLists.txt
test/convnd_fwd/CMakeLists.txt
+2
-13
test/convnd_fwd/conv1d_fwd.cpp
test/convnd_fwd/conv1d_fwd.cpp
+0
-192
test/convnd_fwd/conv2d_fwd.cpp
test/convnd_fwd/conv2d_fwd.cpp
+0
-266
test/convnd_fwd/conv3d_fwd.cpp
test/convnd_fwd/conv3d_fwd.cpp
+0
-317
test/convnd_fwd/conv_util.hpp
test/convnd_fwd/conv_util.hpp
+0
-174
test/convnd_fwd/convnd_fwd.cpp
test/convnd_fwd/convnd_fwd.cpp
+241
-0
test/gemm/CMakeLists.txt
test/gemm/CMakeLists.txt
+4
-4
test/gemm/gemm_bf16.cpp
test/gemm/gemm_bf16.cpp
+3
-3
test/gemm/gemm_fp16.cpp
test/gemm/gemm_fp16.cpp
+3
-3
test/gemm/gemm_fp32.cpp
test/gemm/gemm_fp32.cpp
+3
-3
test/gemm/gemm_fp64.cpp
test/gemm/gemm_fp64.cpp
+3
-3
test/gemm/gemm_int8.cpp
test/gemm/gemm_int8.cpp
+3
-3
test/gemm/gemm_util.hpp
test/gemm/gemm_util.hpp
+6
-6
test/gemm_reduce/CMakeLists.txt
test/gemm_reduce/CMakeLists.txt
+1
-1
test/gemm_split_k/CMakeLists.txt
test/gemm_split_k/CMakeLists.txt
+1
-1
test/gemm_split_k/gemm_split_k.cpp
test/gemm_split_k/gemm_split_k.cpp
+7
-7
test/grouped_convnd_fwd/CMakeLists.txt
test/grouped_convnd_fwd/CMakeLists.txt
+3
-0
No files found.
test/convnd_bwd_data/convnd_bwd_data.cpp
View file @
a1841d55
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <initializer_list>
#include <cstdlib>
#include <vector>
#include <gtest/gtest.h>
#include "profiler/include/profile_convnd_bwd_data_impl.hpp"
#include "profiler/include/profile_conv_bwd_data_impl.hpp"
class
TestConvndBwdData
:
public
::
testing
::
Test
{
protected:
std
::
vector
<
ck
::
utils
::
conv
::
ConvParam
>
conv_params
;
};
int
main
()
// 1d
TEST_F
(
TestConvndBwdData
,
Conv1dBwdData
)
{
bool
pass
=
true
;
// check 1d
std
::
vector
<
ck
::
utils
::
conv
::
ConvParams
>
params
;
params
.
push_back
({
1
,
128
,
128
,
256
,
{
1
},
{
14
},
{
2
},
{
1
},
{
0
},
{
0
}});
params
.
push_back
({
1
,
128
,
128
,
256
,
{
3
},
{
28
},
{
1
},
{
1
},
{
1
},
{
1
}});
params
.
push_back
({
1
,
128
,
128
,
256
,
{
1
},
{
3
},
{
1
},
{
1
},
{
0
},
{
0
}});
for
(
auto
&
param
:
params
)
conv_params
.
clear
();
conv_params
.
push_back
({
1
,
1
,
128
,
128
,
256
,
{
1
},
{
14
},
{
2
},
{
1
},
{
0
},
{
0
}});
conv_params
.
push_back
({
1
,
1
,
128
,
128
,
256
,
{
3
},
{
28
},
{
1
},
{
1
},
{
1
},
{
1
}});
conv_params
.
push_back
({
1
,
1
,
128
,
128
,
256
,
{
1
},
{
3
},
{
1
},
{
1
},
{
0
},
{
0
}});
for
(
auto
&
param
:
conv_params
)
{
pass
&=
ck
::
profiler
::
profile_convnd_bwd_data_impl
<
1
,
float
,
float
,
float
,
float
,
bool
pass
;
// fp32
pass
=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NWK
,
float
,
float
,
float
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
);
pass
&=
ck
::
profiler
::
profile_convnd_bwd_data_impl
<
1
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
,
float
,
param
);
EXPECT_TRUE
(
pass
);
// fp16
pass
=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NWK
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
);
pass
&=
ck
::
profiler
::
profile_convnd_bwd_data_impl
<
1
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
float
,
param
);
EXPECT_TRUE
(
pass
);
// bf16
pass
=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NWK
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
);
pass
&=
ck
::
profiler
::
profile_convnd_bwd_data_impl
<
1
,
int8_t
,
int8_t
,
int8_t
,
int
,
param
);
EXPECT_TRUE
(
pass
);
// int8
pass
=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NWK
,
int8_t
,
int8_t
,
int8_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
);
param
);
EXPECT_TRUE
(
pass
);
}
}
// check 2d
params
.
clear
();
params
.
push_back
({
2
,
128
,
128
,
256
,
{
1
,
1
},
{
7
,
7
},
{
2
,
2
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
params
.
push_back
({
2
,
128
,
128
,
256
,
{
3
,
3
},
{
14
,
14
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
params
.
push_back
({
2
,
128
,
128
,
256
,
{
1
,
1
},
{
3
,
3
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
// 2d
TEST_F
(
TestConvndBwdData
,
Conv2dBwdData
)
{
conv_params
.
clear
();
conv_params
.
push_back
({
2
,
1
,
128
,
128
,
256
,
{
1
,
1
},
{
7
,
7
},
{
2
,
2
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
conv_params
.
push_back
({
2
,
1
,
128
,
128
,
256
,
{
3
,
3
},
{
14
,
14
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
conv_params
.
push_back
({
2
,
1
,
128
,
128
,
256
,
{
1
,
1
},
{
3
,
3
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
for
(
auto
&
param
:
params
)
for
(
auto
&
param
:
conv_
params
)
{
pass
&=
ck
::
profiler
::
profile_convnd_bwd_data_impl
<
2
,
float
,
float
,
float
,
float
,
bool
pass
;
// fp32
pass
=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NHWK
,
float
,
float
,
float
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
);
pass
&=
ck
::
profiler
::
profile_convnd_bwd_data_impl
<
2
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
,
float
,
param
);
EXPECT_TRUE
(
pass
);
// fp16
pass
=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
);
pass
&=
ck
::
profiler
::
profile_convnd_bwd_data_impl
<
2
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
float
,
param
);
EXPECT_TRUE
(
pass
);
// bf16
pass
=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
);
pass
&=
ck
::
profiler
::
profile_convnd_bwd_data_impl
<
2
,
int8_t
,
int8_t
,
int8_t
,
int
,
param
);
EXPECT_TRUE
(
pass
);
// int8
pass
=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NHWK
,
int8_t
,
int8_t
,
int8_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
);
}
param
);
// check 3d
params
.
clear
();
params
.
push_back
(
{
3
,
128
,
128
,
256
,
{
1
,
1
,
1
},
{
7
,
7
,
7
},
{
2
,
2
,
2
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}});
params
.
push_back
(
{
3
,
128
,
128
,
256
,
{
3
,
3
,
3
},
{
14
,
14
,
14
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
}});
params
.
push_back
(
{
3
,
128
,
128
,
256
,
{
1
,
1
,
1
},
{
3
,
3
,
3
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}});
EXPECT_TRUE
(
pass
);
}
}
for
(
auto
&
param
:
params
)
// 3d
TEST_F
(
TestConvndBwdData
,
Conv3dBwdData
)
{
conv_params
.
clear
();
conv_params
.
push_back
(
{
3
,
1
,
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
,
1
,
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
,
1
,
128
,
128
,
256
,
{
1
,
1
,
1
},
{
3
,
3
,
3
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}});
for
(
auto
&
param
:
conv_params
)
{
pass
&=
ck
::
profiler
::
profile_convnd_bwd_data_impl
<
3
,
float
,
float
,
float
,
float
,
bool
pass
;
// fp32
pass
=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NDHWK
,
float
,
float
,
float
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
);
pass
&=
ck
::
profiler
::
profile_convnd_bwd_data_impl
<
3
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
,
float
,
param
);
EXPECT_TRUE
(
pass
);
// fp16
pass
=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NDHWK
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
);
pass
&=
ck
::
profiler
::
profile_convnd_bwd_data_impl
<
3
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
float
,
param
);
EXPECT_TRUE
(
pass
);
// bf16
pass
=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NDHWK
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
);
pass
&=
ck
::
profiler
::
profile_convnd_bwd_data_impl
<
3
,
int8_t
,
int8_t
,
int8_t
,
int
,
param
);
EXPECT_TRUE
(
pass
);
// int8
pass
=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NDHWK
,
int8_t
,
int8_t
,
int8_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
);
}
param
);
if
(
pass
)
{
std
::
cout
<<
"test convnd bwd : Pass"
<<
std
::
endl
;
return
0
;
}
else
{
std
::
cout
<<
"test convnd bwd: Fail "
<<
std
::
endl
;
return
-
1
;
EXPECT_TRUE
(
pass
);
}
}
test/convnd_bwd_weight/CMakeLists.txt
View file @
a1841d55
add_test_executable
(
test_convnd_bwd_weight convnd_bwd_weight.cpp
)
target_link_libraries
(
test_convnd_bwd_weight PRIVATE
host_tensor
device_conv
n
d_bwd_weight_instance
conv_util
)
add_
g
test_executable
(
test_convnd_bwd_weight convnd_bwd_weight.cpp
)
target_link_libraries
(
test_convnd_bwd_weight PRIVATE
utility device_conv1d_bwd_weight_instance
device_conv
2
d_bwd_weight_instance
device_conv3d_bwd_weight_instance
)
test/convnd_bwd_weight/convnd_bwd_weight.cpp
View file @
a1841d55
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <initializer_list>
#include <cstdlib>
#include <vector>
#include <gtest/gtest.h>
#include "test/convnd_fwd/conv_util.hpp"
#include "profiler/include/profile_convnd_bwd_weight_impl.hpp"
#include "profiler/include/profile_conv_bwd_weight_impl.hpp"
int
test_self
()
class
TestConvndBwdWeight
:
public
::
testing
::
Test
{
bool
pass
=
true
;
std
::
vector
<
ck
::
utils
::
conv
::
ConvParams
>
params
;
protected:
std
::
vector
<
ck
::
utils
::
conv
::
ConvParam
>
conv_params
;
};
params
.
push_back
({
1
,
128
,
256
,
256
,
{
1
},
{
7
},
{
2
},
{
1
},
{
0
},
{
0
}});
params
.
push_back
({
1
,
128
,
256
,
256
,
{
3
},
{
14
},
{
1
},
{
1
},
{
1
},
{
1
}});
params
.
push_back
({
1
,
128
,
256
,
256
,
{
1
},
{
3
},
{
1
},
{
1
},
{
0
},
{
0
}});
// 1d
TEST_F
(
TestConvndBwdWeight
,
Conv1dBwdWeight
)
{
conv_params
.
clear
();
conv_params
.
push_back
({
1
,
1
,
128
,
128
,
256
,
{
1
},
{
14
},
{
2
},
{
1
},
{
0
},
{
0
}});
conv_params
.
push_back
({
1
,
1
,
128
,
128
,
256
,
{
3
},
{
28
},
{
1
},
{
1
},
{
1
},
{
1
}});
conv_params
.
push_back
({
1
,
1
,
128
,
128
,
256
,
{
1
},
{
3
},
{
1
},
{
1
},
{
0
},
{
0
}});
for
(
auto
&
param
:
params
)
for
(
auto
&
param
:
conv_
params
)
{
// f32
pass
&=
ck
::
profiler
::
profile_convnd_bwd_weight_impl
<
1
,
float
,
float
,
float
,
bool
pass
;
// fp32
pass
=
ck
::
profiler
::
profile_conv_bwd_weight_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NWK
,
float
,
float
,
float
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
true
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
,
false
,
// time_kernel
param
,
2
);
EXPECT_TRUE
(
pass
);
// fp16
pass
&=
ck
::
profiler
::
profile_convnd_bwd_weight_impl
<
1
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
,
pass
=
ck
::
profiler
::
profile_conv_bwd_weight_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NWK
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
true
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
,
false
,
// time_kernel
param
,
2
);
EXPECT_TRUE
(
pass
);
// bf16
pass
&=
ck
::
profiler
::
profile_convnd_bwd_weight_impl
<
1
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
pass
=
ck
::
profiler
::
profile_conv_bwd_weight_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NWK
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
true
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
,
false
,
// time_kernel
param
,
2
);
EXPECT_TRUE
(
pass
);
}
}
// check 2d
params
.
clear
();
params
.
push_back
({
2
,
128
,
256
,
256
,
{
1
,
1
},
{
7
,
7
},
{
2
,
2
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
params
.
push_back
({
2
,
128
,
256
,
256
,
{
3
,
3
},
{
14
,
14
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
params
.
push_back
({
2
,
128
,
256
,
256
,
{
1
,
1
},
{
3
,
3
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
// 2d
TEST_F
(
TestConvndBwdWeight
,
Conv2dBwdWeight
)
{
conv_params
.
clear
();
conv_params
.
push_back
({
2
,
1
,
128
,
128
,
256
,
{
1
,
1
},
{
7
,
7
},
{
2
,
2
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
conv_params
.
push_back
({
2
,
1
,
32
,
128
,
256
,
{
3
,
3
},
{
14
,
14
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
conv_params
.
push_back
({
2
,
1
,
128
,
128
,
256
,
{
1
,
1
},
{
3
,
3
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
for
(
auto
&
param
:
params
)
for
(
auto
&
param
:
conv_
params
)
{
// f32
pass
&=
ck
::
profiler
::
profile_convnd_bwd_weight_impl
<
2
,
float
,
float
,
float
,
bool
pass
;
// fp32
pass
=
ck
::
profiler
::
profile_conv_bwd_weight_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NHWK
,
float
,
float
,
float
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
true
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
,
false
,
// time_kernel
param
,
2
);
EXPECT_TRUE
(
pass
);
// fp16
pass
&=
ck
::
profiler
::
profile_convnd_bwd_weight_impl
<
2
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
,
pass
=
ck
::
profiler
::
profile_conv_bwd_weight_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
true
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
,
false
,
// time_kernel
param
,
2
);
EXPECT_TRUE
(
pass
);
// bf16
pass
&=
ck
::
profiler
::
profile_convnd_bwd_weight_impl
<
2
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
pass
=
ck
::
profiler
::
profile_conv_bwd_weight_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
true
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
,
false
,
// time_kernel
param
,
2
);
}
// check 2d
params
.
clear
();
params
.
push_back
(
{
3
,
128
,
256
,
256
,
{
1
,
1
,
1
},
{
4
,
4
,
4
},
{
2
,
2
,
2
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}});
params
.
push_back
(
{
3
,
128
,
256
,
256
,
{
3
,
3
,
3
},
{
4
,
4
,
8
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
}});
params
.
push_back
(
{
3
,
128
,
256
,
256
,
{
1
,
1
,
1
},
{
3
,
3
,
3
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}});
EXPECT_TRUE
(
pass
);
}
}
for
(
auto
&
param
:
params
)
// 3d
TEST_F
(
TestConvndBwdWeight
,
Conv3dBwdWeight
)
{
conv_params
.
clear
();
conv_params
.
push_back
(
{
3
,
1
,
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
,
1
,
32
,
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
,
1
,
128
,
128
,
256
,
{
1
,
1
,
1
},
{
3
,
3
,
3
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}});
for
(
auto
&
param
:
conv_params
)
{
// f32
pass
&=
ck
::
profiler
::
profile_convnd_bwd_weight_impl
<
3
,
float
,
float
,
float
,
bool
pass
;
// fp32
pass
=
ck
::
profiler
::
profile_conv_bwd_weight_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NDHWK
,
float
,
float
,
float
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
true
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
,
false
,
// time_kernel
param
,
2
);
EXPECT_TRUE
(
pass
);
// fp16
pass
&=
ck
::
profiler
::
profile_convnd_bwd_weight_impl
<
3
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
,
pass
=
ck
::
profiler
::
profile_conv_bwd_weight_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NDHWK
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
true
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
,
false
,
// time_kernel
param
,
2
);
EXPECT_TRUE
(
pass
);
// bf16
pass
&=
ck
::
profiler
::
profile_convnd_bwd_weight_impl
<
3
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
pass
=
ck
::
profiler
::
profile_conv_bwd_weight_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
>
(
true
,
// do_verification
ck
::
tensor_layout
::
convolution
::
NDHWK
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
true
,
// time_kernel
param
.
N_
,
param
.
K_
,
param
.
C_
,
param
.
input_spatial_lengths_
,
param
.
filter_spatial_lengths_
,
param
.
GetOutputSpatialLengths
(),
param
.
conv_filter_strides_
,
param
.
conv_filter_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
,
false
,
// time_kernel
param
,
2
);
}
return
pass
;
}
int
main
()
{
// int data_type = 1;
// int init_method = 1;
bool
pass
=
true
;
pass
=
test_self
();
if
(
pass
)
{
std
::
cout
<<
"test conv2d bwd weight : Pass"
<<
std
::
endl
;
return
0
;
}
else
{
std
::
cout
<<
"test conv2d bwd weight: Fail "
<<
std
::
endl
;
return
-
1
;
EXPECT_TRUE
(
pass
);
}
}
test/convnd_fwd/CMakeLists.txt
View file @
a1841d55
add_custom_target
(
test_convnd_fwd
)
add_gtest_executable
(
test_conv1d_fwd conv1d_fwd.cpp
)
target_link_libraries
(
test_conv1d_fwd PRIVATE host_tensor device_conv1d_fwd_instance conv_util
)
add_dependencies
(
test_convnd_fwd test_conv1d_fwd
)
add_gtest_executable
(
test_conv2d_fwd conv2d_fwd.cpp
)
target_link_libraries
(
test_conv2d_fwd PRIVATE host_tensor device_conv2d_fwd_instance device_convnd_2d_fwd_instance conv_util
)
add_dependencies
(
test_convnd_fwd test_conv2d_fwd
)
add_gtest_executable
(
test_conv3d_fwd conv3d_fwd.cpp
)
target_link_libraries
(
test_conv3d_fwd PRIVATE host_tensor device_conv3d_fwd_instance conv_util
)
add_dependencies
(
test_convnd_fwd test_conv3d_fwd
)
add_gtest_executable
(
test_convnd_fwd convnd_fwd.cpp
)
target_link_libraries
(
test_convnd_fwd PRIVATE utility device_conv2d_fwd_instance
)
test/convnd_fwd/conv1d_fwd.cpp
deleted
100644 → 0
View file @
127bf7f4
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <tuple>
#include <vector>
#include <gtest/gtest.h>
#include "ck/utility/data_type.hpp"
#include "ck/tensor_operation/gpu/element/element_wise_operation.hpp"
#include "ck/library/utility/conv_util.hpp"
#include "test/convnd_fwd/conv_util.hpp"
namespace
{
class
Conv1dFwdNWCInstances
:
public
::
testing
::
Test
{
public:
template
<
typename
T
>
bool
test_conv1d_nwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
,
const
ck
::
utils
::
conv
::
ConvParams
&
params
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NWC
,
ctl
::
KXC
,
ctl
::
NWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
1
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
atol_
);
run_engine
.
SetRtol
(
rtol_
);
return
run_engine
.
Test
(
conv_ptrs
);
}
template
<
typename
T
>
bool
test_default
()
{
return
test_conv1d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
1
>(),
params_default_
);
}
template
<
typename
T
>
bool
test_filter1x1_stride1_pad0
()
{
return
test_conv1d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
1
>(),
params_filter1x1_stride1_pad0_
);
}
template
<
typename
T
>
bool
test_filter1x1_pad0
()
{
return
test_conv1d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
1
>(),
params_filter1x1_pad0_
);
}
static
inline
ck
::
utils
::
conv
::
ConvParams
params_default_
{
1
,
4
,
256
,
64
,
{
3
},
{
71
},
{
2
},
{
2
},
{
2
},
{
2
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_stride1_pad0_
{
1
,
4
,
256
,
64
,
{
1
},
{
28
},
{
1
},
{
1
},
{
0
},
{
0
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_pad0_
{
1
,
4
,
256
,
64
,
{
1
},
{
28
},
{
2
},
{
1
},
{
0
},
{
0
}};
private:
double
atol_
{
1e-5
};
double
rtol_
{
1e-4
};
};
}
// anonymous namespace
TEST
(
Conv1DFwdNWC
,
IntegerValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
using
T
=
float
;
ck
::
utils
::
conv
::
ConvParams
params
{
1
,
4
,
256
,
64
,
{
3
},
{
36
},
{
1
},
{
2
},
{
2
},
{
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
1
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NWC
,
ctl
::
KXC
,
ctl
::
NWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
1
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-5
);
run_engine
.
SetRtol
(
1e-4
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST
(
Conv1DFwdNWC
,
FloatingPointValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
using
T
=
ck
::
half_t
;
ck
::
utils
::
conv
::
ConvParams
params
{
1
,
4
,
256
,
64
,
{
3
},
{
36
},
{
1
},
{
2
},
{
2
},
{
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
1
,
T
,
T
,
T
,
float
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NWC
,
ctl
::
KXC
,
ctl
::
NWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistribution
<
T
>
,
FillUniformDistribution
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistribution
<
T
>
{},
FillUniformDistribution
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
1
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
0.1
);
run_engine
.
SetRtol
(
1e-2
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST_F
(
Conv1dFwdNWCInstances
,
BF16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
BF16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
BF16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
half_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F32_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
float
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F32_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
float
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F32_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
float
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
I8_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
int8_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
I8_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
int8_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
I8_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
int8_t
>
());
}
test/convnd_fwd/conv2d_fwd.cpp
deleted
100644 → 0
View file @
127bf7f4
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <tuple>
#include <vector>
#include <gtest/gtest.h>
#include "ck/utility/data_type.hpp"
#include "ck/tensor_operation/gpu/element/element_wise_operation.hpp"
#include "ck/library/utility/conv_util.hpp"
#include "test/convnd_fwd/conv_util.hpp"
namespace
{
class
Conv2dFwdNHWCInstances
:
public
::
testing
::
Test
{
public:
template
<
typename
T
>
bool
test_conv2d_nhwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
,
const
ck
::
utils
::
conv
::
ConvParams
&
params
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
2
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
atol_
);
run_engine
.
SetRtol
(
rtol_
);
return
run_engine
.
Test
(
conv_ptrs
);
}
template
<
typename
T
>
bool
test_default
(
bool
use_convnd
=
false
)
{
if
(
use_convnd
)
{
return
test_conv2d_nhwc_instances
<
T
>
(
test
::
conv
::
ConvolutionNDFwdInstances
<
T
,
T
,
T
>::
Get
(
2
),
params_default_
);
}
else
{
return
test_conv2d_nhwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
2
>(),
params_default_
);
}
}
template
<
typename
T
>
bool
test_filter1x1_stride1_pad0
(
bool
use_convnd
=
false
)
{
if
(
use_convnd
)
{
return
test_conv2d_nhwc_instances
<
T
>
(
test
::
conv
::
ConvolutionNDFwdInstances
<
T
,
T
,
T
>::
Get
(
2
),
params_filter1x1_stride1_pad0_
);
}
else
{
return
test_conv2d_nhwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
2
>(),
params_filter1x1_stride1_pad0_
);
}
}
template
<
typename
T
>
bool
test_filter1x1_pad0
(
bool
use_convnd
=
false
)
{
if
(
use_convnd
)
{
return
test_conv2d_nhwc_instances
<
T
>
(
test
::
conv
::
ConvolutionNDFwdInstances
<
T
,
T
,
T
>::
Get
(
2
),
params_filter1x1_pad0_
);
}
else
{
return
test_conv2d_nhwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
2
>(),
params_filter1x1_pad0_
);
}
}
template
<
typename
T
>
bool
test_oddC
()
{
return
test_conv2d_nhwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
2
>(),
params_oddC_
);
}
static
inline
ck
::
utils
::
conv
::
ConvParams
params_default_
{
2
,
4
,
256
,
64
,
{
3
,
3
},
{
36
,
36
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_stride1_pad0_
{
2
,
4
,
256
,
64
,
{
1
,
1
},
{
28
,
28
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_pad0_
{
2
,
4
,
256
,
64
,
{
1
,
1
},
{
28
,
28
},
{
2
,
2
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_oddC_
{
2
,
4
,
256
,
3
,
{
3
,
3
},
{
28
,
28
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}};
private:
double
atol_
{
1e-5
};
double
rtol_
{
1e-4
};
};
}
// anonymous namespace
TEST
(
Conv2DFwdNHWC
,
IntegerValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
using
T
=
float
;
ck
::
utils
::
conv
::
ConvParams
params
{
2
,
4
,
256
,
64
,
{
3
,
3
},
{
36
,
36
},
{
1
,
1
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
2
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
2
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-5
);
run_engine
.
SetRtol
(
1e-4
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST
(
Conv2DFwdNHWC
,
FloatingPointValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
using
T
=
ck
::
half_t
;
ck
::
utils
::
conv
::
ConvParams
params
{
2
,
4
,
256
,
64
,
{
3
,
3
},
{
36
,
36
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
2
,
T
,
T
,
T
,
float
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistribution
<
T
>
,
FillUniformDistribution
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistribution
<
T
>
{},
FillUniformDistribution
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
2
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
2e-4
);
run_engine
.
SetRtol
(
1e-3
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
BF16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
BF16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
BF16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
half_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F16_oddC
)
{
EXPECT_TRUE
(
this
->
test_oddC
<
ck
::
half_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F32_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
float
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F32_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
float
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F32_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
float
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
I8_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
int8_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
I8_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
int8_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
I8_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
int8_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_BF16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
bhalf_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_BF16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
bhalf_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_BF16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
bhalf_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
half_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
half_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
half_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F32_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
float
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F32_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
float
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F32_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
float
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_I8_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
int8_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_I8_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
int8_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_I8_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
int8_t
>
(
true
));
}
test/convnd_fwd/conv3d_fwd.cpp
deleted
100644 → 0
View file @
127bf7f4
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <stdexcept>
#include <tuple>
#include <vector>
#include <gtest/gtest.h>
#include "ck/utility/data_type.hpp"
#include "ck/tensor_operation/gpu/element/element_wise_operation.hpp"
#include "ck/library/utility/conv_util.hpp"
#include "test/convnd_fwd/conv_util.hpp"
namespace
{
class
Conv3dFwdNDHWCInstances
:
public
::
testing
::
Test
{
public:
template
<
typename
T
>
bool
test_conv3d_nwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
,
const
ck
::
utils
::
conv
::
ConvParams
&
params
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NDHWC
,
ctl
::
KZYXC
,
ctl
::
NDHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
3
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
atol_
);
run_engine
.
SetRtol
(
rtol_
);
return
run_engine
.
Test
(
conv_ptrs
);
}
template
<
typename
T
>
bool
test_default
()
{
return
test_conv3d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
3
>(),
params_default_
);
}
template
<
typename
T
>
bool
test_filter1x1_stride1_pad0
()
{
return
test_conv3d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
3
>(),
params_filter1x1_stride1_pad0_
);
}
template
<
typename
T
>
bool
test_filter1x1_pad0
()
{
return
test_conv3d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
3
>(),
params_filter1x1_pad0_
);
}
static
inline
ck
::
utils
::
conv
::
ConvParams
params_default_
{
3
,
4
,
256
,
64
,
{
3
,
3
,
3
},
{
28
,
28
,
28
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
2
,
2
,
2
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_stride1_pad0_
{
3
,
4
,
256
,
64
,
{
1
,
1
,
1
},
{
28
,
28
,
28
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_pad0_
{
3
,
4
,
256
,
64
,
{
1
,
1
,
1
},
{
28
,
28
,
28
},
{
2
,
2
,
2
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}};
private:
double
atol_
{
1e-5
};
double
rtol_
{
1e-4
};
};
}
// anonymous namespace
TEST
(
Conv3DFwdNDHWC
,
IntegerValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
using
T
=
float
;
ck
::
utils
::
conv
::
ConvParams
params
{
3
,
4
,
256
,
64
,
{
3
,
3
,
3
},
{
18
,
18
,
18
},
{
1
,
1
,
1
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
2
,
2
,
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NDHWC
,
ctl
::
KZYXC
,
ctl
::
NDHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
3
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-5
);
run_engine
.
SetRtol
(
1e-3
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST
(
Conv3DFwdNDHWC
,
FloatingPointValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
using
T
=
ck
::
half_t
;
ck
::
utils
::
conv
::
ConvParams
params
{
3
,
4
,
256
,
64
,
{
3
,
3
,
3
},
{
18
,
18
,
18
},
{
1
,
1
,
1
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
2
,
2
,
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
float
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NDHWC
,
ctl
::
KZYXC
,
ctl
::
NDHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistribution
<
T
>
,
FillUniformDistribution
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistribution
<
T
>
{},
FillUniformDistribution
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
3
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-3
);
run_engine
.
SetRtol
(
1e-3
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST
(
Conv3DFwdNDHWC
,
InputOver2GB
)
{
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
namespace
ck
::
utils
;
using
T
=
float
;
// >2GB Input
conv
::
ConvParams
params
;
params
.
num_dim_spatial_
=
3
;
params
.
N_
=
2
;
params
.
K_
=
16
;
params
.
C_
=
32
;
params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
32
,
1000
,
1000
};
params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
auto
arg
=
conv_ptrs
.
back
()
->
MakeArgumentPointer
(
nullptr
,
nullptr
,
nullptr
,
params
.
N_
,
params
.
K_
,
params
.
C_
,
params
.
input_spatial_lengths_
,
params
.
filter_spatial_lengths_
,
params
.
GetOutputSpatialLengths
(),
params
.
conv_filter_strides_
,
params
.
conv_filter_dilations_
,
params
.
input_left_pads_
,
params
.
input_right_pads_
,
PassThrough
{},
PassThrough
{},
PassThrough
{});
EXPECT_FALSE
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
}
TEST
(
Conv3DFwdNDHWC
,
FiltersOver2GB
)
{
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
namespace
ck
::
utils
;
using
T
=
float
;
// >2GB Filters
conv
::
ConvParams
params
;
params
.
num_dim_spatial_
=
3
;
params
.
N_
=
2
;
params
.
K_
=
16
;
params
.
C_
=
32
;
params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
4
,
1000
,
1000
};
params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
16
,
16
,
16
};
params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
auto
arg
=
conv_ptrs
.
back
()
->
MakeArgumentPointer
(
nullptr
,
nullptr
,
nullptr
,
params
.
N_
,
params
.
K_
,
params
.
C_
,
params
.
input_spatial_lengths_
,
params
.
filter_spatial_lengths_
,
params
.
GetOutputSpatialLengths
(),
params
.
conv_filter_strides_
,
params
.
conv_filter_dilations_
,
params
.
input_left_pads_
,
params
.
input_right_pads_
,
PassThrough
{},
PassThrough
{},
PassThrough
{});
EXPECT_FALSE
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
}
TEST
(
Conv3DFwdNDHWC
,
OutputOver2GB
)
{
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
namespace
ck
::
utils
;
using
T
=
float
;
// >2GB Output
conv
::
ConvParams
params
;
params
.
num_dim_spatial_
=
3
;
params
.
N_
=
2
;
params
.
K_
=
16
;
params
.
C_
=
2
;
params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
1000
,
1000
,
30
};
params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
auto
arg
=
conv_ptrs
.
back
()
->
MakeArgumentPointer
(
nullptr
,
nullptr
,
nullptr
,
params
.
N_
,
params
.
K_
,
params
.
C_
,
params
.
input_spatial_lengths_
,
params
.
filter_spatial_lengths_
,
params
.
GetOutputSpatialLengths
(),
params
.
conv_filter_strides_
,
params
.
conv_filter_dilations_
,
params
.
input_left_pads_
,
params
.
input_right_pads_
,
PassThrough
{},
PassThrough
{},
PassThrough
{});
EXPECT_FALSE
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
BF16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
BF16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
BF16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
half_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F32_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
float
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F32_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
float
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F32_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
float
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
I8_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
int8_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
I8_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
int8_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
I8_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
int8_t
>
());
}
test/convnd_fwd/conv_util.hpp
deleted
100644 → 0
View file @
127bf7f4
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#pragma once
#include <tuple>
#include "ck/ck.hpp"
#include "ck/utility/sequence.hpp"
#include "ck/utility/data_type.hpp"
#include "ck/tensor_operation/gpu/device/device_convnd_fwd_xdl_nhwc_kyxc_nhwk.hpp"
#include "ck/tensor_operation/gpu/element/element_wise_operation.hpp"
#include "ck/library/host_tensor/host_tensor.hpp"
namespace
ck
{
namespace
tensor_operation
{
namespace
device
{
using
DeviceConvFwdNoOpPtr
=
DeviceConvFwdPtr
<
element_wise
::
PassThrough
,
element_wise
::
PassThrough
,
element_wise
::
PassThrough
>
;
namespace
instance
{
void
add_device_convnd_2d_fwd_xdl_nhwc_kyxc_nhwk_bf16_instances
(
std
::
vector
<
DeviceConvFwdNoOpPtr
>&
);
void
add_device_convnd_2d_fwd_xdl_nhwc_kyxc_nhwk_f16_instances
(
std
::
vector
<
DeviceConvFwdNoOpPtr
>&
);
void
add_device_convnd_2d_fwd_xdl_nhwc_kyxc_nhwk_f32_instances
(
std
::
vector
<
DeviceConvFwdNoOpPtr
>&
);
void
add_device_convnd_2d_fwd_xdl_nhwc_kyxc_nhwk_int8_instances
(
std
::
vector
<
DeviceConvFwdNoOpPtr
>&
);
}
// namespace instance
}
// namespace device
}
// namespace tensor_operation
}
// namespace ck
namespace
test
{
namespace
conv
{
template
<
ck
::
index_t
...
Is
>
using
S
=
ck
::
Sequence
<
Is
...
>
;
using
InElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
WeiElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
OutElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
DeviceConvFwdNoOpPtr
=
ck
::
tensor_operation
::
device
::
DeviceConvFwdPtr
<
InElementOp
,
WeiElementOp
,
OutElementOp
>
;
static
constexpr
auto
ConvFwdDefault
=
ck
::
tensor_operation
::
device
::
ConvolutionForwardSpecialization
::
Default
;
template
<
ck
::
index_t
SpatialDims
,
typename
InDataType
,
typename
WeiDataType
,
typename
OutDataType
,
typename
AccDataType
>
using
DeviceConvNDFwdInstance
=
ck
::
tensor_operation
::
device
::
DeviceConvNDFwdXdl_Input_N_Hi_Wi_C_Weight_K_Y_X_C_Output_N_Ho_Wo_K
<
// clang-format off
InDataType
,
//
WeiDataType
,
//
OutDataType
,
//
AccDataType
,
// Accumulator data type.
InElementOp
,
// Input Elementwise Operation
WeiElementOp
,
// Weights Elementwise Operation
OutElementOp
,
// Output Elementwise Operation
ConvFwdDefault
,
// ConvForwardSpecialization
SpatialDims
,
// SptialDims
256
,
// BlockSize
128
,
// MPerBlock
256
,
// NPerBlock
4
,
// K0PerBlock
8
,
// K1
32
,
// MPerXdl
32
,
// NPerXdl
2
,
// MXdlPerWave
4
,
// NXdlPerWave
S
<
4
,
64
,
1
>
,
// ABlockTransferThreadClusterLengths_K0_M_K1
S
<
1
,
0
,
2
>
,
// ABlockTransferThreadClusterArrangeOrder
S
<
1
,
0
,
2
>
,
// ABlockTransferSrcAccessOrder
2
,
// ABlockTransferSrcVectorDim
8
,
// ABlockTransferSrcScalarPerVector
8
,
// ABlockTransferDstScalarPerVector_K1
true
,
// ABlockLdsAddExtraM
S
<
4
,
64
,
1
>
,
// BBlockTransferThreadClusterLengths_K0_N_K1
S
<
1
,
0
,
2
>
,
// BBlockTransferThreadClusterArrangeOrder
S
<
1
,
0
,
2
>
,
// BBlockTransferSrcAccessOrder
2
,
// BBlockTransferSrcVectorDim
8
,
// BBlockTransferSrcScalarPerVector
8
,
// BBlockTransferDstScalarPerVector_K1
true
,
// BBlockLdsAddExtraN
7
,
// CThreadTransferSrcDstVectorDim
1
>
;
// CThreadTransferDstScalarPerVector
// clang-format on
template
<
ck
::
index_t
NDim
,
typename
InDataType
,
typename
WeiDataType
,
typename
OutDataType
,
typename
AccDataType
>
void
get_test_convolution_fwd_instance
(
std
::
vector
<
DeviceConvFwdNoOpPtr
>&
instances
)
{
using
ConvInstanceT
=
DeviceConvNDFwdInstance
<
NDim
,
InDataType
,
WeiDataType
,
OutDataType
,
AccDataType
>
;
instances
.
emplace_back
(
std
::
make_unique
<
ConvInstanceT
>
());
}
// TODO (aosewski)
// Temporary solution to get all DeviceConvNDFwdXdl_Input_N_Hi_Wi_C_Weight_K_Y_X_C_Output_N_Ho_Wo_K
// instances. When switched over to DeviceConvNDFwdXdl for 2D remove ConvolutionNDFwdInstances
// structures.
template
<
typename
InDataType
,
typename
WeiDataType
,
typename
OutDataType
>
struct
ConvolutionNDFwdInstances
;
template
<
>
struct
ConvolutionNDFwdInstances
<
float
,
float
,
float
>
{
static
std
::
vector
<
DeviceConvFwdNoOpPtr
>
Get
(
std
::
size_t
num_dim_spatial
)
{
std
::
vector
<
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
if
(
num_dim_spatial
==
2
)
{
ck
::
tensor_operation
::
device
::
instance
::
add_device_convnd_2d_fwd_xdl_nhwc_kyxc_nhwk_f32_instances
(
conv_ptrs
);
}
return
conv_ptrs
;
}
};
template
<
>
struct
ConvolutionNDFwdInstances
<
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>
{
static
std
::
vector
<
DeviceConvFwdNoOpPtr
>
Get
(
std
::
size_t
num_dim_spatial
)
{
std
::
vector
<
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
if
(
num_dim_spatial
==
2
)
{
ck
::
tensor_operation
::
device
::
instance
::
add_device_convnd_2d_fwd_xdl_nhwc_kyxc_nhwk_f16_instances
(
conv_ptrs
);
}
return
conv_ptrs
;
}
};
template
<
>
struct
ConvolutionNDFwdInstances
<
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>
{
static
std
::
vector
<
DeviceConvFwdNoOpPtr
>
Get
(
std
::
size_t
num_dim_spatial
)
{
std
::
vector
<
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
if
(
num_dim_spatial
==
2
)
{
ck
::
tensor_operation
::
device
::
instance
::
add_device_convnd_2d_fwd_xdl_nhwc_kyxc_nhwk_bf16_instances
(
conv_ptrs
);
}
return
conv_ptrs
;
}
};
template
<
>
struct
ConvolutionNDFwdInstances
<
int8_t
,
int8_t
,
int8_t
>
{
static
std
::
vector
<
DeviceConvFwdNoOpPtr
>
Get
(
std
::
size_t
num_dim_spatial
)
{
std
::
vector
<
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
if
(
num_dim_spatial
==
2
)
{
ck
::
tensor_operation
::
device
::
instance
::
add_device_convnd_2d_fwd_xdl_nhwc_kyxc_nhwk_int8_instances
(
conv_ptrs
);
}
return
conv_ptrs
;
}
};
}
// namespace conv
}
// namespace test
test/convnd_fwd/convnd_fwd.cpp
0 → 100644
View file @
a1841d55
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <cstdlib>
#include <iostream>
#include <initializer_list>
#include <vector>
#include <gtest/gtest.h>
#include "profiler/include/profile_conv_fwd_impl.hpp"
class
TestConvndFwd
:
public
::
testing
::
Test
{
protected:
std
::
vector
<
ck
::
utils
::
conv
::
ConvParam
>
conv_params
;
};
// 1d
TEST_F
(
TestConvndFwd
,
Conv1dFwd
)
{
conv_params
.
clear
();
conv_params
.
push_back
({
1
,
1
,
128
,
128
,
256
,
{
1
},
{
14
},
{
2
},
{
1
},
{
0
},
{
0
}});
conv_params
.
push_back
({
1
,
1
,
128
,
128
,
256
,
{
3
},
{
28
},
{
1
},
{
1
},
{
1
},
{
1
}});
conv_params
.
push_back
({
1
,
1
,
128
,
128
,
256
,
{
1
},
{
3
},
{
1
},
{
1
},
{
0
},
{
0
}});
for
(
auto
&
param
:
conv_params
)
{
bool
pass
;
// fp32
pass
=
ck
::
profiler
::
profile_conv_fwd_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
,
float
,
float
,
float
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
// fp16
pass
=
ck
::
profiler
::
profile_conv_fwd_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
,
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_conv_fwd_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
,
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_conv_fwd_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
,
int8_t
,
int8_t
,
int8_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
}
}
// 2d
TEST_F
(
TestConvndFwd
,
Conv2dFwd
)
{
conv_params
.
clear
();
conv_params
.
push_back
({
2
,
1
,
128
,
128
,
256
,
{
1
,
1
},
{
7
,
7
},
{
2
,
2
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
conv_params
.
push_back
({
2
,
1
,
128
,
128
,
256
,
{
3
,
3
},
{
14
,
14
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
conv_params
.
push_back
({
2
,
1
,
128
,
128
,
256
,
{
1
,
1
},
{
3
,
3
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
for
(
auto
&
param
:
conv_params
)
{
bool
pass
;
// fp32
pass
=
ck
::
profiler
::
profile_conv_fwd_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
float
,
float
,
float
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
// fp16
pass
=
ck
::
profiler
::
profile_conv_fwd_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
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_conv_fwd_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
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_conv_fwd_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
int8_t
,
int8_t
,
int8_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
}
}
// 3d
TEST_F
(
TestConvndFwd
,
Conv3dFwd
)
{
conv_params
.
clear
();
conv_params
.
push_back
(
{
3
,
1
,
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
,
1
,
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
,
1
,
128
,
128
,
256
,
{
1
,
1
,
1
},
{
3
,
3
,
3
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}});
for
(
auto
&
param
:
conv_params
)
{
bool
pass
;
// fp32
pass
=
ck
::
profiler
::
profile_conv_fwd_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
,
float
,
float
,
float
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
// fp16
pass
=
ck
::
profiler
::
profile_conv_fwd_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
,
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_conv_fwd_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
,
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_conv_fwd_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
,
int8_t
,
int8_t
,
int8_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
EXPECT_TRUE
(
pass
);
}
}
test/gemm/CMakeLists.txt
View file @
a1841d55
add_test_executable
(
test_gemm_fp32 gemm_fp32.cpp
)
target_link_libraries
(
test_gemm_fp32 PRIVATE
host_tensor
)
target_link_libraries
(
test_gemm_fp32 PRIVATE
utility
)
target_link_libraries
(
test_gemm_fp32 PRIVATE device_gemm_instance
)
add_test_executable
(
test_gemm_fp16 gemm_fp16.cpp
)
target_link_libraries
(
test_gemm_fp16 PRIVATE
host_tensor
)
target_link_libraries
(
test_gemm_fp16 PRIVATE
utility
)
target_link_libraries
(
test_gemm_fp16 PRIVATE device_gemm_instance
)
add_test_executable
(
test_gemm_bf16 gemm_bf16.cpp
)
target_link_libraries
(
test_gemm_bf16 PRIVATE
host_tensor
)
target_link_libraries
(
test_gemm_bf16 PRIVATE
utility
)
target_link_libraries
(
test_gemm_bf16 PRIVATE device_gemm_instance
)
add_test_executable
(
test_gemm_int8 gemm_int8.cpp
)
target_link_libraries
(
test_gemm_int8 PRIVATE
host_tensor
)
target_link_libraries
(
test_gemm_int8 PRIVATE
utility
)
target_link_libraries
(
test_gemm_int8 PRIVATE device_gemm_instance
)
test/gemm/gemm_bf16.cpp
View file @
a1841d55
...
...
@@ -17,9 +17,9 @@
#include "ck/library/tensor_operation_instance/gpu/gemm.hpp"
#include "ck/library/utility/check_err.hpp"
#include "ck/library/
host_tensor
/device_memory.hpp"
#include "ck/library/
host_tensor
/host_tensor.hpp"
#include "ck/library/
host_tensor
/host_tensor_generator.hpp"
#include "ck/library/
utility
/device_memory.hpp"
#include "ck/library/
utility
/host_tensor.hpp"
#include "ck/library/
utility
/host_tensor_generator.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
#include "test/gemm/gemm_util.hpp"
...
...
test/gemm/gemm_fp16.cpp
View file @
a1841d55
...
...
@@ -17,9 +17,9 @@
#include "ck/library/tensor_operation_instance/gpu/gemm.hpp"
#include "ck/library/utility/check_err.hpp"
#include "ck/library/
host_tensor
/device_memory.hpp"
#include "ck/library/
host_tensor
/host_tensor.hpp"
#include "ck/library/
host_tensor
/host_tensor_generator.hpp"
#include "ck/library/
utility
/device_memory.hpp"
#include "ck/library/
utility
/host_tensor.hpp"
#include "ck/library/
utility
/host_tensor_generator.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
#include "test/gemm/gemm_util.hpp"
...
...
test/gemm/gemm_fp32.cpp
View file @
a1841d55
...
...
@@ -17,9 +17,9 @@
#include "ck/library/tensor_operation_instance/gpu/gemm.hpp"
#include "ck/library/utility/check_err.hpp"
#include "ck/library/
host_tensor
/device_memory.hpp"
#include "ck/library/
host_tensor
/host_tensor.hpp"
#include "ck/library/
host_tensor
/host_tensor_generator.hpp"
#include "ck/library/
utility
/device_memory.hpp"
#include "ck/library/
utility
/host_tensor.hpp"
#include "ck/library/
utility
/host_tensor_generator.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
#include "test/gemm/gemm_util.hpp"
...
...
test/gemm/gemm_fp64.cpp
View file @
a1841d55
...
...
@@ -17,9 +17,9 @@
#include "ck/library/tensor_operation_instance/gpu/gemm.hpp"
#include "ck/library/utility/check_err.hpp"
#include "ck/library/
host_tensor
/device_memory.hpp"
#include "ck/library/
host_tensor
/host_tensor.hpp"
#include "ck/library/
host_tensor
/host_tensor_generator.hpp"
#include "ck/library/
utility
/device_memory.hpp"
#include "ck/library/
utility
/host_tensor.hpp"
#include "ck/library/
utility
/host_tensor_generator.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
#include "test/gemm/gemm_util.hpp"
...
...
test/gemm/gemm_int8.cpp
View file @
a1841d55
...
...
@@ -17,9 +17,9 @@
#include "ck/library/tensor_operation_instance/gpu/gemm.hpp"
#include "ck/library/utility/check_err.hpp"
#include "ck/library/
host_tensor
/device_memory.hpp"
#include "ck/library/
host_tensor
/host_tensor.hpp"
#include "ck/library/
host_tensor
/host_tensor_generator.hpp"
#include "ck/library/
utility
/device_memory.hpp"
#include "ck/library/
utility
/host_tensor.hpp"
#include "ck/library/
utility
/host_tensor_generator.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
#include "test/gemm/gemm_util.hpp"
...
...
test/gemm/gemm_util.hpp
View file @
a1841d55
...
...
@@ -6,9 +6,9 @@
#include "ck/ck.hpp"
#include "ck/tensor_operation/gpu/device/tensor_layout.hpp"
#include "ck/library/utility/check_err.hpp"
#include "ck/library/
host_tensor
/device_memory.hpp"
#include "ck/library/
host_tensor
/host_tensor.hpp"
#include "ck/library/
host_tensor
/host_tensor_generator.hpp"
#include "ck/library/
utility
/device_memory.hpp"
#include "ck/library/
utility
/host_tensor.hpp"
#include "ck/library/
utility
/host_tensor_generator.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
namespace
ck
{
...
...
@@ -71,9 +71,9 @@ bool RunDeviceGEMM(DeviceGemmPtr_& gemmPtr,
BElementwiseOperation
b_element_op
,
CElementwiseOperation
c_element_op
)
{
DeviceMem
a_m_k_device_buf
(
sizeof
(
ADataType
)
*
A
.
mDesc
.
GetElementSpace
());
DeviceMem
b_k_n_device_buf
(
sizeof
(
BDataType
)
*
B
.
mDesc
.
GetElementSpace
());
DeviceMem
c_m_n_device_buf
(
sizeof
(
CDataType
)
*
C
.
mDesc
.
GetElementSpace
());
DeviceMem
a_m_k_device_buf
(
sizeof
(
ADataType
)
*
A
.
mDesc
.
GetElementSpace
Size
());
DeviceMem
b_k_n_device_buf
(
sizeof
(
BDataType
)
*
B
.
mDesc
.
GetElementSpace
Size
());
DeviceMem
c_m_n_device_buf
(
sizeof
(
CDataType
)
*
C
.
mDesc
.
GetElementSpace
Size
());
auto
invoker_ptr
=
gemmPtr
->
MakeInvokerPointer
();
auto
argument_ptr
=
...
...
test/gemm_reduce/CMakeLists.txt
View file @
a1841d55
add_test_executable
(
test_gemm_reduce_fp16 gemm_reduce_fp16.cpp
)
target_link_libraries
(
test_gemm_reduce_fp16 PRIVATE
host_tensor
)
target_link_libraries
(
test_gemm_reduce_fp16 PRIVATE
utility
)
target_link_libraries
(
test_gemm_reduce_fp16 PRIVATE device_gemm_reduce_instance
)
test/gemm_split_k/CMakeLists.txt
View file @
a1841d55
add_test_executable
(
test_gemm_split_k gemm_split_k.cpp
)
target_link_libraries
(
test_gemm_split_k PRIVATE
host_tensor
)
target_link_libraries
(
test_gemm_split_k PRIVATE
utility
)
target_link_libraries
(
test_gemm_split_k PRIVATE device_gemm_splitk_instance
)
test/gemm_split_k/gemm_split_k.cpp
View file @
a1841d55
...
...
@@ -14,12 +14,12 @@
#include "ck/library/tensor_operation_instance/gpu/gemm_splitk.hpp"
#include "ck/library/utility/check_err.hpp"
#include "ck/library/
host_tensor
/device_memory.hpp"
#include "ck/library/
host_tensor
/host_tensor.hpp"
#include "ck/library/
host_tensor
/host_tensor_generator.hpp"
#include "ck/library/
utility
/device_memory.hpp"
#include "ck/library/
utility
/host_tensor.hpp"
#include "ck/library/
utility
/host_tensor_generator.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
#include "ck/library/
host_tensor
/host_gemm.hpp"
#include "ck/library/
utility
/host_gemm.hpp"
enum
struct
GemmMatrixLayout
{
...
...
@@ -127,9 +127,9 @@ int test_gemm(const gemmArgs& args)
ck
::
tensor_operation
::
element_wise
::
PassThrough
{},
ck
::
tensor_operation
::
element_wise
::
PassThrough
{});
DeviceMem
a_device_buf
(
sizeof
(
float
)
*
a_m_k
.
mDesc
.
GetElementSpace
());
DeviceMem
b_device_buf
(
sizeof
(
float
)
*
b_k_n
.
mDesc
.
GetElementSpace
());
DeviceMem
c_device_buf
(
sizeof
(
float
)
*
c_m_n_device_result
.
mDesc
.
GetElementSpace
());
DeviceMem
a_device_buf
(
sizeof
(
float
)
*
a_m_k
.
mDesc
.
GetElementSpace
Size
());
DeviceMem
b_device_buf
(
sizeof
(
float
)
*
b_k_n
.
mDesc
.
GetElementSpace
Size
());
DeviceMem
c_device_buf
(
sizeof
(
float
)
*
c_m_n_device_result
.
mDesc
.
GetElementSpace
Size
());
a_device_buf
.
ToDevice
(
a_m_k
.
mData
.
data
());
b_device_buf
.
ToDevice
(
b_k_n
.
mData
.
data
());
...
...
test/grouped_convnd_fwd/CMakeLists.txt
0 → 100644
View file @
a1841d55
add_gtest_executable
(
test_grouped_convnd_fwd 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
)
Prev
1
…
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