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
d0b9a467
Commit
d0b9a467
authored
May 04, 2022
by
Chao Liu
Browse files
Merge remote-tracking branch 'origin/develop' into improve_pipeline
parents
c8f6d5d1
8eca05a6
Changes
37
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
801 additions
and
872 deletions
+801
-872
library/src/tensor_operation_instance/gpu/gemm_reduce/device_gemm_reduce_xdl_cshuffle_f16_f16_f16_f32_f32_km_kn_mn_instance.cpp
...ce_xdl_cshuffle_f16_f16_f16_f32_f32_km_kn_mn_instance.cpp
+22
-24
library/src/tensor_operation_instance/gpu/gemm_reduce/device_gemm_reduce_xdl_cshuffle_f16_f16_f16_f32_f32_km_nk_mn_instance.cpp
...ce_xdl_cshuffle_f16_f16_f16_f32_f32_km_nk_mn_instance.cpp
+22
-24
library/src/tensor_operation_instance/gpu/gemm_reduce/device_gemm_reduce_xdl_cshuffle_f16_f16_f16_f32_f32_mk_kn_mn_instance.cpp
...ce_xdl_cshuffle_f16_f16_f16_f32_f32_mk_kn_mn_instance.cpp
+22
-24
library/src/tensor_operation_instance/gpu/gemm_reduce/device_gemm_reduce_xdl_cshuffle_f16_f16_f16_f32_f32_mk_nk_mn_instance.cpp
...ce_xdl_cshuffle_f16_f16_f16_f32_f32_mk_nk_mn_instance.cpp
+19
-21
profiler/include/profile_batched_gemm_reduce_impl.hpp
profiler/include/profile_batched_gemm_reduce_impl.hpp
+25
-21
profiler/include/profile_gemm_reduce_impl.hpp
profiler/include/profile_gemm_reduce_impl.hpp
+25
-21
script/clang-format-overwrite.sh
script/clang-format-overwrite.sh
+2
-2
test/CMakeLists.txt
test/CMakeLists.txt
+15
-0
test/conv_util/CMakeLists.txt
test/conv_util/CMakeLists.txt
+1
-1
test/conv_util/conv_util.cpp
test/conv_util/conv_util.cpp
+111
-112
test/convnd_fwd/CMakeLists.txt
test/convnd_fwd/CMakeLists.txt
+3
-5
test/convnd_fwd/conv1d_fwd.cpp
test/convnd_fwd/conv1d_fwd.cpp
+39
-60
test/convnd_fwd/conv2d_fwd.cpp
test/convnd_fwd/conv2d_fwd.cpp
+41
-56
test/convnd_fwd/conv3d_fwd.cpp
test/convnd_fwd/conv3d_fwd.cpp
+48
-79
test/gemm/gemm_util.hpp
test/gemm/gemm_util.hpp
+333
-340
test/reference_conv_fwd/CMakeLists.txt
test/reference_conv_fwd/CMakeLists.txt
+1
-1
test/reference_conv_fwd/reference_conv_fwd.cpp
test/reference_conv_fwd/reference_conv_fwd.cpp
+72
-81
No files found.
library/src/tensor_operation_instance/gpu/gemm_reduce/device_gemm_reduce_xdl_cshuffle_f16_f16_f16_f32_f32_km_kn_mn_instance.cpp
View file @
d0b9a467
This diff is collapsed.
Click to expand it.
library/src/tensor_operation_instance/gpu/gemm_reduce/device_gemm_reduce_xdl_cshuffle_f16_f16_f16_f32_f32_km_nk_mn_instance.cpp
View file @
d0b9a467
This diff is collapsed.
Click to expand it.
library/src/tensor_operation_instance/gpu/gemm_reduce/device_gemm_reduce_xdl_cshuffle_f16_f16_f16_f32_f32_mk_kn_mn_instance.cpp
View file @
d0b9a467
This diff is collapsed.
Click to expand it.
library/src/tensor_operation_instance/gpu/gemm_reduce/device_gemm_reduce_xdl_cshuffle_f16_f16_f16_f32_f32_mk_nk_mn_instance.cpp
View file @
d0b9a467
This diff is collapsed.
Click to expand it.
profiler/include/profile_batched_gemm_reduce_impl.hpp
View file @
d0b9a467
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
#include "tensor_layout.hpp"
#include "tensor_layout.hpp"
#include "device_tensor.hpp"
#include "device_tensor.hpp"
#include "element_wise_operation.hpp"
#include "element_wise_operation.hpp"
#include "
element_wise_
reduc
e
_operat
ion
.hpp"
#include "reduc
tion
_operat
or
.hpp"
#include "device_gemm_reduce.hpp"
#include "device_gemm_reduce.hpp"
#include "reference_batched_gemm.hpp"
#include "reference_batched_gemm.hpp"
...
@@ -21,8 +21,7 @@ using DeviceGemmReduceNoOpPtr = ck::tensor_operation::device::DeviceGemmReducePt
...
@@ -21,8 +21,7 @@ using DeviceGemmReduceNoOpPtr = ck::tensor_operation::device::DeviceGemmReducePt
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
ReduceSum
,
ck
::
tensor_operation
::
element_wise
::
UnarySquare
<
float
,
float
,
false
>>
;
ck
::
tensor_operation
::
element_wise
::
ReduceSquareSum
>
;
void
add_device_batched_gemm_reduce_xdl_cshuffle_f16_f16_f16_f32_f32_gmk_gkn_gmn_instances
(
void
add_device_batched_gemm_reduce_xdl_cshuffle_f16_f16_f16_f32_f32_gmk_gkn_gmn_instances
(
std
::
vector
<
DeviceGemmReduceNoOpPtr
>&
);
std
::
vector
<
DeviceGemmReduceNoOpPtr
>&
);
...
@@ -123,14 +122,16 @@ bool profile_batched_gemm_reduce_impl(int do_verification,
...
@@ -123,14 +122,16 @@ bool profile_batched_gemm_reduce_impl(int do_verification,
using
AElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
AElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
BElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
BElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
CElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
CElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
D0ReduceOp
=
ck
::
tensor_operation
::
element_wise
::
ReduceSum
;
using
D0ReduceOp
=
ck
::
reduce
::
Add
<
float
>
;
using
D1ReduceOp
=
ck
::
tensor_operation
::
element_wise
::
ReduceSquareSum
;
using
D1ReduceOp
=
ck
::
reduce
::
Add
<
float
>
;
using
D1ElementOp
=
ck
::
tensor_operation
::
element_wise
::
UnarySquare
<
float
,
float
,
false
>
;
const
auto
a_element_op
=
AElementOp
{};
const
auto
a_element_op
=
AElementOp
{};
const
auto
b_element_op
=
BElementOp
{};
const
auto
b_element_op
=
BElementOp
{};
const
auto
c_element_op
=
CElementOp
{};
const
auto
c_element_op
=
CElementOp
{};
const
auto
d0_reduce_op
=
D0ReduceOp
{};
const
auto
d0_reduce_op
=
D0ReduceOp
{};
const
auto
d1_reduce_op
=
D1ReduceOp
{};
const
auto
d1_reduce_op
=
D1ReduceOp
{};
const
auto
d1_element_op
=
D1ElementOp
{};
if
(
do_verification
)
if
(
do_verification
)
{
{
...
@@ -154,17 +155,21 @@ bool profile_batched_gemm_reduce_impl(int do_verification,
...
@@ -154,17 +155,21 @@ bool profile_batched_gemm_reduce_impl(int do_verification,
{
{
for
(
int
m
=
0
;
m
<
M
;
++
m
)
for
(
int
m
=
0
;
m
<
M
;
++
m
)
{
{
float
d0_acc
=
d0_reduce_op
.
GetReduc
e
ZeroVal
ue
();
float
d0_acc
=
d0_reduce_op
.
GetReduc
tion
ZeroVal
();
float
d1_acc
=
d1_reduce_op
.
GetReduc
e
ZeroVal
ue
();
float
d1_acc
=
d1_reduce_op
.
GetReduc
tion
ZeroVal
();
for
(
int
n
=
0
;
n
<
N
;
++
n
)
for
(
int
n
=
0
;
n
<
N
;
++
n
)
{
{
d0_reduce_op
.
Reduce
(
d0_acc
,
c_g_m_n_host_result
(
batch
,
m
,
n
));
float
d0_val
=
ck
::
type_convert
<
float
>
(
c_g_m_n_host_result
(
batch
,
m
,
n
));
d1_reduce_op
.
Reduce
(
d1_acc
,
c_g_m_n_host_result
(
batch
,
m
,
n
));
float
d1_val
;
d1_element_op
(
d1_val
,
d0_val
);
d0_reduce_op
(
d0_acc
,
d0_val
);
d1_reduce_op
(
d1_acc
,
d1_val
);
}
}
d0_g_m_host_result
(
batch
,
m
)
=
d0_acc
;
d0_g_m_host_result
(
batch
,
m
)
=
ck
::
type_convert
<
DDataType
>
(
d0_acc
)
;
d1_g_m_host_result
(
batch
,
m
)
=
d1_acc
;
d1_g_m_host_result
(
batch
,
m
)
=
ck
::
type_convert
<
DDataType
>
(
d1_acc
)
;
}
}
}
}
}
}
...
@@ -247,8 +252,7 @@ bool profile_batched_gemm_reduce_impl(int do_verification,
...
@@ -247,8 +252,7 @@ bool profile_batched_gemm_reduce_impl(int do_verification,
a_element_op
,
a_element_op
,
b_element_op
,
b_element_op
,
c_element_op
,
c_element_op
,
d0_reduce_op
,
d1_element_op
,
d1_reduce_op
,
BatchCount
);
BatchCount
);
auto
invoker_ptr
=
gemm_ptr
->
MakeInvokerPointer
();
auto
invoker_ptr
=
gemm_ptr
->
MakeInvokerPointer
();
...
...
profiler/include/profile_gemm_reduce_impl.hpp
View file @
d0b9a467
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#include "tensor_layout.hpp"
#include "tensor_layout.hpp"
#include "device_tensor.hpp"
#include "device_tensor.hpp"
#include "element_wise_operation.hpp"
#include "element_wise_operation.hpp"
#include "
element_wise_
reduc
e
_operat
ion
.hpp"
#include "reduc
tion
_operat
or
.hpp"
#include "device_gemm_reduce.hpp"
#include "device_gemm_reduce.hpp"
#include "reference_gemm.hpp"
#include "reference_gemm.hpp"
...
@@ -20,8 +20,7 @@ using DeviceGemmReduceNoOpPtr = ck::tensor_operation::device::DeviceGemmReducePt
...
@@ -20,8 +20,7 @@ using DeviceGemmReduceNoOpPtr = ck::tensor_operation::device::DeviceGemmReducePt
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
ReduceSum
,
ck
::
tensor_operation
::
element_wise
::
UnarySquare
<
float
,
float
,
false
>>
;
ck
::
tensor_operation
::
element_wise
::
ReduceSquareSum
>
;
void
add_device_gemm_reduce_xdl_cshuffle_f16_f16_f16_f32_f32_mk_kn_mn_instances
(
void
add_device_gemm_reduce_xdl_cshuffle_f16_f16_f16_f32_f32_mk_kn_mn_instances
(
std
::
vector
<
DeviceGemmReduceNoOpPtr
>&
);
std
::
vector
<
DeviceGemmReduceNoOpPtr
>&
);
...
@@ -116,14 +115,16 @@ bool profile_gemm_reduce_impl(int do_verification,
...
@@ -116,14 +115,16 @@ bool profile_gemm_reduce_impl(int do_verification,
using
AElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
AElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
BElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
BElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
CElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
CElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
D0ReduceOp
=
ck
::
tensor_operation
::
element_wise
::
ReduceSum
;
using
D0ReduceOp
=
ck
::
reduce
::
Add
<
float
>
;
using
D1ReduceOp
=
ck
::
tensor_operation
::
element_wise
::
ReduceSquareSum
;
using
D1ReduceOp
=
ck
::
reduce
::
Add
<
float
>
;
using
D1ElementOp
=
ck
::
tensor_operation
::
element_wise
::
UnarySquare
<
float
,
float
,
false
>
;
const
auto
a_element_op
=
AElementOp
{};
const
auto
a_element_op
=
AElementOp
{};
const
auto
b_element_op
=
BElementOp
{};
const
auto
b_element_op
=
BElementOp
{};
const
auto
c_element_op
=
CElementOp
{};
const
auto
c_element_op
=
CElementOp
{};
const
auto
d0_reduce_op
=
D0ReduceOp
{};
const
auto
d0_reduce_op
=
D0ReduceOp
{};
const
auto
d1_reduce_op
=
D1ReduceOp
{};
const
auto
d1_reduce_op
=
D1ReduceOp
{};
const
auto
d1_element_op
=
D1ElementOp
{};
if
(
do_verification
)
if
(
do_verification
)
{
{
...
@@ -140,17 +141,21 @@ bool profile_gemm_reduce_impl(int do_verification,
...
@@ -140,17 +141,21 @@ bool profile_gemm_reduce_impl(int do_verification,
for
(
int
m
=
0
;
m
<
M
;
++
m
)
for
(
int
m
=
0
;
m
<
M
;
++
m
)
{
{
float
d0_acc
=
d0_reduce_op
.
GetReduc
e
ZeroVal
ue
();
float
d0_acc
=
d0_reduce_op
.
GetReduc
tion
ZeroVal
();
float
d1_acc
=
d1_reduce_op
.
GetReduc
e
ZeroVal
ue
();
float
d1_acc
=
d1_reduce_op
.
GetReduc
tion
ZeroVal
();
for
(
int
n
=
0
;
n
<
N
;
++
n
)
for
(
int
n
=
0
;
n
<
N
;
++
n
)
{
{
d0_reduce_op
.
Reduce
(
d0_acc
,
c_m_n_host_result
(
m
,
n
));
float
d0_val
=
ck
::
type_convert
<
float
>
(
c_m_n_host_result
(
m
,
n
));
d1_reduce_op
.
Reduce
(
d1_acc
,
c_m_n_host_result
(
m
,
n
));
float
d1_val
;
d1_element_op
(
d1_val
,
d0_val
);
d0_reduce_op
(
d0_acc
,
d0_val
);
d1_reduce_op
(
d1_acc
,
d1_val
);
}
}
d0_m_host_result
(
m
)
=
d0_acc
;
d0_m_host_result
(
m
)
=
ck
::
type_convert
<
DDataType
>
(
d0_acc
)
;
d1_m_host_result
(
m
)
=
d1_acc
;
d1_m_host_result
(
m
)
=
ck
::
type_convert
<
DDataType
>
(
d1_acc
)
;
}
}
}
}
...
@@ -232,8 +237,7 @@ bool profile_gemm_reduce_impl(int do_verification,
...
@@ -232,8 +237,7 @@ bool profile_gemm_reduce_impl(int do_verification,
a_element_op
,
a_element_op
,
b_element_op
,
b_element_op
,
c_element_op
,
c_element_op
,
d0_reduce_op
,
d1_element_op
);
d1_reduce_op
);
auto
invoker_ptr
=
gemm_ptr
->
MakeInvokerPointer
();
auto
invoker_ptr
=
gemm_ptr
->
MakeInvokerPointer
();
...
...
script/clang-format-overwrite.sh
View file @
d0b9a467
find
.
-name
deps
-prune
-o
-name
build
-prune
-o
-iname
'*.h'
-o
-iname
'*.hpp'
-o
-iname
'*.cpp'
-o
-iname
'*.h.in'
-o
-iname
'*.hpp.in'
-o
-iname
'*.cpp.in'
-o
-iname
'*.cl'
-o
-iname
'*.cuh'
-o
-iname
'*.cu'
| xargs
-n
1
-P
16
-I
{}
-t
sh
-c
'clang-format-10 -i -style=file {}'
#
find . -name deps -prune -o -name build -prune -o -iname '*.h' -o -iname '*.hpp' -o -iname '*.cpp' -o -iname '*.h.in' -o -iname '*.hpp.in' -o -iname '*.cpp.in' -o -iname '*.cl' -o -iname '*.cuh' -o -iname '*.cu' | xargs -n 1 -P 16 -I{} -t sh -c 'clang-format-10 -i -style=file {}'
git status
--porcelain
|
awk
'$1 != "D" && (match($2, "\\.cpp|hpp")) {print $2}'
| xargs
-n
1
-P
16
-I
{}
-t
sh
-c
'clang-format-10 -i -style=file {}'
test/CMakeLists.txt
View file @
d0b9a467
...
@@ -24,6 +24,7 @@ include_directories(BEFORE
...
@@ -24,6 +24,7 @@ include_directories(BEFORE
add_custom_target
(
check COMMAND
${
CMAKE_CTEST_COMMAND
}
--output-on-failure -C
${
CMAKE_CFG_INTDIR
}
)
add_custom_target
(
check COMMAND
${
CMAKE_CTEST_COMMAND
}
--output-on-failure -C
${
CMAKE_CFG_INTDIR
}
)
add_custom_target
(
tests
)
add_custom_target
(
tests
)
function
(
add_test_executable TEST_NAME
)
function
(
add_test_executable TEST_NAME
)
message
(
"adding test
${
TEST_NAME
}
"
)
message
(
"adding test
${
TEST_NAME
}
"
)
add_executable
(
${
TEST_NAME
}
${
ARGN
}
)
add_executable
(
${
TEST_NAME
}
${
ARGN
}
)
...
@@ -32,6 +33,20 @@ function(add_test_executable TEST_NAME)
...
@@ -32,6 +33,20 @@ function(add_test_executable TEST_NAME)
add_dependencies
(
check
${
TEST_NAME
}
)
add_dependencies
(
check
${
TEST_NAME
}
)
endfunction
(
add_test_executable TEST_NAME
)
endfunction
(
add_test_executable TEST_NAME
)
include
(
GoogleTest
)
function
(
add_gtest_executable TEST_NAME
)
message
(
"adding gtest
${
TEST_NAME
}
"
)
add_executable
(
${
TEST_NAME
}
${
ARGN
}
)
add_dependencies
(
tests
${
TEST_NAME
}
)
add_dependencies
(
check
${
TEST_NAME
}
)
# suppress gtest warnings
target_compile_options
(
${
TEST_NAME
}
PRIVATE -Wno-global-constructors
)
target_link_libraries
(
${
TEST_NAME
}
PRIVATE gtest_main
)
gtest_discover_tests
(
${
TEST_NAME
}
)
endfunction
(
add_gtest_executable TEST_NAME
)
add_subdirectory
(
magic_number_division
)
add_subdirectory
(
magic_number_division
)
add_subdirectory
(
space_filling_curve
)
add_subdirectory
(
space_filling_curve
)
add_subdirectory
(
conv_util
)
add_subdirectory
(
conv_util
)
...
...
test/conv_util/CMakeLists.txt
View file @
d0b9a467
add_test_executable
(
test_conv_util conv_util.cpp
)
add_
g
test_executable
(
test_conv_util conv_util.cpp
)
target_link_libraries
(
test_conv_util PRIVATE host_tensor conv_fwd_util
)
target_link_libraries
(
test_conv_util PRIVATE host_tensor conv_fwd_util
)
test/conv_util/conv_util.cpp
View file @
d0b9a467
#include <iostream>
#include <iostream>
#include <string>
#include <string>
#include <vector>
#include <vector>
#include "gtest/gtest.h"
#include "config.hpp"
#include "config.hpp"
#include "conv_fwd_util.hpp"
#include "conv_fwd_util.hpp"
...
@@ -9,196 +10,194 @@
...
@@ -9,196 +10,194 @@
namespace
{
namespace
{
bool
t
est
_c
onv
_params_get_output_spatial_lengths
()
class
T
est
C
onv
Util
:
public
::
testing
::
Test
{
{
bool
res
{
true
};
public:
// -------------------------- default 2D ------------------------------------
void
SetNDParams
(
std
::
size_t
ndims
)
{
conv_params
.
num_dim_spatial
=
ndims
;
conv_params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
3
);
conv_params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
71
);
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
2
);
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
1
);
conv_params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
1
);
conv_params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
(
ndims
,
1
);
}
protected:
// ------- default 2D -------
// input NCHW {128,192,71,71},
// input NCHW {128,192,71,71},
// weights KCYX {256,192,3,3},
// weights KCYX {256,192,3,3},
// stride {2,2},
// stride {2,2},
// dilations {1,1},
// dilations {1,1},
// padding {{1,1}, {1,1}}
// padding {{1,1}, {1,1}}
ck
::
utils
::
conv
::
ConvParams
conv_params
;
ck
::
utils
::
conv
::
ConvParams
conv_params
;
};
}
// namespace
TEST_F
(
TestConvUtil
,
ConvParamsGetOutputSpatialLengths2D
)
{
ck
::
utils
::
conv
::
ConvParams
conv_params
;
std
::
vector
<
ck
::
index_t
>
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
std
::
vector
<
ck
::
index_t
>
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
out_spatial_len
,
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
},
std
::
vector
<
ck
::
index_t
>
{
36
,
36
},
"Error: ConvParams 2D default constructor."
);
"Error: ConvParams 2D default constructor."
)
)
;
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
71
,
71
},
"Error: ConvParams 2D stride {1,1}."
);
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
71
,
71
},
"Error: ConvParams 2D stride {1,1}."
)
)
;
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
conv_params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
conv_params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
conv_params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
conv_params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
out_spatial_len
,
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
37
,
37
},
std
::
vector
<
ck
::
index_t
>
{
37
,
37
},
"Error: ConvParams 2D padding left/right {2,2}."
);
"Error: ConvParams 2D padding left/right {2,2}."
)
)
;
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
},
"Error: ConvParams 2D dilation {2,2}."
);
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
},
"Error: ConvParams 2D dilation {2,2}."
)
)
;
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
};
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
};
conv_params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
conv_params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
conv_params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
conv_params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
23
,
23
},
std
::
vector
<
ck
::
index_t
>
{
23
,
23
},
"Error: ConvParams 2D strides{3,3}, padding {1,1}, dilations {2,2}."
);
"Error: ConvParams 2D strides{3,3}, padding {1,1}, dilations {2,2}."
));
}
// -------------------------- 1D ------------------------------------
TEST_F
(
TestConvUtil
,
ConvParamsGetOutputSpatialLengths1D
)
conv_params
.
num_dim_spatial
=
1
;
{
conv_params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
};
SetNDParams
(
1
);
conv_params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
71
};
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
2
};
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
1
};
conv_params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
conv_params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
std
::
vector
<
ck
::
index_t
>
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
},
"Error: ConvParams 1D."
);
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
},
"Error: ConvParams 1D."
)
)
;
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
1
};
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
1
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
71
},
"Error: ConvParams 1D stride {1}."
);
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
71
},
"Error: ConvParams 1D stride {1}."
)
)
;
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
2
};
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
2
};
conv_params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
2
};
conv_params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
2
};
conv_params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
2
};
conv_params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
out_spatial_len
,
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
37
},
std
::
vector
<
ck
::
index_t
>
{
37
},
"Error: ConvParams 1D padding left/right {2}."
);
"Error: ConvParams 1D padding left/right {2}."
)
)
;
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
2
};
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
},
"Error: ConvParams 1D dilation {2}."
);
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
},
"Error: ConvParams 1D dilation {2}."
)
)
;
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
3
};
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
3
};
conv_params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
conv_params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
conv_params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
conv_params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
2
};
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
out_spatial_len
,
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
23
},
std
::
vector
<
ck
::
index_t
>
{
23
},
"Error: ConvParams 1D strides{3}, padding {1}, dilations {2}."
);
"Error: ConvParams 1D strides{3}, padding {1}, dilations {2}."
));
}
// -------------------------- 3D ------------------------------------
TEST_F
(
TestConvUtil
,
ConvParamsGetOutputSpatialLengths3D
)
conv_params
.
num_dim_spatial
=
3
;
{
conv_params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
SetNDParams
(
3
);
conv_params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
71
,
71
,
71
};
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
conv_params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
conv_params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
std
::
vector
<
ck
::
index_t
>
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
,
36
},
"Error: ConvParams 3D."
);
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
,
36
},
"Error: ConvParams 3D."
)
)
;
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
out_spatial_len
,
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
71
,
71
,
71
},
std
::
vector
<
ck
::
index_t
>
{
71
,
71
,
71
},
"Error: ConvParams 3D stride {1, 1, 1}."
);
"Error: ConvParams 3D stride {1, 1, 1}."
)
)
;
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
conv_params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
conv_params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
conv_params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
conv_params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
out_spatial_len
,
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
37
,
37
,
37
},
std
::
vector
<
ck
::
index_t
>
{
37
,
37
,
37
},
"Error: ConvParams 3D padding left/right {2, 2, 2}."
);
"Error: ConvParams 3D padding left/right {2, 2, 2}."
)
)
;
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
out_spatial_len
,
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
,
36
},
std
::
vector
<
ck
::
index_t
>
{
36
,
36
,
36
},
"Error: ConvParams 3D dilation {2, 2, 2}."
);
"Error: ConvParams 3D dilation {2, 2, 2}."
)
)
;
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
conv_params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
conv_params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
conv_params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
conv_params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
23
,
23
,
23
},
std
::
vector
<
ck
::
index_t
>
{
23
,
23
,
23
},
"Error: ConvParams 3D strides{3, 3, 3}, padding {1, 1, 1}, dilations {2, 2, 2}."
);
"Error: ConvParams 3D strides{3, 3, 3}, padding {1, 1, 1}, dilations {2, 2, 2}."
));
return
res
;
}
}
bool
test_get_h
ost
_t
ensor
_d
escriptor
(
)
TEST
(
ConvUtil
,
GetH
ost
T
ensor
D
escriptor
)
{
{
bool
res
{
true
};
namespace
tl
=
ck
::
tensor_layout
::
convolution
;
namespace
tl
=
ck
::
tensor_layout
::
convolution
;
std
::
vector
<
std
::
size_t
>
dims
{
2
,
3
,
4
,
5
};
std
::
vector
<
std
::
size_t
>
dims
{
2
,
3
,
4
,
5
};
HostTensorDescriptor
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NHWC
{});
HostTensorDescriptor
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NHWC
{});
res
=
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
,
5
},
"Error: wrong NHWC dimensions lengths!"
);
h
.
GetLengths
(),
{
2
,
3
,
4
,
5
},
"Error: wrong NHWC dimensions lengths!"
)
)
;
res
=
ck
::
utils
::
check_err
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
*
5
,
1
,
3
*
5
,
3
},
"Error: wrong NHWC dimensions strides!"
);
h
.
GetStrides
(),
{
3
*
4
*
5
,
1
,
3
*
5
,
3
},
"Error: wrong NHWC dimensions strides!"
)
)
;
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NCHW
{});
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NCHW
{});
res
=
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
,
5
},
"Error: wrong NCHW dimensions lengths!"
);
h
.
GetLengths
(),
{
2
,
3
,
4
,
5
},
"Error: wrong NCHW dimensions lengths!"
)
)
;
res
=
ck
::
utils
::
check_err
(
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
*
5
,
4
*
5
,
5
,
1
},
"Error: wrong NCHW dimensions strides!"
);
h
.
GetStrides
(),
{
3
*
4
*
5
,
4
*
5
,
5
,
1
},
"Error: wrong NCHW dimensions strides!"
)
)
;
dims
=
std
::
vector
<
std
::
size_t
>
{
2
,
3
,
4
};
dims
=
std
::
vector
<
std
::
size_t
>
{
2
,
3
,
4
};
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NWC
{});
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NWC
{});
res
=
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
},
"Error: wrong NWC dimensions lengths!"
);
EXPECT_TRUE
(
res
=
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
},
"Error: wrong NWC dimensions lengths!"
));
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
,
1
,
3
},
"Error: wrong NWC dimensions strides!"
);
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
,
1
,
3
},
"Error: wrong NWC dimensions strides!"
));
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NCW
{});
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NCW
{});
res
=
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
},
"Error: wrong NCW dimensions lengths!"
);
EXPECT_TRUE
(
res
=
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
},
"Error: wrong NCW dimensions lengths!"
));
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
,
4
,
1
},
"Error: wrong NCW dimensions strides!"
);
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
,
4
,
1
},
"Error: wrong NCW dimensions strides!"
));
dims
=
std
::
vector
<
std
::
size_t
>
{
2
,
3
,
4
,
5
,
6
};
dims
=
std
::
vector
<
std
::
size_t
>
{
2
,
3
,
4
,
5
,
6
};
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NDHWC
{});
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NDHWC
{});
res
=
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
dims
,
"Error: wrong NDHWC dimensions lengths!"
);
EXPECT_TRUE
(
res
=
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
dims
,
"Error: wrong NDHWC dimensions lengths!"
));
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
*
5
*
6
,
// N
{
3
*
4
*
5
*
6
,
// N
1
,
// C
1
,
// C
3
*
5
*
6
,
// D
3
*
5
*
6
,
// D
3
*
6
,
// H
3
*
6
,
// H
3
},
// W
3
},
// W
"Error: wrong NDHWC dimensions strides!"
);
"Error: wrong NDHWC dimensions strides!"
)
)
;
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NCDHW
{});
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NCDHW
{});
res
=
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
dims
,
"Error: wrong NCDHW dimensions lengths!"
);
EXPECT_TRUE
(
res
=
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
dims
,
"Error: wrong NCDHW dimensions lengths!"
));
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
*
5
*
6
,
// N
{
3
*
4
*
5
*
6
,
// N
4
*
5
*
6
,
// C
4
*
5
*
6
,
// C
5
*
6
,
// D
5
*
6
,
// D
6
,
// H
6
,
// H
1
},
// W
1
},
// W
"Error: wrong NCDHW dimensions strides!"
);
"Error: wrong NCDHW dimensions strides!"
));
return
res
;
}
}
// namespace
int
main
(
void
)
{
bool
res
=
test_conv_params_get_output_spatial_lengths
();
std
::
cout
<<
"test_conv_params_get_output_spatial_lengths ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_get_host_tensor_descriptor
();
std
::
cout
<<
"test_get_host_tensor_descriptor ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
return
res
?
0
:
1
;
}
}
test/convnd_fwd/CMakeLists.txt
View file @
d0b9a467
add_custom_target
(
test_convnd_fwd
)
add_custom_target
(
test_convnd_fwd
)
add_test_executable
(
test_conv1d_fwd conv1d_fwd.cpp
)
add_
g
test_executable
(
test_conv1d_fwd conv1d_fwd.cpp
)
target_link_libraries
(
test_conv1d_fwd PRIVATE host_tensor device_conv1d_fwd_instance conv_fwd_util
)
target_link_libraries
(
test_conv1d_fwd PRIVATE host_tensor device_conv1d_fwd_instance conv_fwd_util
)
target_link_libraries
(
test_conv1d_fwd PRIVATE
)
add_dependencies
(
test_convnd_fwd test_conv1d_fwd
)
add_dependencies
(
test_convnd_fwd test_conv1d_fwd
)
add_test_executable
(
test_conv2d_fwd conv2d_fwd.cpp
)
add_
g
test_executable
(
test_conv2d_fwd conv2d_fwd.cpp
)
target_link_libraries
(
test_conv2d_fwd PRIVATE host_tensor device_conv2d_fwd_instance conv_fwd_util
)
target_link_libraries
(
test_conv2d_fwd PRIVATE host_tensor device_conv2d_fwd_instance conv_fwd_util
)
add_dependencies
(
test_convnd_fwd test_conv2d_fwd
)
add_dependencies
(
test_convnd_fwd test_conv2d_fwd
)
add_test_executable
(
test_conv3d_fwd conv3d_fwd.cpp
)
add_
g
test_executable
(
test_conv3d_fwd conv3d_fwd.cpp
)
target_link_libraries
(
test_conv3d_fwd PRIVATE host_tensor device_conv3d_fwd_instance conv_fwd_util
)
target_link_libraries
(
test_conv3d_fwd PRIVATE host_tensor device_conv3d_fwd_instance conv_fwd_util
)
add_dependencies
(
test_convnd_fwd test_conv3d_fwd
)
add_dependencies
(
test_convnd_fwd test_conv3d_fwd
)
test/convnd_fwd/conv1d_fwd.cpp
View file @
d0b9a467
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include <stdexcept>
#include <stdexcept>
#include <tuple>
#include <tuple>
#include <vector>
#include <vector>
#include "gtest/gtest.h"
#include "data_type.hpp"
#include "data_type.hpp"
#include "element_wise_operation.hpp"
#include "element_wise_operation.hpp"
...
@@ -10,7 +11,8 @@
...
@@ -10,7 +11,8 @@
namespace
{
namespace
{
bool
test_conv1D_nwc
()
template
<
typename
T
>
bool
test_conv1d_nwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
)
{
{
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
using
namespace
ck
::
utils
;
...
@@ -18,31 +20,24 @@ bool test_conv1D_nwc()
...
@@ -18,31 +20,24 @@ bool test_conv1D_nwc()
ck
::
utils
::
conv
::
ConvParams
params
;
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
num_dim_spatial
=
1
;
params
.
num_dim_spatial
=
1
;
params
.
N
=
2
;
params
.
K
=
16
;
params
.
C
=
4
;
params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
};
params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
};
params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
1
6
};
params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
7
1
};
params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
2
};
params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NWC
,
ctl
::
KCX
,
ctl
::
NWK
>
conv_instance
(
params
);
test
::
conv
::
get_test_convolution_fwd_instance
<
1
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
float
,
float
,
float
,
ctl
::
NWC
,
ctl
::
KCX
,
ctl
::
NWK
>
conv_instance
(
params
);
auto
reference_conv_fwd_fun
=
std
::
bind
(
auto
reference_conv_fwd_fun
=
conv
::
run_reference_convolution_forward
<
1
,
float
,
float
,
float
>
,
params
,
_1
,
_2
,
_3
);
std
::
bind
(
conv
::
run_reference_convolution_forward
<
1
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
float
,
float
,
float
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-5
);
run_engine
.
SetRtol
(
1e-4
);
return
run_engine
.
Test
(
conv_ptrs
);
return
run_engine
.
Test
(
conv_ptrs
);
}
}
template
<
typename
T
>
}
// anonymous namespace
bool
test_conv1d_nwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
)
TEST
(
Conv1DFwdNWC
,
TestConv1D
)
{
{
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
using
namespace
ck
::
utils
;
...
@@ -50,65 +45,49 @@ bool test_conv1d_nwc_instances(const std::vector<test::conv::DeviceConvFwdNoOpPt
...
@@ -50,65 +45,49 @@ bool test_conv1d_nwc_instances(const std::vector<test::conv::DeviceConvFwdNoOpPt
ck
::
utils
::
conv
::
ConvParams
params
;
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
num_dim_spatial
=
1
;
params
.
num_dim_spatial
=
1
;
params
.
N
=
2
;
params
.
K
=
16
;
params
.
C
=
4
;
params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
};
params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
};
params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
7
1
};
params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
1
6
};
params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
2
};
params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NWC
,
ctl
::
KCX
,
ctl
::
NWK
>
conv_instance
(
params
);
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
1
>
(
conv_ptrs
);
auto
reference_conv_fwd_fun
=
conv
::
ConvFwdOpInstance
<
float
,
float
,
float
,
ctl
::
NWC
,
ctl
::
KCX
,
ctl
::
NWK
>
conv_instance
(
std
::
bind
(
conv
::
run_reference_convolution_forward
<
1
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
params
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
return
run_engine
.
Test
(
conv_ptrs
);
}
bool
test_conv1d_nwc_bf16_instances
()
auto
reference_conv_fwd_fun
=
std
::
bind
(
{
conv
::
run_reference_convolution_forward
<
1
,
float
,
float
,
float
>
,
params
,
_1
,
_2
,
_3
);
return
test_conv1d_nwc_instances
<
ck
::
bhalf_t
>
(
OpInstanceRunEngine
<
float
,
float
,
float
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>::
Get
<
1
>
());
run_engine
.
SetAtol
(
1e-5
);
run_engine
.
SetRtol
(
1e-4
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
}
bool
test_conv1d_nwc_
f16
_
instances
(
)
TEST
(
Conv1DFwdNWC
,
B
f16
I
instances
)
{
{
return
test_conv1d_nwc_instances
<
ck
::
half_t
>
(
EXPECT_TRUE
(
test_conv1d_nwc_instances
<
ck
::
b
half_t
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>::
Get
<
1
>
());
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
ck
::
b
half_t
,
ck
::
b
half_t
,
ck
::
b
half_t
>::
Get
<
1
>
())
)
;
}
}
bool
test_conv1d_nwc_f32_i
nstances
(
)
TEST
(
Conv1DFwdNWC
,
F16I
nstances
)
{
{
return
test_conv1d_nwc_instances
<
floa
t
>
(
EXPECT_TRUE
(
test_conv1d_nwc_instances
<
ck
::
half_
t
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
float
,
float
,
floa
t
>::
Get
<
1
>
());
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_
t
>::
Get
<
1
>
())
)
;
}
}
bool
test_conv1d_nwc_int8_i
nstances
(
)
TEST
(
Conv1DFwdNWC
,
F32I
nstances
)
{
{
return
test_conv1d_nwc_instances
<
int8_
t
>
(
EXPECT_TRUE
(
test_conv1d_nwc_instances
<
floa
t
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
int8_t
,
int8_t
,
int8_
t
>::
Get
<
1
>
());
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
float
,
float
,
floa
t
>::
Get
<
1
>
())
)
;
}
}
}
// anonymous namespace
TEST
(
Conv1DFwdNWC
,
Int8Instances
)
int
main
()
{
{
bool
res
{
true
};
EXPECT_TRUE
(
test_conv1d_nwc_instances
<
int8_t
>
(
res
=
test_conv1D_nwc
();
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
int8_t
,
int8_t
,
int8_t
>::
Get
<
1
>
()));
std
::
cout
<<
"test_conv1D_nwc ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv1d_nwc_bf16_instances
();
std
::
cout
<<
"
\n
TestConv1DNWCBF16Instances ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv1d_nwc_f16_instances
();
std
::
cout
<<
"
\n
test_conv1d_nwc_f16_instances ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv1d_nwc_f32_instances
();
std
::
cout
<<
"
\n
test_conv1d_nwc_f32_instances ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv1d_nwc_int8_instances
();
std
::
cout
<<
"
\n
test_conv1d_nwc_int8_instances ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
return
res
?
0
:
1
;
}
}
test/convnd_fwd/conv2d_fwd.cpp
View file @
d0b9a467
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include <iostream>
#include <iostream>
#include <tuple>
#include <tuple>
#include <vector>
#include <vector>
#include "gtest/gtest.h"
#include "data_type.hpp"
#include "data_type.hpp"
#include "element_wise_operation.hpp"
#include "element_wise_operation.hpp"
...
@@ -10,30 +11,6 @@
...
@@ -10,30 +11,6 @@
namespace
{
namespace
{
bool
test_conv2d_nhwc
()
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
N
=
2
;
params
.
K
=
16
;
params
.
C
=
4
;
params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
16
,
16
};
params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
2
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
float
,
float
,
float
>
conv_instance
(
params
);
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
2
,
float
,
float
,
float
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
float
,
float
,
float
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-5
);
run_engine
.
SetRtol
(
1e-4
);
return
run_engine
.
Test
(
conv_ptrs
);
}
template
<
typename
T
>
template
<
typename
T
>
bool
test_conv2d_nhwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
)
bool
test_conv2d_nhwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
)
{
{
...
@@ -57,50 +34,58 @@ bool test_conv2d_nhwc_instances(const std::vector<test::conv::DeviceConvFwdNoOpP
...
@@ -57,50 +34,58 @@ bool test_conv2d_nhwc_instances(const std::vector<test::conv::DeviceConvFwdNoOpP
return
run_engine
.
Test
(
conv_ptrs
);
return
run_engine
.
Test
(
conv_ptrs
);
}
}
bool
test_conv2d_nhwc_bf16_instances
()
}
// anonymous namespace
TEST
(
Conv2DFwdNHWC
,
TestConv2D
)
{
{
return
test_conv2d_nhwc_instances
<
ck
::
bhalf_t
>
(
using
namespace
std
::
placeholders
;
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>::
Get
<
2
>
());
using
namespace
ck
::
utils
;
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
N
=
2
;
params
.
K
=
16
;
params
.
C
=
4
;
params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
16
,
16
};
params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
2
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
float
,
float
,
float
>
conv_instance
(
params
);
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
2
,
float
,
float
,
float
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
float
,
float
,
float
>
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
));
}
}
bool
test_conv2d_nhwc_
f16
_i
nstances
(
)
TEST
(
Conv2DFwdNHWC
,
B
f16
I
nstances
)
{
{
return
test_conv2d_nhwc_instances
<
ck
::
half_t
>
(
EXPECT_TRUE
(
test_conv2d_nhwc_instances
<
ck
::
b
half_t
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>::
Get
<
2
>
());
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
ck
::
b
half_t
,
ck
::
b
half_t
,
ck
::
b
half_t
>::
Get
<
2
>
())
)
;
}
}
bool
test_conv2d_nhwc_f32_i
nstances
(
)
TEST
(
Conv2DFwdNHWC
,
F16I
nstances
)
{
{
return
test_conv2d_nhwc_instances
<
floa
t
>
(
EXPECT_TRUE
(
test_conv2d_nhwc_instances
<
ck
::
half_
t
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
float
,
float
,
floa
t
>::
Get
<
2
>
());
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_
t
>::
Get
<
2
>
())
)
;
}
}
bool
test_conv2d_nhwc_int8_i
nstances
(
)
TEST
(
Conv2DFwdNHWC
,
BF32I
nstances
)
{
{
return
test_conv2d_nhwc_instances
<
int8_
t
>
(
EXPECT_TRUE
(
test_conv2d_nhwc_instances
<
floa
t
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
int8_t
,
int8_t
,
int8_
t
>::
Get
<
2
>
());
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
float
,
float
,
floa
t
>::
Get
<
2
>
())
)
;
}
}
}
// anonymous namespace
TEST
(
Conv2DFwdNHWC
,
F32Instances
)
{
EXPECT_TRUE
(
test_conv2d_nhwc_instances
<
float
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
float
,
float
,
float
>::
Get
<
2
>
()));
}
int
main
(
)
TEST
(
Conv2DFwdNHWC
,
Int8Instances
)
{
{
bool
res
{
true
};
EXPECT_TRUE
(
test_conv2d_nhwc_instances
<
int8_t
>
(
res
=
test_conv2d_nhwc
();
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
int8_t
,
int8_t
,
int8_t
>::
Get
<
2
>
()));
std
::
cout
<<
"test_conv2d_nhwc ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv2d_nhwc_bf16_instances
();
std
::
cout
<<
"
\n
test_conv2d_nhwc_bf16_instances ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv2d_nhwc_f16_instances
();
std
::
cout
<<
"
\n
test_conv2d_nhwc_f16_instances ....."
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv2d_nhwc_f32_instances
();
std
::
cout
<<
"
\n
test_conv2d_nhwc_f32_instances ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv2d_nhwc_int8_instances
();
std
::
cout
<<
"
\n
test_conv2d_nhwc_int8_instances ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
return
res
?
0
:
1
;
}
}
test/convnd_fwd/conv3d_fwd.cpp
View file @
d0b9a467
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include <stdexcept>
#include <stdexcept>
#include <tuple>
#include <tuple>
#include <vector>
#include <vector>
#include "gtest/gtest.h"
#include "data_type.hpp"
#include "data_type.hpp"
#include "element_wise_operation.hpp"
#include "element_wise_operation.hpp"
...
@@ -11,7 +12,34 @@
...
@@ -11,7 +12,34 @@
namespace
{
namespace
{
bool
test_conv3d_ndhwc
()
template
<
typename
T
>
bool
test_conv3d_ndhwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
conv
::
ConvParams
params
;
params
.
N
=
64
;
params
.
num_dim_spatial
=
3
;
params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
2
};
params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
32
,
32
,
2
};
params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
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
};
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NDHWC
,
ctl
::
KZYXC
,
ctl
::
NDHWK
>
conv_instance
(
params
);
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
);
return
run_engine
.
Test
(
conv_ptrs
);
}
}
// anonymous namespace
TEST
(
Conv3DFwdNDHWC
,
TestConv3D
)
{
{
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
using
namespace
ck
::
utils
;
...
@@ -39,10 +67,10 @@ bool test_conv3d_ndhwc()
...
@@ -39,10 +67,10 @@ bool test_conv3d_ndhwc()
OpInstanceRunEngine
<
float
,
float
,
float
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
OpInstanceRunEngine
<
float
,
float
,
float
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-5
);
run_engine
.
SetAtol
(
1e-5
);
run_engine
.
SetRtol
(
1e-4
);
run_engine
.
SetRtol
(
1e-4
);
return
run_engine
.
Test
(
conv_ptrs
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
)
)
;
}
}
bool
test_conv3d_ndhwc_2gb_input
(
)
TEST
(
Conv3DFwdNDHWC
,
InputOver2GB
)
{
{
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
namespace
ck
::
utils
;
using
namespace
ck
::
utils
;
...
@@ -79,10 +107,10 @@ bool test_conv3d_ndhwc_2gb_input()
...
@@ -79,10 +107,10 @@ bool test_conv3d_ndhwc_2gb_input()
PassThrough
{},
PassThrough
{},
PassThrough
{},
PassThrough
{},
PassThrough
{});
PassThrough
{});
return
!
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
EXPECT_FALSE
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
}
}
bool
test_conv3d_ndhwc_2gb_filters
(
)
TEST
(
Conv3DFwdNDHWC
,
FiltersOver2GB
)
{
{
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
namespace
ck
::
utils
;
using
namespace
ck
::
utils
;
...
@@ -119,10 +147,10 @@ bool test_conv3d_ndhwc_2gb_filters()
...
@@ -119,10 +147,10 @@ bool test_conv3d_ndhwc_2gb_filters()
PassThrough
{},
PassThrough
{},
PassThrough
{},
PassThrough
{},
PassThrough
{});
PassThrough
{});
return
!
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
EXPECT_FALSE
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
}
}
bool
test_conv3d_ndhwc_2gb_output
(
)
TEST
(
Conv3DFwdNDHWC
,
OutputOver2GB
)
{
{
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
namespace
ck
::
utils
;
using
namespace
ck
::
utils
;
...
@@ -158,88 +186,29 @@ bool test_conv3d_ndhwc_2gb_output()
...
@@ -158,88 +186,29 @@ bool test_conv3d_ndhwc_2gb_output()
PassThrough
{},
PassThrough
{},
PassThrough
{},
PassThrough
{},
PassThrough
{});
PassThrough
{});
return
!
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
EXPECT_FALSE
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
}
template
<
typename
T
>
bool
test_conv3d_ndhwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
conv
::
ConvParams
params
;
params
.
N
=
64
;
params
.
num_dim_spatial
=
3
;
params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
2
};
params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
32
,
32
,
2
};
params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
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
};
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NDHWC
,
ctl
::
KZYXC
,
ctl
::
NDHWK
>
conv_instance
(
params
);
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
);
return
run_engine
.
Test
(
conv_ptrs
);
}
}
bool
test_conv3d_ndhwc_b
f16
_i
nstances
(
)
TEST
(
Conv3DFwdNDHWC
,
B
f16
I
nstances
)
{
{
return
test_conv3d_ndhwc_instances
<
ck
::
bhalf_t
>
(
EXPECT_TRUE
(
test_conv3d_ndhwc_instances
<
ck
::
bhalf_t
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>::
Get
<
3
>
());
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>::
Get
<
3
>
())
)
;
}
}
bool
test_conv3d_ndhwc_f16_i
nstances
(
)
TEST
(
Conv3DFwdNDHWC
,
F16I
nstances
)
{
{
return
test_conv3d_ndhwc_instances
<
ck
::
half_t
>
(
EXPECT_TRUE
(
test_conv3d_ndhwc_instances
<
ck
::
half_t
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>::
Get
<
3
>
());
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>::
Get
<
3
>
())
)
;
}
}
bool
test_conv3d_ndhwc_f32_i
nstances
(
)
TEST
(
Conv3DFwdNDHWC
,
F32I
nstances
)
{
{
return
test_conv3d_ndhwc_instances
<
float
>
(
EXPECT_TRUE
(
test_conv3d_ndhwc_instances
<
float
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
float
,
float
,
float
>::
Get
<
3
>
());
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
float
,
float
,
float
>::
Get
<
3
>
())
)
;
}
}
bool
test_conv3d_ndhwc_int8_instances
()
TEST
(
Conv3DFwdNDHWC
,
Int8Instances
)
{
return
test_conv3d_ndhwc_instances
<
int8_t
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
int8_t
,
int8_t
,
int8_t
>::
Get
<
3
>
());
}
}
// anonymous namespace
int
main
()
{
{
bool
res
{
true
};
EXPECT_TRUE
(
test_conv3d_ndhwc_instances
<
int8_t
>
(
res
=
test_conv3d_ndhwc
();
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
int8_t
,
int8_t
,
int8_t
>::
Get
<
3
>
()));
std
::
cout
<<
"test_conv3d_ndhwc ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv3d_ndhwc_2gb_input
();
std
::
cout
<<
"
\n
test_conv3d_ndhwc_2gb_input ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv3d_ndhwc_2gb_filters
();
std
::
cout
<<
"
\n
test_conv3d_ndhwc_2gb_filters ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv3d_ndhwc_2gb_output
();
std
::
cout
<<
"
\n
test_conv3d_ndhwc_2gb_output ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv3d_ndhwc_bf16_instances
();
std
::
cout
<<
"
\n
test_conv3d_ndhwc_bf16_instances ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv3d_ndhwc_f16_instances
();
std
::
cout
<<
"
\n
test_conv3d_ndhwc_f16_instances ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv3d_ndhwc_f32_instances
();
std
::
cout
<<
"
\n
test_conv3d_ndhwc_f32_instances ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv3d_ndhwc_int8_instances
();
std
::
cout
<<
"
\n
test_conv3d_ndhwc_int8_instances ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
return
res
?
0
:
1
;
}
}
test/gemm/gemm_util.hpp
View file @
d0b9a467
...
@@ -139,17 +139,10 @@ struct TestGemm
...
@@ -139,17 +139,10 @@ struct TestGemm
Tensor
<
CDataType
>
c_m_n_device_result
(
Tensor
<
CDataType
>
c_m_n_device_result
(
f_host_tensor_descriptor
(
params
.
M
,
params
.
N
,
params
.
StrideC
,
CLayout
{}));
f_host_tensor_descriptor
(
params
.
M
,
params
.
N
,
params
.
StrideC
,
CLayout
{}));
auto
f_generate_tensor_value
=
[](
auto
desc
,
auto
type
)
{
auto
f_generate_tensor_value
=
[](
auto
&
tensor
,
auto
type
)
{
using
dataType
=
decltype
(
type
);
using
dataType
=
decltype
(
type
);
if
(
std
::
is_same
<
dataType
,
int8_t
>::
value
)
tensor
.
GenerateTensorValue
(
GeneratorTensor_2
<
dataType
>
{
-
5
,
5
});
{
desc
.
GenerateTensorValue
(
GeneratorTensor_2
<
int8_t
>
{
-
5
,
5
});
}
else
{
desc
.
GenerateTensorValue
(
GeneratorTensor_3
<
dataType
>
{
-
0.5
,
0.5
});
}
};
};
f_generate_tensor_value
(
a_m_k
,
ADataType
{});
f_generate_tensor_value
(
a_m_k
,
ADataType
{});
...
...
test/reference_conv_fwd/CMakeLists.txt
View file @
d0b9a467
add_test_executable
(
test_reference_conv_fwd reference_conv_fwd.cpp
)
add_
g
test_executable
(
test_reference_conv_fwd reference_conv_fwd.cpp
)
target_link_libraries
(
test_reference_conv_fwd PRIVATE host_tensor conv_fwd_util
)
target_link_libraries
(
test_reference_conv_fwd PRIVATE host_tensor conv_fwd_util
)
test/reference_conv_fwd/reference_conv_fwd.cpp
View file @
d0b9a467
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include <numeric>
#include <numeric>
#include <type_traits>
#include <type_traits>
#include <vector>
#include <vector>
#include "gtest/gtest.h"
#include "check_err.hpp"
#include "check_err.hpp"
#include "config.hpp"
#include "config.hpp"
...
@@ -82,13 +83,13 @@ run_reference_convolution_forward(const ck::utils::conv::ConvParams& params,
...
@@ -82,13 +83,13 @@ run_reference_convolution_forward(const ck::utils::conv::ConvParams& params,
OutElementOp
{});
OutElementOp
{});
ref_invoker
.
Run
(
ref_argument
);
ref_invoker
.
Run
(
ref_argument
);
// std::cout <<"output: " << host_output.mDesc << std::endl << host_output.mData << std::endl;
return
host_output
;
return
host_output
;
}
}
bool
test_conv2d_nhwc
()
}
// anonymous namespace
TEST
(
ReferenceConvolutionFWD
,
Conv2DNHWC
)
{
{
bool
res
{
true
};
ck
::
utils
::
conv
::
ConvParams
params
;
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
N
=
1
;
params
.
N
=
1
;
params
.
K
=
1
;
params
.
K
=
1
;
...
@@ -118,11 +119,14 @@ bool test_conv2d_nhwc()
...
@@ -118,11 +119,14 @@ bool test_conv2d_nhwc()
472.5
,
472.5
,
490.5
,
490.5
,
508.5
};
508.5
};
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
ref_dims
,
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
));
"Error: wrong output tensor dimension
s!"
);
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect result
s!"
)
)
;
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
);
}
TEST
(
ReferenceConvolutionFWD
,
Conv2DNHWCStridesDilationsPadding
)
{
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
N
=
1
;
params
.
N
=
1
;
params
.
K
=
2
;
params
.
K
=
2
;
params
.
C
=
2
;
params
.
C
=
2
;
...
@@ -133,25 +137,21 @@ bool test_conv2d_nhwc()
...
@@ -133,25 +137,21 @@ bool test_conv2d_nhwc()
params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
out_tensor
=
run_reference_convolution_forward
<
2
>
(
params
);
auto
out_tensor
=
run_reference_convolution_forward
<
2
>
(
params
);
ref_dims
=
std
::
vector
<
std
::
size_t
>
{
1
,
2
,
5
,
5
};
std
::
vector
<
std
::
size_t
>
ref_dims
=
std
::
vector
<
std
::
size_t
>
{
1
,
2
,
5
,
5
};
ref_data
=
std
::
vector
<
float
>
{
std
::
vector
<
float
>
ref_data
{
210.
,
210.
,
327.
,
327.
,
351.
,
351.
,
375.
,
375.
,
399.
,
399.
,
210.
,
210.
,
327.
,
327.
,
351.
,
351.
,
375.
,
375.
,
399.
,
399.
,
459.
,
459.
,
706.5
,
706.5
,
742.5
,
742.5
,
778.5
,
778.5
,
814.5
,
814.5
,
459.
,
459.
,
706.5
,
706.5
,
742.5
,
742.5
,
778.5
,
778.5
,
814.5
,
814.5
,
747.
,
747.
,
1138.5
,
1138.5
,
1174.5
,
1174.5
,
1210.5
,
1210.5
,
1246.5
,
1246.5
,
747.
,
747.
,
1138.5
,
1138.5
,
1174.5
,
1174.5
,
1210.5
,
1210.5
,
1246.5
,
1246.5
,
1035.
,
1035.
,
1570.5
,
1570.5
,
1606.5
,
1606.5
,
1642.5
,
1642.5
,
1678.5
,
1678.5
,
1035.
,
1035.
,
1570.5
,
1570.5
,
1606.5
,
1606.5
,
1642.5
,
1642.5
,
1678.5
,
1678.5
,
1323.
,
1323.
,
2002.5
,
2002.5
,
2038.5
,
2038.5
,
2074.5
,
2074.5
,
2110.5
,
2110.5
};
1323.
,
1323.
,
2002.5
,
2002.5
,
2038.5
,
2038.5
,
2074.5
,
2074.5
,
2110.5
,
2110.5
};
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
ref_dims
,
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
));
"Error: wrong output tensor dimensions!"
);
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
));
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
);
return
res
;
}
}
bool
test_conv1d_nwc
(
)
TEST
(
ReferenceConvolutionFWD
,
Conv1DNWC
)
{
{
bool
res
{
true
};
ck
::
utils
::
conv
::
ConvParams
params
;
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
num_dim_spatial
=
1
;
params
.
num_dim_spatial
=
1
;
params
.
N
=
1
;
params
.
N
=
1
;
...
@@ -174,11 +174,14 @@ bool test_conv1d_nwc()
...
@@ -174,11 +174,14 @@ bool test_conv1d_nwc()
ck
::
tensor_layout
::
convolution
::
NWK
>
(
params
);
ck
::
tensor_layout
::
convolution
::
NWK
>
(
params
);
std
::
vector
<
std
::
size_t
>
ref_dims
{
1
,
1
,
4
};
std
::
vector
<
std
::
size_t
>
ref_dims
{
1
,
1
,
4
};
std
::
vector
<
float
>
ref_data
{
7.5
,
13.5
,
19.5
,
25.5
};
std
::
vector
<
float
>
ref_data
{
7.5
,
13.5
,
19.5
,
25.5
};
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
ref_dims
,
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
));
"Error: wrong output tensor dimension
s!"
);
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect result
s!"
)
)
;
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
);
}
TEST
(
ReferenceConvolutionFWD
,
Conv1DNWCStridesDilationsPadding
)
{
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
num_dim_spatial
=
1
;
params
.
num_dim_spatial
=
1
;
params
.
N
=
1
;
params
.
N
=
1
;
params
.
K
=
2
;
params
.
K
=
2
;
...
@@ -190,20 +193,24 @@ bool test_conv1d_nwc()
...
@@ -190,20 +193,24 @@ bool test_conv1d_nwc()
params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
out_tensor
=
run_reference_convolution_forward
<
1
,
auto
out_tensor
=
run_reference_convolution_forward
<
1
,
float
,
float
,
float
,
float
,
float
,
float
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
>
(
params
);
ck
::
tensor_layout
::
convolution
::
NWK
>
(
params
);
ref_dims
=
std
::
vector
<
std
::
size_t
>
{
1
,
2
,
5
};
std
::
vector
<
std
::
size_t
>
ref_dims
{
1
,
2
,
5
};
ref_data
=
std
::
vector
<
float
>
{
9.
,
9.
,
19.5
,
19.5
,
31.5
,
31.5
,
43.5
,
43.5
,
55.5
,
55.5
};
std
::
vector
<
float
>
ref_data
{
9.
,
9.
,
19.5
,
19.5
,
31.5
,
31.5
,
43.5
,
43.5
,
55.5
,
55.5
};
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
ref_dims
,
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
));
"Error: wrong output tensor dimension
s!"
);
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect result
s!"
)
)
;
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error: incorrect results!"
);
}
TEST
(
ReferenceConvolutionFWD
,
Conv1DNWCSameOutputSize
)
{
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
num_dim_spatial
=
1
;
params
.
num_dim_spatial
=
1
;
params
.
N
=
2
;
params
.
N
=
2
;
params
.
K
=
16
;
params
.
K
=
16
;
...
@@ -224,8 +231,8 @@ bool test_conv1d_nwc()
...
@@ -224,8 +231,8 @@ bool test_conv1d_nwc()
ck
::
tensor_layout
::
convolution
::
NWK
>
(
ck
::
tensor_layout
::
convolution
::
NWK
>
(
params
,
ck
::
utils
::
FillMonotonicSeq
<
float
>
{
0.
f
,
0.1
f
});
params
,
ck
::
utils
::
FillMonotonicSeq
<
float
>
{
0.
f
,
0.1
f
});
ref_dims
=
std
::
vector
<
std
::
size_t
>
{
2
,
16
,
16
};
std
::
vector
<
std
::
size_t
>
ref_dims
{
2
,
16
,
16
};
ref_data
=
std
::
vector
<
float
>
{
std
::
vector
<
float
>
ref_data
{
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
1.4
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
3.3
,
...
@@ -290,17 +297,13 @@ bool test_conv1d_nwc()
...
@@ -290,17 +297,13 @@ bool test_conv1d_nwc()
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
72.9
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
};
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
,
49.4
};
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor2
.
mDesc
.
GetLengths
(),
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
ref_dims
,
out_tensor2
.
mDesc
.
GetLengths
(),
ref_dims
,
"Error: wrong output tensor dimensions!"
));
"Error: wrong output tensor dimensions!"
);
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_tensor2
.
mData
,
ref_data
,
"Error: incorrect results!"
));
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor2
.
mData
,
ref_data
,
"Error: incorrect results!"
);
return
res
;
}
}
bool
test_conv3d_ncdhw
(
)
TEST
(
ReferenceConvolutionFWD
,
Conv3DNCDHW
)
{
{
bool
res
{
true
};
ck
::
utils
::
conv
::
ConvParams
params
;
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
num_dim_spatial
=
3
;
params
.
num_dim_spatial
=
3
;
params
.
N
=
1
;
params
.
N
=
1
;
...
@@ -331,12 +334,17 @@ bool test_conv3d_ncdhw()
...
@@ -331,12 +334,17 @@ bool test_conv3d_ncdhw()
634.5
,
637.2
,
639.9
,
642.60004
,
650.7
,
653.4
,
656.10004
,
658.8
,
634.5
,
637.2
,
639.9
,
642.60004
,
650.7
,
653.4
,
656.10004
,
658.8
,
699.3
,
702.
,
704.7
,
707.4
,
715.5
,
718.2
,
720.9
,
723.60004
,
699.3
,
702.
,
704.7
,
707.4
,
715.5
,
718.2
,
720.9
,
723.60004
,
731.7
,
734.4001
,
737.10004
,
739.8
,
747.9001
,
750.60004
,
753.3
,
756.
};
731.7
,
734.4001
,
737.10004
,
739.8
,
747.9001
,
750.60004
,
753.3
,
756.
};
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
ref_dims
,
"Error [case 1]: wrong output tensor dimensions!"
);
"Error [case 1]: wrong output tensor dimensions!"
));
res
=
res
&&
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error [case 1]: incorrect results!"
);
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error [case 1]: incorrect results!"
));
}
TEST
(
ReferenceConvolutionFWD
,
Conv3DNCDHWStridesDilations
)
{
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
num_dim_spatial
=
3
;
params
.
N
=
1
;
params
.
N
=
1
;
params
.
K
=
2
;
params
.
K
=
2
;
params
.
C
=
2
;
params
.
C
=
2
;
...
@@ -347,7 +355,7 @@ bool test_conv3d_ncdhw()
...
@@ -347,7 +355,7 @@ bool test_conv3d_ncdhw()
params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
};
params
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
};
params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
0
,
0
,
0
};
out_tensor
=
run_reference_convolution_forward
<
3
,
auto
out_tensor
=
run_reference_convolution_forward
<
3
,
float
,
float
,
float
,
float
,
float
,
float
,
...
@@ -355,8 +363,8 @@ bool test_conv3d_ncdhw()
...
@@ -355,8 +363,8 @@ bool test_conv3d_ncdhw()
ck
::
tensor_layout
::
convolution
::
KCZYX
,
ck
::
tensor_layout
::
convolution
::
KCZYX
,
ck
::
tensor_layout
::
convolution
::
NKDHW
>
(
ck
::
tensor_layout
::
convolution
::
NKDHW
>
(
params
,
ck
::
utils
::
FillMonotonicSeq
<
float
>
{
0.
f
,
0.1
f
});
params
,
ck
::
utils
::
FillMonotonicSeq
<
float
>
{
0.
f
,
0.1
f
});
ref_dims
=
std
::
vector
<
std
::
size_t
>
{
1
,
2
,
4
,
4
,
4
};
std
::
vector
<
std
::
size_t
>
ref_dims
{
1
,
2
,
4
,
4
,
4
};
ref_data
=
std
::
vector
<
float
>
{
std
::
vector
<
float
>
ref_data
{
2756.7002
,
2764.7998
,
2772.9001
,
2781.
,
2853.9001
,
2862.
,
2870.1
,
2878.2002
,
2756.7002
,
2764.7998
,
2772.9001
,
2781.
,
2853.9001
,
2862.
,
2870.1
,
2878.2002
,
2951.1
,
2959.2002
,
2967.2998
,
2975.4001
,
3048.2998
,
3056.4001
,
3064.5
,
3072.6
,
2951.1
,
2959.2002
,
2967.2998
,
2975.4001
,
3048.2998
,
3056.4001
,
3064.5
,
3072.6
,
3923.1
,
3931.2
,
3939.2998
,
3947.4
,
4020.2998
,
4028.4001
,
4036.5002
,
4044.5999
,
3923.1
,
3931.2
,
3939.2998
,
3947.4
,
4020.2998
,
4028.4001
,
4036.5002
,
4044.5999
,
...
@@ -373,26 +381,9 @@ bool test_conv3d_ncdhw()
...
@@ -373,26 +381,9 @@ bool test_conv3d_ncdhw()
5283.9004
,
5292.
,
5300.0996
,
5308.2
,
5381.0996
,
5389.2
,
5397.3
,
5405.4004
,
5283.9004
,
5292.
,
5300.0996
,
5308.2
,
5381.0996
,
5389.2
,
5397.3
,
5405.4004
,
6255.9004
,
6264.0005
,
6272.1
,
6280.2
,
6353.1
,
6361.2
,
6369.301
,
6377.4
,
6255.9004
,
6264.0005
,
6272.1
,
6280.2
,
6353.1
,
6361.2
,
6369.301
,
6377.4
,
6450.301
,
6458.4
,
6466.5
,
6474.6
,
6547.5
,
6555.6
,
6563.699
,
6571.801
};
6450.301
,
6458.4
,
6466.5
,
6474.6
,
6547.5
,
6555.6
,
6563.699
,
6571.801
};
res
=
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_tensor
.
mDesc
.
GetLengths
(),
ref_dims
,
ref_dims
,
"Error [case 2]: wrong output tensor dimensions!"
);
"Error [case 2]: wrong output tensor dimensions!"
));
res
=
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
res
&&
ck
::
utils
::
check_err
(
out_tensor
.
mData
,
ref_data
,
"Error [case 2]: incorrect results!"
,
1e-4
f
,
1e-6
f
));
out_tensor
.
mData
,
ref_data
,
"Error [case 2]: incorrect results!"
,
1e-4
f
,
1e-6
f
);
return
res
;
}
}
// anonymous namespace
int
main
(
void
)
{
bool
res
{
true
};
res
=
test_conv2d_nhwc
();
std
::
cout
<<
"test_conv2d_nhwc ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv1d_nwc
();
std
::
cout
<<
"TestConv1DNHWC ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
res
=
test_conv3d_ncdhw
();
std
::
cout
<<
"test_conv3d_ncdhw ..... "
<<
(
res
?
"SUCCESS"
:
"FAILURE"
)
<<
std
::
endl
;
return
res
?
0
:
1
;
}
}
Prev
1
2
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