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_ROCM
Commits
b134b7d6
Commit
b134b7d6
authored
May 16, 2022
by
carlushuang
Browse files
Merge remote-tracking branch 'origin/develop' into cpu_avx2
parents
090ba885
9f71ff48
Changes
211
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
942 additions
and
685 deletions
+942
-685
script/profile_gemm.sh
script/profile_gemm.sh
+14
-6
test/CMakeLists.txt
test/CMakeLists.txt
+19
-2
test/batched_gemm_reduce/batched_gemm_reduce_fp16.cpp
test/batched_gemm_reduce/batched_gemm_reduce_fp16.cpp
+4
-4
test/client_app/CMakeLists.txt
test/client_app/CMakeLists.txt
+11
-0
test/client_app/client_app.cpp
test/client_app/client_app.cpp
+77
-0
test/client_app/client_app_impl.hpp
test/client_app/client_app_impl.hpp
+214
-0
test/conv2d_bwd_weight/CMakeLists.txt
test/conv2d_bwd_weight/CMakeLists.txt
+1
-1
test/conv2d_bwd_weight/conv2d_bwd_weight.cpp
test/conv2d_bwd_weight/conv2d_bwd_weight.cpp
+53
-53
test/conv_util/CMakeLists.txt
test/conv_util/CMakeLists.txt
+2
-2
test/conv_util/conv_util.cpp
test/conv_util/conv_util.cpp
+165
-166
test/convnd_bwd_data/CMakeLists.txt
test/convnd_bwd_data/CMakeLists.txt
+1
-1
test/convnd_bwd_data/convnd_bwd_data.cpp
test/convnd_bwd_data/convnd_bwd_data.cpp
+156
-156
test/convnd_fwd/CMakeLists.txt
test/convnd_fwd/CMakeLists.txt
+6
-8
test/convnd_fwd/conv1d_fwd.cpp
test/convnd_fwd/conv1d_fwd.cpp
+50
-71
test/convnd_fwd/conv2d_fwd.cpp
test/convnd_fwd/conv2d_fwd.cpp
+49
-64
test/convnd_fwd/conv3d_fwd.cpp
test/convnd_fwd/conv3d_fwd.cpp
+116
-147
test/convnd_fwd/conv_util.hpp
test/convnd_fwd/conv_util.hpp
+0
-1
test/convnd_fwd_cpu/conv2d_fwd_cpu.cpp
test/convnd_fwd_cpu/conv2d_fwd_cpu.cpp
+2
-1
test/gemm/gemm_bf16.cpp
test/gemm/gemm_bf16.cpp
+1
-1
test/gemm/gemm_fp16.cpp
test/gemm/gemm_fp16.cpp
+1
-1
No files found.
script/profile_gemm.sh
View file @
b134b7d6
#!/bin/bash
## GPU visibility
export
HIP_VISIBLE_DEVICES
=
0
make
-j
ckProfiler
DRIVER
=
"./profiler/ckProfiler"
export
HIP_VISIBLE_DEVICES
=
0
#make -j ckProfiler
DRIVER
=
"../build/bin/ckProfiler"
echo
$DRIVER
OP
=
$1
DATATYPE
=
$2
LAYOUT
=
$3
...
...
@@ -43,3 +41,13 @@ $DRIVER $OP $DATATYPE $LAYOUT $VERIFY $INIT $LOG $REPEAT 1024 1024 1024 1088 1
$DRIVER
$OP
$DATATYPE
$LAYOUT
$VERIFY
$INIT
$LOG
$REPEAT
2048 2048 2048 2112 2112 2112
$DRIVER
$OP
$DATATYPE
$LAYOUT
$VERIFY
$INIT
$LOG
$REPEAT
4096 4096 4096 4160 4160 4160
$DRIVER
$OP
$DATATYPE
$LAYOUT
$VERIFY
$INIT
$LOG
$REPEAT
8192 8192 8192 8256 8256 8256
$DRIVER
$OP
$DATATYPE
$LAYOUT
$VERIFY
$INIT
$LOG
$REPEAT
6656 8192 8192
-1
-1
-1
$DRIVER
$OP
$DATATYPE
$LAYOUT
$VERIFY
$INIT
$LOG
$REPEAT
3328 4096 4096
-1
-1
-1
$DRIVER
$OP
$DATATYPE
$LAYOUT
$VERIFY
$INIT
$LOG
$REPEAT
1664 2048 2048
-1
-1
-1
$DRIVER
$OP
$DATATYPE
$LAYOUT
$VERIFY
$INIT
$LOG
$REPEAT
832 1024 1024
-1
-1
-1
$DRIVER
$OP
$DATATYPE
$LAYOUT
$VERIFY
$INIT
$LOG
$REPEAT
7040 8192 8192
-1
-1
-1
$DRIVER
$OP
$DATATYPE
$LAYOUT
$VERIFY
$INIT
$LOG
$REPEAT
5120 5632 4096
-1
-1
-1
$DRIVER
$OP
$DATATYPE
$LAYOUT
$VERIFY
$INIT
$LOG
$REPEAT
2560 2816 2048
-1
-1
-1
$DRIVER
$OP
$DATATYPE
$LAYOUT
$VERIFY
$INIT
$LOG
$REPEAT
1280 1408 1024
-1
-1
-1
test/CMakeLists.txt
View file @
b134b7d6
include_directories
(
BEFORE
${
PROJECT_SOURCE_DIR
}
/
${
PROJECT_SOURCE_DIR
}
/include/ck
${
PROJECT_SOURCE_DIR
}
/include/ck/utility
${
PROJECT_SOURCE_DIR
}
/include/ck/tensor_description
...
...
@@ -26,9 +27,11 @@ include_directories(BEFORE
${
PROJECT_SOURCE_DIR
}
/external/include/half
)
add_custom_target
(
check COMMAND
${
CMAKE_CTEST_COMMAND
}
--output-on-failure -C
${
CMAKE_CFG_INTDIR
}
)
include
(
googletest
)
add_custom_target
(
tests
)
function
(
add_test_executable TEST_NAME
)
message
(
"adding test
${
TEST_NAME
}
"
)
add_executable
(
${
TEST_NAME
}
${
ARGN
}
)
...
...
@@ -37,6 +40,19 @@ function(add_test_executable TEST_NAME)
add_dependencies
(
check
${
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 -Wno-undef
)
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
(
space_filling_curve
)
...
...
@@ -51,7 +67,8 @@ add_subdirectory(grouped_gemm)
add_subdirectory
(
convnd_fwd
)
add_subdirectory
(
reduce
)
add_subdirectory
(
conv2d_bwd_weight
)
add_subdirectory
(
convnd_bwd_data
)
add_subdirectory
(
cpu_ukernel
)
add_subdirectory
(
cpu_threadwise_transfer
)
add_subdirectory
(
convnd_fwd_cpu
)
# DONOT add client_app, that is tested via CI independently
test/batched_gemm_reduce/batched_gemm_reduce_fp16.cpp
View file @
b134b7d6
...
...
@@ -22,7 +22,7 @@ int main()
Row
,
Row
,
Row
>
(
true
,
1
,
false
,
1
,
M
,
N
,
K
,
K
,
N
,
N
,
BatchCount
);
true
,
1
,
false
,
false
,
M
,
N
,
K
,
K
,
N
,
N
,
BatchCount
);
pass
=
pass
&&
ck
::
profiler
::
profile_batched_gemm_reduce_impl
<
ck
::
half_t
,
ck
::
half_t
,
...
...
@@ -31,7 +31,7 @@ int main()
Row
,
Col
,
Row
>
(
true
,
1
,
false
,
1
,
M
,
N
,
K
,
K
,
K
,
N
,
BatchCount
);
true
,
1
,
false
,
false
,
M
,
N
,
K
,
K
,
K
,
N
,
BatchCount
);
pass
=
pass
&&
ck
::
profiler
::
profile_batched_gemm_reduce_impl
<
ck
::
half_t
,
ck
::
half_t
,
...
...
@@ -40,7 +40,7 @@ int main()
Col
,
Row
,
Row
>
(
true
,
1
,
false
,
1
,
M
,
N
,
K
,
M
,
N
,
N
,
BatchCount
);
true
,
1
,
false
,
false
,
M
,
N
,
K
,
M
,
N
,
N
,
BatchCount
);
pass
=
pass
&&
ck
::
profiler
::
profile_batched_gemm_reduce_impl
<
ck
::
half_t
,
ck
::
half_t
,
...
...
@@ -49,7 +49,7 @@ int main()
Col
,
Col
,
Row
>
(
true
,
1
,
false
,
1
,
M
,
N
,
K
,
M
,
K
,
N
,
BatchCount
);
true
,
1
,
false
,
false
,
M
,
N
,
K
,
M
,
K
,
N
,
BatchCount
);
if
(
pass
)
{
...
...
test/client_app/CMakeLists.txt
0 → 100644
View file @
b134b7d6
cmake_minimum_required
(
VERSION 3.15
)
project
(
ck_app
)
add_compile_options
(
-std=c++14
)
find_package
(
composable_kernel 1.0.0 COMPONENTS device_operations host_tensor
)
find_package
(
hip REQUIRED PATHS /opt/rocm
)
message
(
STATUS
"Build with HIP
${
hip_VERSION
}
"
)
add_executable
(
test_client_app client_app.cpp
)
target_link_libraries
(
test_client_app PRIVATE composable_kernel::device_operations composable_kernel::host_tensor hip::host
)
test/client_app/client_app.cpp
0 → 100644
View file @
b134b7d6
#include <iostream>
#include <numeric>
#include <initializer_list>
#include <cstdlib>
#include <stdlib.h>
#include <half.hpp>
#include <vector>
#include "client_app_impl.hpp"
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
25
)
{
printf
(
"arg1: tensor operation (conv_fwd: ForwardConvolution)
\n
"
);
printf
(
"arg2: data type (0: fp32; 1: fp16)
\n
"
);
printf
(
"arg3: input tensor layout (0: NCHW; 1: NHWC)
\n
"
);
printf
(
"arg4: weight tensor layout (0: KCYX; 1: KYXC)
\n
"
);
printf
(
"arg5: output tensor layout (0: NKHW; 1: NHWK)
\n
"
);
printf
(
"arg6: verification (0: no; 1: yes)
\n
"
);
printf
(
"arg7: initialization (0: no init; 1: integer value; 2: decimal value)
\n
"
);
printf
(
"arg8: print tensor value (0: no; 1: yes)
\n
"
);
printf
(
"arg9: time kernel (0=n0, 1=yes)
\n
"
);
printf
(
"arg10 to 24: N, K, C, Y, X, Hi, Wi, Sy, Sx, Dy, Dx, LeftPy, LeftPx, RightPy, "
"RightPx
\n
"
);
exit
(
1
);
}
const
ConvDataType
data_type
=
static_cast
<
ConvDataType
>
(
std
::
stoi
(
argv
[
2
]));
const
int
in_layout
=
static_cast
<
ConvInputLayout
>
(
std
::
stoi
(
argv
[
3
]));
const
int
wei_layout
=
static_cast
<
ConvWeightLayout
>
(
std
::
stoi
(
argv
[
4
]));
const
int
out_layout
=
static_cast
<
ConvOutputLayout
>
(
std
::
stoi
(
argv
[
5
]));
const
bool
do_verification
=
std
::
stoi
(
argv
[
6
]);
const
int
init_method
=
std
::
stoi
(
argv
[
7
]);
const
bool
do_log
=
std
::
stoi
(
argv
[
8
]);
const
bool
time_kernel
=
std
::
stoi
(
argv
[
9
]);
const
ck
::
index_t
N
=
std
::
stoi
(
argv
[
10
]);
const
ck
::
index_t
K
=
std
::
stoi
(
argv
[
11
]);
const
ck
::
index_t
C
=
std
::
stoi
(
argv
[
12
]);
const
ck
::
index_t
Y
=
std
::
stoi
(
argv
[
13
]);
const
ck
::
index_t
X
=
std
::
stoi
(
argv
[
14
]);
const
ck
::
index_t
Hi
=
std
::
stoi
(
argv
[
15
]);
const
ck
::
index_t
Wi
=
std
::
stoi
(
argv
[
16
]);
const
ck
::
index_t
conv_stride_h
=
std
::
stoi
(
argv
[
17
]);
const
ck
::
index_t
conv_stride_w
=
std
::
stoi
(
argv
[
18
]);
const
ck
::
index_t
conv_dilation_h
=
std
::
stoi
(
argv
[
19
]);
const
ck
::
index_t
conv_dilation_w
=
std
::
stoi
(
argv
[
20
]);
const
ck
::
index_t
in_left_pad_h
=
std
::
stoi
(
argv
[
21
]);
const
ck
::
index_t
in_left_pad_w
=
std
::
stoi
(
argv
[
22
]);
const
ck
::
index_t
in_right_pad_h
=
std
::
stoi
(
argv
[
23
]);
const
ck
::
index_t
in_right_pad_w
=
std
::
stoi
(
argv
[
24
]);
const
ck
::
index_t
YEff
=
(
Y
-
1
)
*
conv_dilation_h
+
1
;
const
ck
::
index_t
XEff
=
(
X
-
1
)
*
conv_dilation_w
+
1
;
const
ck
::
index_t
Ho
=
(
Hi
+
in_left_pad_h
+
in_right_pad_h
-
YEff
)
/
conv_stride_h
+
1
;
const
ck
::
index_t
Wo
=
(
Wi
+
in_left_pad_w
+
in_right_pad_w
-
XEff
)
/
conv_stride_w
+
1
;
ck
::
app
::
profile_conv_fwd_impl
(
do_verification
,
init_method
,
do_log
,
time_kernel
,
data_type
,
N
,
K
,
C
,
std
::
vector
<
ck
::
index_t
>
{
Hi
,
Wi
},
std
::
vector
<
ck
::
index_t
>
{
Y
,
X
},
std
::
vector
<
ck
::
index_t
>
{
Ho
,
Wo
},
std
::
vector
<
ck
::
index_t
>
{
conv_stride_h
,
conv_stride_w
},
std
::
vector
<
ck
::
index_t
>
{
conv_dilation_h
,
conv_dilation_w
},
std
::
vector
<
ck
::
index_t
>
{
in_left_pad_h
,
in_left_pad_w
},
std
::
vector
<
ck
::
index_t
>
{
in_right_pad_h
,
in_right_pad_w
});
return
1
;
}
test/client_app/client_app_impl.hpp
0 → 100644
View file @
b134b7d6
#pragma once
#include "host_interface.hpp"
enum
ConvDataType
{
F32_F32_F32
,
// 0
F16_F16_F16
,
// 1
BF16_BF16_BF16
,
// 2
INT8_INT8_INT8
,
// 3
};
enum
ConvInputLayout
{
NCHW
,
// 0
NHWC
,
// 1
};
enum
ConvWeightLayout
{
KCYX
,
// 0
KYXC
,
// 1
};
enum
ConvOutputLayout
{
NKHW
,
// 0
NHWK
,
// 1
};
void
check_hip_error
(
void
)
{
hipError_t
err
=
hipGetLastError
();
if
(
err
!=
hipSuccess
)
{
std
::
cerr
<<
"Error: "
<<
hipGetErrorString
(
err
)
<<
std
::
endl
;
exit
(
err
);
}
}
std
::
string
getDeviceName
(
int
device
)
{
struct
hipDeviceProp_t
prop
;
hipGetDeviceProperties
(
&
prop
,
device
);
check_hip_error
();
return
std
::
string
(
prop
.
name
);
}
int
getDriver
(
void
)
{
int
driver
;
hipDriverGetVersion
(
&
driver
);
check_hip_error
();
return
driver
;
}
namespace
ck
{
namespace
app
{
struct
DeviceMem
{
DeviceMem
()
=
delete
;
DeviceMem
(
std
::
size_t
mem_size
);
void
*
GetDeviceBuffer
();
void
ToDevice
(
const
void
*
p
);
void
FromDevice
(
void
*
p
);
~
DeviceMem
();
void
*
mpDeviceBuf
;
std
::
size_t
mMemSize
;
};
DeviceMem
::
DeviceMem
(
std
::
size_t
mem_size
)
:
mMemSize
(
mem_size
)
{
hipGetErrorString
(
hipMalloc
(
static_cast
<
void
**>
(
&
mpDeviceBuf
),
mMemSize
));
}
void
*
DeviceMem
::
GetDeviceBuffer
()
{
return
mpDeviceBuf
;
}
void
DeviceMem
::
ToDevice
(
const
void
*
p
)
{
hipGetErrorString
(
hipMemcpy
(
mpDeviceBuf
,
const_cast
<
void
*>
(
p
),
mMemSize
,
hipMemcpyHostToDevice
));
}
void
DeviceMem
::
FromDevice
(
void
*
p
)
{
hipGetErrorString
(
hipMemcpy
(
p
,
mpDeviceBuf
,
mMemSize
,
hipMemcpyDeviceToHost
));
}
DeviceMem
::~
DeviceMem
()
{
hipGetErrorString
(
hipFree
(
mpDeviceBuf
));
}
void
profile_conv_fwd_impl
(
int
do_verification
,
int
init_method
,
bool
do_log
,
bool
time_kernel
,
ConvDataType
data_type
,
ck
::
index_t
N
,
ck
::
index_t
K
,
ck
::
index_t
C
,
std
::
vector
<
ck
::
index_t
>
input_spatial_lengths
,
std
::
vector
<
ck
::
index_t
>
filter_spatial_lengths
,
std
::
vector
<
ck
::
index_t
>
output_spatial_lengths
,
std
::
vector
<
ck
::
index_t
>
conv_filter_strides
,
std
::
vector
<
ck
::
index_t
>
conv_filter_dilations
,
std
::
vector
<
ck
::
index_t
>
input_left_pads
,
std
::
vector
<
ck
::
index_t
>
input_right_pads
)
{
const
ck
::
index_t
Y
=
filter_spatial_lengths
[
0
];
const
ck
::
index_t
X
=
filter_spatial_lengths
[
1
];
const
ck
::
index_t
Hi
=
input_spatial_lengths
[
0
];
const
ck
::
index_t
Wi
=
input_spatial_lengths
[
1
];
const
ck
::
index_t
Ho
=
output_spatial_lengths
[
0
];
const
ck
::
index_t
Wo
=
output_spatial_lengths
[
1
];
const
auto
in_sz
=
N
*
C
*
Hi
*
Wi
;
const
auto
wei_sz
=
K
*
C
*
Y
*
X
;
const
auto
out_sz
=
N
*
K
*
Ho
*
Wo
;
using
WeiDataType
=
float
;
using
InDataType
=
float
;
using
OutDataType
=
float
;
app
::
DeviceMem
in_device_buf
(
sizeof
(
InDataType
)
*
in_sz
);
app
::
DeviceMem
wei_device_buf
(
sizeof
(
WeiDataType
)
*
wei_sz
);
app
::
DeviceMem
out_device_buf
(
sizeof
(
OutDataType
)
*
out_sz
);
// data is already on device!
// add device Conv instances
std
::
vector
<
DeviceConvFwdPtr_t
>
conv_ptrs
;
if
(
data_type
==
F16_F16_F16
)
{
add_device_conv2d_fwd_xdl_c_shuffle_nhwc_kyxc_nhwk_f16_instances_t
(
conv_ptrs
);
add_device_conv2d_fwd_xdl_nhwc_kyxc_nhwk_f16_instances_t
(
conv_ptrs
);
}
else
if
(
data_type
==
BF16_BF16_BF16
)
add_device_conv2d_fwd_xdl_nhwc_kyxc_nhwk_bf16_instances_t
(
conv_ptrs
);
else
if
(
data_type
==
F32_F32_F32
)
add_device_conv2d_fwd_xdl_nhwc_kyxc_nhwk_f32_instances_t
(
conv_ptrs
);
else
if
(
data_type
==
INT8_INT8_INT8
)
add_device_conv2d_fwd_xdl_nhwc_kyxc_nhwk_int8_instances_t
(
conv_ptrs
);
else
throw
std
::
runtime_error
(
"wrong! Invalid data type"
);
if
(
conv_ptrs
.
empty
())
{
throw
std
::
runtime_error
(
"wrong! no device Conv instance found"
);
}
std
::
string
best_conv_name
;
float
best_ave_time
=
0
;
float
best_tflops
=
0
;
float
best_gb_per_sec
=
0
;
int
deviceIndex
=
0
;
hipSetDevice
(
deviceIndex
);
check_hip_error
();
StreamConfig
stream_config
{
nullptr
,
time_kernel
};
hipStreamCreate
(
&
stream_config
.
stream_id_
);
check_hip_error
();
// profile device Conv instances
for
(
auto
&
conv_ptr
:
conv_ptrs
)
{
auto
argument_ptr
=
conv_ptr
.
MakeArgumentPointer
(
static_cast
<
void
*>
(
in_device_buf
.
GetDeviceBuffer
()),
static_cast
<
void
*>
(
wei_device_buf
.
GetDeviceBuffer
()),
static_cast
<
void
*>
(
out_device_buf
.
GetDeviceBuffer
()),
N
,
K
,
C
,
input_spatial_lengths
,
filter_spatial_lengths
,
output_spatial_lengths
,
conv_filter_strides
,
conv_filter_dilations
,
input_left_pads
,
input_right_pads
);
auto
invoker_ptr
=
conv_ptr
.
MakeInvokerPointer
();
if
(
conv_ptr
.
IsSupportedArgument
(
argument_ptr
.
get
()))
{
std
::
string
conv_name
=
conv_ptr
.
GetTypeString
();
float
ave_time
=
invoker_ptr
->
Run
(
argument_ptr
.
get
(),
stream_config
);
std
::
size_t
flop
=
std
::
size_t
(
2
)
*
N
*
K
*
Ho
*
Wo
*
C
*
Y
*
X
;
std
::
size_t
num_btype
=
sizeof
(
InDataType
)
*
(
N
*
C
*
Hi
*
Wi
)
+
sizeof
(
WeiDataType
)
*
(
K
*
C
*
Y
*
X
)
+
sizeof
(
OutDataType
)
*
(
N
*
K
*
Ho
*
Wo
);
float
tflops
=
static_cast
<
float
>
(
flop
)
/
1.E9
/
ave_time
;
float
gb_per_sec
=
num_btype
/
1.E6
/
ave_time
;
std
::
cout
<<
"Perf: "
<<
ave_time
<<
" ms, "
<<
tflops
<<
" TFlops, "
<<
gb_per_sec
<<
" GB/s, "
<<
conv_name
<<
std
::
endl
;
if
(
tflops
>
best_tflops
)
{
best_conv_name
=
conv_name
;
best_tflops
=
tflops
;
best_ave_time
=
ave_time
;
best_gb_per_sec
=
gb_per_sec
;
}
}
}
std
::
cout
<<
"Best Perf: "
<<
best_ave_time
<<
" ms, "
<<
best_tflops
<<
" TFlops, "
<<
best_gb_per_sec
<<
" GB/s, "
<<
best_conv_name
<<
std
::
endl
;
}
}
// namespace app
}
// namespace ck
test/conv2d_bwd_weight/CMakeLists.txt
View file @
b134b7d6
...
...
@@ -4,4 +4,4 @@ include_directories(BEFORE
)
add_test_executable
(
test_conv2d_bwd_weight conv2d_bwd_weight.cpp
)
target_link_libraries
(
test_conv2d_bwd_weight PRIVATE host_tensor device_conv2d_bwd_weight_instance conv_
fwd_
util
)
target_link_libraries
(
test_conv2d_bwd_weight PRIVATE host_tensor device_conv2d_bwd_weight_instance conv_util
)
test/conv2d_bwd_weight/conv2d_bwd_weight.cpp
View file @
b134b7d6
...
...
@@ -6,7 +6,7 @@
#include <half.hpp>
#include <vector>
#include "conv_
fwd_
util.hpp"
#include "conv_util.hpp"
#include "profile_conv_bwd_weight_impl.hpp"
int
test_self
()
...
...
@@ -28,20 +28,20 @@ int test_self()
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
>
(
1
,
// do_verification
,
1
,
// init_method
,
0
,
// do_log
,
1
,
// nrepeat,
param
.
N
,
param
.
K
,
param
.
C
,
param
.
input_spatial_lengths
,
param
.
filter_spatial_lengths
,
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
.
conv_filter_strides
_
,
param
.
conv_filter_dilations
_
,
param
.
input_left_pads
_
,
param
.
input_right_pads
_
,
2
);
// fp16
...
...
@@ -52,28 +52,28 @@ int test_self()
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
>
(
1
,
// do_verification
,
1
,
// init_method
,
0
,
// do_log
,
1
,
// nrepeat,
param
.
N
,
param
.
K
,
param
.
C
,
param
.
input_spatial_lengths
,
param
.
filter_spatial_lengths
,
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
.
conv_filter_strides
_
,
param
.
conv_filter_dilations
_
,
param
.
input_left_pads
_
,
param
.
input_right_pads
_
,
2
);
}
return
pass
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
data_type
=
0
;
int
init_method
=
0
;
int
data_type
=
1
;
int
init_method
=
1
;
// Conv shape
ck
::
index_t
N
=
128
;
...
...
@@ -155,20 +155,20 @@ int main(int argc, char* argv[])
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
>
(
1
,
true
,
// do_verification
init_method
,
0
,
1
,
param
.
N
,
param
.
K
,
param
.
C
,
param
.
input_spatial_lengths
,
param
.
filter_spatial_lengths
,
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
.
conv_filter_strides
_
,
param
.
conv_filter_dilations
_
,
param
.
input_left_pads
_
,
param
.
input_right_pads
_
,
split_k
);
}
else
if
(
data_type
==
1
)
...
...
@@ -180,20 +180,20 @@ int main(int argc, char* argv[])
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
>
(
1
,
true
,
// do_verification
init_method
,
0
,
1
,
param
.
N
,
param
.
K
,
param
.
C
,
param
.
input_spatial_lengths
,
param
.
filter_spatial_lengths
,
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
.
conv_filter_strides
_
,
param
.
conv_filter_dilations
_
,
param
.
input_left_pads
_
,
param
.
input_right_pads
_
,
split_k
);
}
else
...
...
test/conv_util/CMakeLists.txt
View file @
b134b7d6
add_test_executable
(
test_conv_util conv_util.cpp
)
target_link_libraries
(
test_conv_util PRIVATE host_tensor conv_
fwd_
util
)
add_
g
test_executable
(
test_conv_util conv_util.cpp
)
target_link_libraries
(
test_conv_util PRIVATE host_tensor conv_util
)
test/conv_util/conv_util.cpp
View file @
b134b7d6
#include <iostream>
#include <string>
#include <vector>
#include <gtest/gtest.h>
#include "config.hpp"
#include "conv_
fwd_
util.hpp"
#include "conv_util.hpp"
#include "tensor_layout.hpp"
#include "check_err.hpp"
namespace
{
bool
t
est
_c
onv
_params_get_output_spatial_lengths
()
class
T
est
C
onv
Util
:
public
::
testing
::
Test
{
bool
res
{
true
};
// -------------------------- default 2D ------------------------------------
public:
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},
// weights KCYX {256,192,3,3},
// stride {2,2},
// dilations {1,1},
// padding {{1,1}, {1,1}}
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
();
res
=
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
},
"Error: ConvParams 2D default constructor."
);
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
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
.
input_left_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
();
res
=
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
37
,
37
},
"Error: ConvParams 2D padding left/right {2,2}."
);
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
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
.
input_left_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
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
},
"Error: ConvParams 2D default constructor."
)
)
;
conv_params
.
conv_filter_strides
_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
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
.
input_left_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
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
37
,
37
},
"Error: ConvParams 2D padding left/right {2,2}."
)
)
;
conv_params
.
conv_filter_dilations
_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
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
.
input_left_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
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
23
,
23
},
"Error: ConvParams 2D strides{3,3}, padding {1,1}, dilations {2,2}."
);
// -------------------------- 1D ------------------------------------
conv_params
.
num_dim_spatial
=
1
;
conv_params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
};
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
();
res
=
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
},
"Error: ConvParams 1D."
);
conv_params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
1
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
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
.
input_left_pads
=
std
::
vector
<
ck
::
index_t
>
{
2
};
conv_params
.
input_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
37
},
"Error: ConvParams 1D padding left/right {2}."
);
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
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
.
input_left_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
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
23
},
"Error: ConvParams 1D strides{3}, padding {1}, dilations {2}."
);
// -------------------------- 3D ------------------------------------
conv_params
.
num_dim_spatial
=
3
;
conv_params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
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
();
res
=
ck
::
utils
::
check_err
(
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
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
71
,
71
,
71
},
"Error: ConvParams 3D stride {1, 1, 1}."
);
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_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
37
,
37
,
37
},
"Error: ConvParams 3D padding left/right {2, 2, 2}."
);
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
,
36
},
"Error: ConvParams 3D dilation {2, 2, 2}."
);
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_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
conv_params
.
conv_filter_dilations
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
res
=
ck
::
utils
::
check_err
(
"Error: ConvParams 2D strides{3,3}, padding {1,1}, dilations {2,2}."
));
}
TEST_F
(
TestConvUtil
,
ConvParamsGetOutputSpatialLengths1D
)
{
SetNDParams
(
1
);
std
::
vector
<
ck
::
index_t
>
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
},
"Error: ConvParams 1D."
));
conv_params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
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
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
conv_params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
37
},
"Error: ConvParams 1D padding left/right {2}."
));
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
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
.
input_left_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
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
23
},
"Error: ConvParams 1D strides{3}, padding {1}, dilations {2}."
));
}
TEST_F
(
TestConvUtil
,
ConvParamsGetOutputSpatialLengths3D
)
{
SetNDParams
(
3
);
std
::
vector
<
ck
::
index_t
>
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
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
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
71
,
71
,
71
},
"Error: ConvParams 3D stride {1, 1, 1}."
));
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_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
37
,
37
,
37
},
"Error: ConvParams 3D padding left/right {2, 2, 2}."
));
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
36
,
36
,
36
},
"Error: ConvParams 3D dilation {2, 2, 2}."
));
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_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
conv_params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
out_spatial_len
=
conv_params
.
GetOutputSpatialLengths
();
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
out_spatial_len
,
std
::
vector
<
ck
::
index_t
>
{
23
,
23
,
23
},
"Error: ConvParams 3D strides{3, 3, 3}, padding {1, 1, 1}, dilations {2, 2, 2}."
);
return
res
;
"Error: ConvParams 3D strides{3, 3, 3}, padding {1, 1, 1}, dilations {2, 2, 2}."
));
}
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
;
std
::
vector
<
std
::
size_t
>
dims
{
2
,
3
,
4
,
5
};
HostTensorDescriptor
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NHWC
{});
res
=
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
,
5
},
"Error: wrong NHWC dimensions lengths!"
);
res
=
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
*
5
,
1
,
3
*
5
,
3
},
"Error: wrong NHWC dimensions strides!"
);
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
,
5
},
"Error: wrong NHWC dimensions lengths!"
)
)
;
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
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
{});
res
=
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
,
5
},
"Error: wrong NCHW dimensions lengths!"
);
res
=
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
*
5
,
4
*
5
,
5
,
1
},
"Error: wrong NCHW dimensions strides!"
);
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
,
5
},
"Error: wrong NCHW dimensions lengths!"
)
)
;
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
*
5
,
4
*
5
,
5
,
1
},
"Error: wrong NCHW dimensions strides!"
)
)
;
dims
=
std
::
vector
<
std
::
size_t
>
{
2
,
3
,
4
};
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!"
);
res
=
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
,
1
,
3
},
"Error: wrong NWC dimensions strides!"
);
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
},
"Error: wrong NWC dimensions lengths!"
));
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
{});
res
=
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
},
"Error: wrong NCW dimensions lengths!"
);
res
=
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
,
4
,
1
},
"Error: wrong NCW dimensions strides!"
);
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NCW
{});
EXPECT_TRUE
(
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
{
2
,
3
,
4
},
"Error: wrong NCW dimensions lengths!"
));
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
};
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NDHWC
{});
res
=
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
dims
,
"Error: wrong NDHWC dimensions lengths!"
);
res
=
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
*
5
*
6
,
// N
1
,
// C
3
*
5
*
6
,
// D
3
*
6
,
// H
3
},
// W
"Error: wrong NDHWC dimensions strides!"
);
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NCDHW
{});
res
=
ck
::
utils
::
check_err
(
h
.
GetLengths
(),
dims
,
"Error: wrong NCDHW dimensions lengths!"
);
res
=
ck
::
utils
::
check_err
(
h
.
GetStrides
(),
{
3
*
4
*
5
*
6
,
// N
4
*
5
*
6
,
// C
5
*
6
,
// D
6
,
// H
1
},
// W
"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
;
EXPECT_TRUE
(
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
1
,
// C
3
*
5
*
6
,
// D
3
*
6
,
// H
3
},
// W
"Error: wrong NDHWC dimensions strides!"
));
h
=
ck
::
utils
::
conv
::
get_host_tensor_descriptor
(
dims
,
tl
::
NCDHW
{});
EXPECT_TRUE
(
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
4
*
5
*
6
,
// C
5
*
6
,
// D
6
,
// H
1
},
// W
"Error: wrong NCDHW dimensions strides!"
));
}
test/convnd_bwd_data/CMakeLists.txt
View file @
b134b7d6
...
...
@@ -4,4 +4,4 @@ include_directories(BEFORE
)
add_test_executable
(
test_convnd_bwd_data convnd_bwd_data.cpp
)
target_link_libraries
(
test_convnd_bwd_data PRIVATE host_tensor device_convnd_bwd_data_instance conv_
fwd_
util
)
target_link_libraries
(
test_convnd_bwd_data PRIVATE host_tensor device_convnd_bwd_data_instance conv_util
)
test/convnd_bwd_data/convnd_bwd_data.cpp
View file @
b134b7d6
...
...
@@ -27,20 +27,20 @@ int main()
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
>
(
1
,
// do_verification
,
1
,
// init_method
,
0
,
// do_log
,
1
,
// nrepeat,
param
.
N
,
param
.
K
,
param
.
C
,
param
.
input_spatial_lengths
,
param
.
filter_spatial_lengths
,
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
.
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
,
...
...
@@ -50,20 +50,20 @@ int main()
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
>
(
1
,
// do_verification
,
1
,
// init_method
,
0
,
// do_log
,
1
,
// nrepeat,
param
.
N
,
param
.
K
,
param
.
C
,
param
.
input_spatial_lengths
,
param
.
filter_spatial_lengths
,
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
.
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
,
...
...
@@ -73,20 +73,20 @@ int main()
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
>
(
1
,
// do_verification
,
1
,
// init_method
,
0
,
// do_log
,
1
,
// nrepeat,
param
.
N
,
param
.
K
,
param
.
C
,
param
.
input_spatial_lengths
,
param
.
filter_spatial_lengths
,
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
.
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
,
...
...
@@ -96,20 +96,20 @@ int main()
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
>
(
1
,
// do_verification
,
1
,
// init_method
,
0
,
// do_log
,
1
,
// nrepeat,
param
.
N
,
param
.
K
,
param
.
C
,
param
.
input_spatial_lengths
,
param
.
filter_spatial_lengths
,
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
.
conv_filter_strides
_
,
param
.
conv_filter_dilations
_
,
param
.
input_left_pads
_
,
param
.
input_right_pads
_
);
}
// check 2d
...
...
@@ -128,20 +128,20 @@ int main()
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
>
(
1
,
// do_verification
,
1
,
// init_method
,
0
,
// do_log
,
1
,
// nrepeat,
param
.
N
,
param
.
K
,
param
.
C
,
param
.
input_spatial_lengths
,
param
.
filter_spatial_lengths
,
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
.
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
,
...
...
@@ -151,20 +151,20 @@ int main()
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
>
(
1
,
// do_verification
,
1
,
// init_method
,
0
,
// do_log
,
1
,
// nrepeat,
param
.
N
,
param
.
K
,
param
.
C
,
param
.
input_spatial_lengths
,
param
.
filter_spatial_lengths
,
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
.
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
,
...
...
@@ -174,20 +174,20 @@ int main()
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
>
(
1
,
// do_verification
,
1
,
// init_method
,
0
,
// do_log
,
1
,
// nrepeat,
param
.
N
,
param
.
K
,
param
.
C
,
param
.
input_spatial_lengths
,
param
.
filter_spatial_lengths
,
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
.
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
,
...
...
@@ -197,20 +197,20 @@ int main()
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
>
(
1
,
// do_verification
,
1
,
// init_method
,
0
,
// do_log
,
1
,
// nrepeat,
param
.
N
,
param
.
K
,
param
.
C
,
param
.
input_spatial_lengths
,
param
.
filter_spatial_lengths
,
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
.
conv_filter_strides
_
,
param
.
conv_filter_dilations
_
,
param
.
input_left_pads
_
,
param
.
input_right_pads
_
);
}
// check 3d
...
...
@@ -232,20 +232,20 @@ int main()
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
>
(
1
,
// do_verification
,
1
,
// init_method
,
0
,
// do_log
,
1
,
// nrepeat,
param
.
N
,
param
.
K
,
param
.
C
,
param
.
input_spatial_lengths
,
param
.
filter_spatial_lengths
,
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
.
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
,
...
...
@@ -255,20 +255,20 @@ int main()
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
>
(
1
,
// do_verification
,
1
,
// init_method
,
0
,
// do_log
,
1
,
// nrepeat,
param
.
N
,
param
.
K
,
param
.
C
,
param
.
input_spatial_lengths
,
param
.
filter_spatial_lengths
,
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
.
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
,
...
...
@@ -278,20 +278,20 @@ int main()
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
>
(
1
,
// do_verification
,
1
,
// init_method
,
0
,
// do_log
,
1
,
// nrepeat,
param
.
N
,
param
.
K
,
param
.
C
,
param
.
input_spatial_lengths
,
param
.
filter_spatial_lengths
,
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
.
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
,
...
...
@@ -301,20 +301,20 @@ int main()
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
>
(
1
,
// do_verification
,
1
,
// init_method
,
0
,
// do_log
,
1
,
// nrepeat,
param
.
N
,
param
.
K
,
param
.
C
,
param
.
input_spatial_lengths
,
param
.
filter_spatial_lengths
,
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
.
conv_filter_strides
_
,
param
.
conv_filter_dilations
_
,
param
.
input_left_pads
_
,
param
.
input_right_pads
_
);
}
if
(
pass
)
...
...
test/convnd_fwd/CMakeLists.txt
View file @
b134b7d6
add_custom_target
(
test_convnd_fwd
)
add_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
)
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_test_executable
(
test_conv2d_fwd conv2d_fwd.cpp
)
target_link_libraries
(
test_conv2d_fwd PRIVATE host_tensor device_conv2d_fwd_instance conv_
fwd_
util
)
add_
g
test_executable
(
test_conv2d_fwd conv2d_fwd.cpp
)
target_link_libraries
(
test_conv2d_fwd PRIVATE host_tensor device_conv2d_fwd_instance conv_util
)
add_dependencies
(
test_convnd_fwd test_conv2d_fwd
)
add_test_executable
(
test_conv3d_fwd conv3d_fwd.cpp
)
target_link_libraries
(
test_conv3d_fwd PRIVATE host_tensor device_conv3d_fwd_instance conv_
fwd_
util
)
add_
g
test_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
)
test/convnd_fwd/conv1d_fwd.cpp
View file @
b134b7d6
...
...
@@ -2,113 +2,92 @@
#include <stdexcept>
#include <tuple>
#include <vector>
#include "gtest/gtest.h"
#include "data_type.hpp"
#include "element_wise_operation.hpp"
#include "conv
_fwd
_util.hpp"
#include "
library/include/ck/library/utility/
conv_util.hpp"
#include "conv_util.hpp"
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
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
ck
::
utils
::
conv
::
ConvParams
params
;
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
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
16
};
params
.
conv_filter_strides
=
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_right_pads
=
std
::
vector
<
ck
::
index_t
>
{
1
};
params
.
num_dim_spatial_
=
1
;
params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
3
};
params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
71
};
params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
2
};
params
.
conv_filter_dilations_
=
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
};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
1
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
float
,
float
,
float
,
ctl
::
NWC
,
ctl
::
KCX
,
ctl
::
NWK
>
conv_instance
(
params
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NWC
,
ctl
::
KCX
,
ctl
::
NWK
>
conv_instance
(
params
);
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
1
,
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
);
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
);
return
run_engine
.
Test
(
conv_ptrs
);
}
template
<
typename
T
>
bool
test_conv1d_nwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
)
}
// anonymous namespace
TEST
(
Conv1DFwdNWC
,
TestConv1D
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
ck
::
utils
::
conv
::
ConvParams
params
;
params
.
num_dim_spatial
=
1
;
params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
};
params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
71
};
params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
2
};
params
.
conv_filter_dilations
=
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
};
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NWC
,
ctl
::
KCX
,
ctl
::
NWK
>
conv_instance
(
params
);
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
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
16
};
params
.
conv_filter_strides_
=
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_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
};
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
);
return
run_engine
.
Test
(
conv_ptrs
);
}
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
1
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
float
,
float
,
float
,
ctl
::
NWC
,
ctl
::
KCX
,
ctl
::
NWK
>
conv_instance
(
params
);
bool
test_conv1d_nwc_bf16_instances
()
{
return
test_conv1d_nwc_instances
<
ck
::
bhalf_t
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>::
Get
<
1
>
());
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
1
,
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_conv1d_nwc_
f16
_
instances
(
)
TEST
(
Conv1DFwdNWC
,
B
f16
I
instances
)
{
return
test_conv1d_nwc_instances
<
ck
::
half_t
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>::
Get
<
1
>
());
EXPECT_TRUE
(
test_conv1d_nwc_instances
<
ck
::
b
half_t
>
(
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
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
float
,
float
,
floa
t
>::
Get
<
1
>
());
EXPECT_TRUE
(
test_conv1d_nwc_instances
<
ck
::
half_
t
>
(
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
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
int8_t
,
int8_t
,
int8_
t
>::
Get
<
1
>
());
EXPECT_TRUE
(
test_conv1d_nwc_instances
<
floa
t
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
float
,
float
,
floa
t
>::
Get
<
1
>
())
)
;
}
}
// anonymous namespace
int
main
()
TEST
(
Conv1DFwdNWC
,
Int8Instances
)
{
bool
res
{
true
};
res
=
test_conv1D_nwc
();
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
;
EXPECT_TRUE
(
test_conv1d_nwc_instances
<
int8_t
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
int8_t
,
int8_t
,
int8_t
>::
Get
<
1
>
()));
}
test/convnd_fwd/conv2d_fwd.cpp
View file @
b134b7d6
...
...
@@ -2,38 +2,15 @@
#include <iostream>
#include <tuple>
#include <vector>
#include "gtest/gtest.h"
#include "data_type.hpp"
#include "element_wise_operation.hpp"
#include "c
onv_fwd
_util.hpp"
#include "c
k/library/utility/conv
_util.hpp"
#include "conv_util.hpp"
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
>
bool
test_conv2d_nhwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
)
{
...
...
@@ -41,13 +18,13 @@ bool test_conv2d_nhwc_instances(const std::vector<test::conv::DeviceConvFwdNoOpP
using
namespace
ck
::
utils
;
conv
::
ConvParams
params
;
params
.
num_dim_spatial
=
2
;
params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
};
params
.
input_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
71
,
71
};
params
.
conv_filter_strides
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
params
.
conv_filter_dilations
=
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
.
num_dim_spatial
_
=
2
;
params
.
filter_spatial_lengths
_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
};
params
.
input_spatial_lengths
_
=
std
::
vector
<
ck
::
index_t
>
{
71
,
71
};
params
.
conv_filter_strides
_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
};
params
.
conv_filter_dilations
_
=
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
};
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
>
conv_instance
(
params
);
...
...
@@ -57,50 +34,58 @@ bool test_conv2d_nhwc_instances(const std::vector<test::conv::DeviceConvFwdNoOpP
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
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>::
Get
<
2
>
());
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
);
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
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>::
Get
<
2
>
());
EXPECT_TRUE
(
test_conv2d_nhwc_instances
<
ck
::
b
half_t
>
(
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
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
float
,
float
,
floa
t
>::
Get
<
2
>
());
EXPECT_TRUE
(
test_conv2d_nhwc_instances
<
ck
::
half_
t
>
(
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
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
int8_t
,
int8_t
,
int8_
t
>::
Get
<
2
>
());
EXPECT_TRUE
(
test_conv2d_nhwc_instances
<
floa
t
>
(
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
};
res
=
test_conv2d_nhwc
();
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
;
EXPECT_TRUE
(
test_conv2d_nhwc_instances
<
int8_t
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
int8_t
,
int8_t
,
int8_t
>::
Get
<
2
>
()));
}
test/convnd_fwd/conv3d_fwd.cpp
View file @
b134b7d6
...
...
@@ -3,31 +3,59 @@
#include <stdexcept>
#include <tuple>
#include <vector>
#include "gtest/gtest.h"
#include "data_type.hpp"
#include "element_wise_operation.hpp"
#include "conv
_fwd
_util.hpp"
#include "
library/include/ck/library/utility/
conv_util.hpp"
#include "conv_util.hpp"
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
.
num_dim_spatial
=
3
;
params
.
N
=
2
;
params
.
K
=
16
;
params
.
C
=
4
;
params
.
filter_spatial_lengths
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
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
};
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
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
conv
::
ConvParams
params
;
params
.
num_dim_spatial_
=
3
;
params
.
N_
=
2
;
params
.
K_
=
16
;
params
.
C_
=
4
;
params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
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
>
(
conv_ptrs
);
...
...
@@ -39,26 +67,26 @@ bool test_conv3d_ndhwc()
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
);
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
namespace
ck
::
utils
;
// >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
};
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
>
(
conv_ptrs
);
...
...
@@ -66,39 +94,39 @@ bool test_conv3d_ndhwc_2gb_input()
auto
arg
=
conv_ptrs
.
back
()
->
MakeArgumentPointer
(
nullptr
,
nullptr
,
nullptr
,
params
.
N
,
params
.
K
,
params
.
C
,
params
.
input_spatial_lengths
,
params
.
filter_spatial_lengths
,
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
,
params
.
conv_filter_strides
_
,
params
.
conv_filter_dilations
_
,
params
.
input_left_pads
_
,
params
.
input_right_pads
_
,
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
namespace
ck
::
utils
;
// >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
};
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
>
(
conv_ptrs
);
...
...
@@ -106,140 +134,81 @@ bool test_conv3d_ndhwc_2gb_filters()
auto
arg
=
conv_ptrs
.
back
()
->
MakeArgumentPointer
(
nullptr
,
nullptr
,
nullptr
,
params
.
N
,
params
.
K
,
params
.
C
,
params
.
input_spatial_lengths
,
params
.
filter_spatial_lengths
,
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
,
params
.
conv_filter_strides
_
,
params
.
conv_filter_dilations
_
,
params
.
input_left_pads
_
,
params
.
input_right_pads
_
,
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
namespace
ck
::
utils
;
// >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
};
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
>
(
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
.
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
,
params
.
conv_filter_strides
_
,
params
.
conv_filter_dilations
_
,
params
.
input_left_pads
_
,
params
.
input_right_pads
_
,
PassThrough
{},
PassThrough
{},
PassThrough
{});
return
!
(
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
);
EXPECT_FALSE
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
}
bool
test_conv3d_ndhwc_b
f16
_i
nstances
(
)
TEST
(
Conv3DFwdNDHWC
,
B
f16
I
nstances
)
{
return
test_conv3d_ndhwc_instances
<
ck
::
bhalf_t
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>::
Get
<
3
>
());
EXPECT_TRUE
(
test_conv3d_ndhwc_instances
<
ck
::
bhalf_t
>
(
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
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>::
Get
<
3
>
());
EXPECT_TRUE
(
test_conv3d_ndhwc_instances
<
ck
::
half_t
>
(
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
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
float
,
float
,
float
>::
Get
<
3
>
());
EXPECT_TRUE
(
test_conv3d_ndhwc_instances
<
float
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
float
,
float
,
float
>::
Get
<
3
>
())
)
;
}
bool
test_conv3d_ndhwc_int8_instances
()
{
return
test_conv3d_ndhwc_instances
<
int8_t
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
int8_t
,
int8_t
,
int8_t
>::
Get
<
3
>
());
}
}
// anonymous namespace
int
main
()
TEST
(
Conv3DFwdNDHWC
,
Int8Instances
)
{
bool
res
{
true
};
res
=
test_conv3d_ndhwc
();
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
;
EXPECT_TRUE
(
test_conv3d_ndhwc_instances
<
int8_t
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
int8_t
,
int8_t
,
int8_t
>::
Get
<
3
>
()));
}
test/convnd_fwd/conv_util.hpp
View file @
b134b7d6
...
...
@@ -4,7 +4,6 @@
#include <tuple>
#include "config.hpp"
#include "conv_fwd_util.hpp"
#include "device_convnd_fwd_xdl_nhwc_kyxc_nhwk.hpp"
#include "element_wise_operation.hpp"
#include "host_tensor.hpp"
...
...
test/convnd_fwd_cpu/conv2d_fwd_cpu.cpp
View file @
b134b7d6
#include <sstream>
#include "config.hpp"
#include "device.hpp"
#include "host_tensor.hpp"
...
...
@@ -404,7 +405,7 @@ int main(int argc, char* argv[])
if
(
conv_ptr
->
IsSupportedArgument
(
argument_ptr
.
get
()))
{
auto
invoker_ptr
=
conv_ptr
->
MakeInvokerPointer
();
double
time
=
invoker_ptr
->
Run
(
argument_ptr
.
get
(),
10
);
double
time
=
invoker_ptr
->
Run
(
argument_ptr
.
get
(),
StreamConfig
{},
10
);
double
total_flop
=
static_cast
<
double
>
(
2
)
*
N
*
C
*
Ho
*
Wo
*
K
*
Y
*
X
;
...
...
test/gemm/gemm_bf16.cpp
View file @
b134b7d6
...
...
@@ -15,7 +15,7 @@
#include "host_gemm.hpp"
#include "device_tensor.hpp"
#include "device_gemm_xdl.hpp"
#include "device_gemm_xdl_c
_
shuffle.hpp"
#include "device_gemm_xdl_cshuffle.hpp"
#include "element_wise_operation.hpp"
#include "reference_gemm.hpp"
#include "gemm_specialization.hpp"
...
...
test/gemm/gemm_fp16.cpp
View file @
b134b7d6
...
...
@@ -13,7 +13,7 @@
#include "host_gemm.hpp"
#include "device_tensor.hpp"
#include "device_gemm_xdl.hpp"
#include "device_gemm_xdl_c
_
shuffle.hpp"
#include "device_gemm_xdl_cshuffle.hpp"
#include "element_wise_operation.hpp"
#include "gemm_specialization.hpp"
...
...
Prev
1
…
6
7
8
9
10
11
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