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
d84da366
Commit
d84da366
authored
Jul 18, 2022
by
Chao Liu
Browse files
update test for conv fwd
parent
74603261
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
229 additions
and
964 deletions
+229
-964
test/convnd_bwd_data/convnd_bwd_data.cpp
test/convnd_bwd_data/convnd_bwd_data.cpp
+14
-2
test/convnd_fwd/CMakeLists.txt
test/convnd_fwd/CMakeLists.txt
+2
-13
test/convnd_fwd/conv1d_fwd.cpp
test/convnd_fwd/conv1d_fwd.cpp
+0
-192
test/convnd_fwd/conv2d_fwd.cpp
test/convnd_fwd/conv2d_fwd.cpp
+0
-266
test/convnd_fwd/conv3d_fwd.cpp
test/convnd_fwd/conv3d_fwd.cpp
+0
-317
test/convnd_fwd/conv_util.hpp
test/convnd_fwd/conv_util.hpp
+0
-174
test/convnd_fwd/convnd_fwd.cpp
test/convnd_fwd/convnd_fwd.cpp
+213
-0
No files found.
test/convnd_bwd_data/convnd_bwd_data.cpp
View file @
d84da366
...
@@ -22,6 +22,7 @@ int main()
...
@@ -22,6 +22,7 @@ int main()
for
(
auto
&
param
:
params
)
for
(
auto
&
param
:
params
)
{
{
// fp32
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
1
,
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
...
@@ -34,6 +35,7 @@ int main()
...
@@ -34,6 +35,7 @@ int main()
false
,
// time_kernel
false
,
// time_kernel
param
);
param
);
// fp16
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
1
,
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
...
@@ -46,6 +48,7 @@ int main()
...
@@ -46,6 +48,7 @@ int main()
false
,
// time_kernel
false
,
// time_kernel
param
);
param
);
// bf16
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
1
,
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
...
@@ -58,6 +61,7 @@ int main()
...
@@ -58,6 +61,7 @@ int main()
false
,
// time_kernel
false
,
// time_kernel
param
);
param
);
// int8
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
1
,
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
...
@@ -79,6 +83,7 @@ int main()
...
@@ -79,6 +83,7 @@ int main()
for
(
auto
&
param
:
params
)
for
(
auto
&
param
:
params
)
{
{
// fp32
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
2
,
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
...
@@ -91,6 +96,7 @@ int main()
...
@@ -91,6 +96,7 @@ int main()
false
,
// time_kernel
false
,
// time_kernel
param
);
param
);
// fp16
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
2
,
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
...
@@ -103,6 +109,7 @@ int main()
...
@@ -103,6 +109,7 @@ int main()
false
,
// time_kernel
false
,
// time_kernel
param
);
param
);
// bf16
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
2
,
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
...
@@ -115,6 +122,7 @@ int main()
...
@@ -115,6 +122,7 @@ int main()
false
,
// time_kernel
false
,
// time_kernel
param
);
param
);
// int8
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
2
,
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
...
@@ -139,6 +147,7 @@ int main()
...
@@ -139,6 +147,7 @@ int main()
for
(
auto
&
param
:
params
)
for
(
auto
&
param
:
params
)
{
{
// fp32
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
3
,
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
...
@@ -151,6 +160,7 @@ int main()
...
@@ -151,6 +160,7 @@ int main()
false
,
// time_kernel
false
,
// time_kernel
param
);
param
);
// fp16
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
3
,
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
...
@@ -163,6 +173,7 @@ int main()
...
@@ -163,6 +173,7 @@ int main()
false
,
// time_kernel
false
,
// time_kernel
param
);
param
);
// bf16
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
3
,
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
...
@@ -175,6 +186,7 @@ int main()
...
@@ -175,6 +186,7 @@ int main()
false
,
// time_kernel
false
,
// time_kernel
param
);
param
);
// int8
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
3
,
pass
&=
ck
::
profiler
::
profile_conv_bwd_data_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
...
@@ -190,12 +202,12 @@ int main()
...
@@ -190,12 +202,12 @@ int main()
if
(
pass
)
if
(
pass
)
{
{
std
::
cout
<<
"test convnd bwd : Pass"
<<
std
::
endl
;
std
::
cout
<<
"test convnd bwd
data
: Pass"
<<
std
::
endl
;
return
0
;
return
0
;
}
}
else
else
{
{
std
::
cout
<<
"test convnd bwd: Fail "
<<
std
::
endl
;
std
::
cout
<<
"test convnd bwd
data
: Fail "
<<
std
::
endl
;
return
1
;
return
1
;
}
}
}
}
test/convnd_fwd/CMakeLists.txt
View file @
d84da366
add_custom_target
(
test_convnd_fwd
)
add_test_executable
(
test_convnd_fwd convnd_fwd.cpp
)
target_link_libraries
(
test_convnd_fwd PRIVATE utility device_conv1d_fwd_instance device_conv2d_fwd_instance device_conv3d_fwd_instance
)
add_gtest_executable
(
test_conv1d_fwd conv1d_fwd.cpp
)
target_link_libraries
(
test_conv1d_fwd PRIVATE utility device_conv1d_fwd_instance
)
add_dependencies
(
test_convnd_fwd test_conv1d_fwd
)
add_gtest_executable
(
test_conv2d_fwd conv2d_fwd.cpp
)
target_link_libraries
(
test_conv2d_fwd PRIVATE utility device_conv2d_fwd_instance
)
add_dependencies
(
test_convnd_fwd test_conv2d_fwd
)
add_gtest_executable
(
test_conv3d_fwd conv3d_fwd.cpp
)
target_link_libraries
(
test_conv3d_fwd PRIVATE utility device_conv3d_fwd_instance
)
add_dependencies
(
test_convnd_fwd test_conv3d_fwd
)
test/convnd_fwd/conv1d_fwd.cpp
deleted
100644 → 0
View file @
74603261
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <tuple>
#include <vector>
#include <gtest/gtest.h>
#include "ck/utility/data_type.hpp"
#include "ck/tensor_operation/gpu/element/element_wise_operation.hpp"
#include "ck/library/utility/convolution_parameter.hpp"
#include "test/convnd_fwd/conv_util.hpp"
namespace
{
class
Conv1dFwdNWCInstances
:
public
::
testing
::
Test
{
public:
template
<
typename
T
>
bool
test_conv1d_nwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
,
const
ck
::
utils
::
conv
::
ConvParams
&
params
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NWC
,
ctl
::
KXC
,
ctl
::
NWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
1
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
atol_
);
run_engine
.
SetRtol
(
rtol_
);
return
run_engine
.
Test
(
conv_ptrs
);
}
template
<
typename
T
>
bool
test_default
()
{
return
test_conv1d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
1
>(),
params_default_
);
}
template
<
typename
T
>
bool
test_filter1x1_stride1_pad0
()
{
return
test_conv1d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
1
>(),
params_filter1x1_stride1_pad0_
);
}
template
<
typename
T
>
bool
test_filter1x1_pad0
()
{
return
test_conv1d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
1
>(),
params_filter1x1_pad0_
);
}
static
inline
ck
::
utils
::
conv
::
ConvParams
params_default_
{
1
,
4
,
256
,
64
,
{
3
},
{
71
},
{
2
},
{
2
},
{
2
},
{
2
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_stride1_pad0_
{
1
,
4
,
256
,
64
,
{
1
},
{
28
},
{
1
},
{
1
},
{
0
},
{
0
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_pad0_
{
1
,
4
,
256
,
64
,
{
1
},
{
28
},
{
2
},
{
1
},
{
0
},
{
0
}};
private:
double
atol_
{
1e-5
};
double
rtol_
{
1e-4
};
};
}
// anonymous namespace
TEST
(
Conv1DFwdNWC
,
IntegerValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
using
T
=
float
;
ck
::
utils
::
conv
::
ConvParams
params
{
1
,
4
,
256
,
64
,
{
3
},
{
36
},
{
1
},
{
2
},
{
2
},
{
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
1
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NWC
,
ctl
::
KXC
,
ctl
::
NWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
1
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-5
);
run_engine
.
SetRtol
(
1e-4
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST
(
Conv1DFwdNWC
,
FloatingPointValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
using
T
=
ck
::
half_t
;
ck
::
utils
::
conv
::
ConvParams
params
{
1
,
4
,
256
,
64
,
{
3
},
{
36
},
{
1
},
{
2
},
{
2
},
{
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
1
,
T
,
T
,
T
,
float
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NWC
,
ctl
::
KXC
,
ctl
::
NWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistribution
<
T
>
,
FillUniformDistribution
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistribution
<
T
>
{},
FillUniformDistribution
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
1
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
0.1
);
run_engine
.
SetRtol
(
1e-2
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST_F
(
Conv1dFwdNWCInstances
,
BF16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
BF16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
BF16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
half_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F32_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
float
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F32_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
float
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
F32_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
float
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
I8_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
int8_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
I8_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
int8_t
>
());
}
TEST_F
(
Conv1dFwdNWCInstances
,
I8_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
int8_t
>
());
}
test/convnd_fwd/conv2d_fwd.cpp
deleted
100644 → 0
View file @
74603261
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <tuple>
#include <vector>
#include <gtest/gtest.h>
#include "ck/utility/data_type.hpp"
#include "ck/tensor_operation/gpu/element/element_wise_operation.hpp"
#include "ck/library/utility/convolution_parameter.hpp"
#include "test/convnd_fwd/conv_util.hpp"
namespace
{
class
Conv2dFwdNHWCInstances
:
public
::
testing
::
Test
{
public:
template
<
typename
T
>
bool
test_conv2d_nhwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
,
const
ck
::
utils
::
conv
::
ConvParams
&
params
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
2
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
atol_
);
run_engine
.
SetRtol
(
rtol_
);
return
run_engine
.
Test
(
conv_ptrs
);
}
template
<
typename
T
>
bool
test_default
(
bool
use_convnd
=
false
)
{
if
(
use_convnd
)
{
return
test_conv2d_nhwc_instances
<
T
>
(
test
::
conv
::
ConvolutionNDFwdInstances
<
T
,
T
,
T
>::
Get
(
2
),
params_default_
);
}
else
{
return
test_conv2d_nhwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
2
>(),
params_default_
);
}
}
template
<
typename
T
>
bool
test_filter1x1_stride1_pad0
(
bool
use_convnd
=
false
)
{
if
(
use_convnd
)
{
return
test_conv2d_nhwc_instances
<
T
>
(
test
::
conv
::
ConvolutionNDFwdInstances
<
T
,
T
,
T
>::
Get
(
2
),
params_filter1x1_stride1_pad0_
);
}
else
{
return
test_conv2d_nhwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
2
>(),
params_filter1x1_stride1_pad0_
);
}
}
template
<
typename
T
>
bool
test_filter1x1_pad0
(
bool
use_convnd
=
false
)
{
if
(
use_convnd
)
{
return
test_conv2d_nhwc_instances
<
T
>
(
test
::
conv
::
ConvolutionNDFwdInstances
<
T
,
T
,
T
>::
Get
(
2
),
params_filter1x1_pad0_
);
}
else
{
return
test_conv2d_nhwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
2
>(),
params_filter1x1_pad0_
);
}
}
template
<
typename
T
>
bool
test_oddC
()
{
return
test_conv2d_nhwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
2
>(),
params_oddC_
);
}
static
inline
ck
::
utils
::
conv
::
ConvParams
params_default_
{
2
,
4
,
256
,
64
,
{
3
,
3
},
{
36
,
36
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_stride1_pad0_
{
2
,
4
,
256
,
64
,
{
1
,
1
},
{
28
,
28
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_pad0_
{
2
,
4
,
256
,
64
,
{
1
,
1
},
{
28
,
28
},
{
2
,
2
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_oddC_
{
2
,
4
,
256
,
3
,
{
3
,
3
},
{
28
,
28
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}};
private:
double
atol_
{
1e-5
};
double
rtol_
{
1e-4
};
};
}
// anonymous namespace
TEST
(
Conv2DFwdNHWC
,
IntegerValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
using
T
=
float
;
ck
::
utils
::
conv
::
ConvParams
params
{
2
,
4
,
256
,
64
,
{
3
,
3
},
{
36
,
36
},
{
1
,
1
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
2
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
2
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-5
);
run_engine
.
SetRtol
(
1e-4
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST
(
Conv2DFwdNHWC
,
FloatingPointValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
using
T
=
ck
::
half_t
;
ck
::
utils
::
conv
::
ConvParams
params
{
2
,
4
,
256
,
64
,
{
3
,
3
},
{
36
,
36
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
},
{
2
,
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
2
,
T
,
T
,
T
,
float
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistribution
<
T
>
,
FillUniformDistribution
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistribution
<
T
>
{},
FillUniformDistribution
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
2
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
2e-4
);
run_engine
.
SetRtol
(
1e-3
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
BF16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
BF16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
BF16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
half_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F16_oddC
)
{
EXPECT_TRUE
(
this
->
test_oddC
<
ck
::
half_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F32_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
float
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F32_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
float
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
F32_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
float
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
I8_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
int8_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
I8_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
int8_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
I8_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
int8_t
>
());
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_BF16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
bhalf_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_BF16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
bhalf_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_BF16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
bhalf_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
half_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
half_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
half_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F32_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
float
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F32_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
float
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_F32_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
float
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_I8_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
int8_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_I8_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
int8_t
>
(
true
));
}
TEST_F
(
Conv2dFwdNHWCInstances
,
ND_I8_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
int8_t
>
(
true
));
}
test/convnd_fwd/conv3d_fwd.cpp
deleted
100644 → 0
View file @
74603261
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <stdexcept>
#include <tuple>
#include <vector>
#include <gtest/gtest.h>
#include "ck/utility/data_type.hpp"
#include "ck/tensor_operation/gpu/element/element_wise_operation.hpp"
#include "ck/library/utility/convolution_parameter.hpp"
#include "test/convnd_fwd/conv_util.hpp"
namespace
{
class
Conv3dFwdNDHWCInstances
:
public
::
testing
::
Test
{
public:
template
<
typename
T
>
bool
test_conv3d_nwc_instances
(
const
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>&
conv_ptrs
,
const
ck
::
utils
::
conv
::
ConvParams
&
params
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NDHWC
,
ctl
::
KZYXC
,
ctl
::
NDHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
3
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
atol_
);
run_engine
.
SetRtol
(
rtol_
);
return
run_engine
.
Test
(
conv_ptrs
);
}
template
<
typename
T
>
bool
test_default
()
{
return
test_conv3d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
3
>(),
params_default_
);
}
template
<
typename
T
>
bool
test_filter1x1_stride1_pad0
()
{
return
test_conv3d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
3
>(),
params_filter1x1_stride1_pad0_
);
}
template
<
typename
T
>
bool
test_filter1x1_pad0
()
{
return
test_conv3d_nwc_instances
<
T
>
(
ck
::
utils
::
conv
::
ConvolutionFwdInstances
<
T
,
T
,
T
>::
template
Get
<
3
>(),
params_filter1x1_pad0_
);
}
static
inline
ck
::
utils
::
conv
::
ConvParams
params_default_
{
3
,
4
,
256
,
64
,
{
3
,
3
,
3
},
{
28
,
28
,
28
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
2
,
2
,
2
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_stride1_pad0_
{
3
,
4
,
256
,
64
,
{
1
,
1
,
1
},
{
28
,
28
,
28
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}};
static
inline
ck
::
utils
::
conv
::
ConvParams
params_filter1x1_pad0_
{
3
,
4
,
256
,
64
,
{
1
,
1
,
1
},
{
28
,
28
,
28
},
{
2
,
2
,
2
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}};
private:
double
atol_
{
1e-5
};
double
rtol_
{
1e-4
};
};
}
// anonymous namespace
TEST
(
Conv3DFwdNDHWC
,
IntegerValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
using
T
=
float
;
ck
::
utils
::
conv
::
ConvParams
params
{
3
,
4
,
256
,
64
,
{
3
,
3
,
3
},
{
18
,
18
,
18
},
{
1
,
1
,
1
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
2
,
2
,
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NDHWC
,
ctl
::
KZYXC
,
ctl
::
NDHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistributionIntegerValue
<
T
>
,
FillUniformDistributionIntegerValue
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistributionIntegerValue
<
T
>
{},
FillUniformDistributionIntegerValue
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
3
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-5
);
run_engine
.
SetRtol
(
1e-3
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST
(
Conv3DFwdNDHWC
,
FloatingPointValues
)
{
using
namespace
std
::
placeholders
;
using
namespace
ck
::
utils
;
namespace
ctl
=
ck
::
tensor_layout
::
convolution
;
using
T
=
ck
::
half_t
;
ck
::
utils
::
conv
::
ConvParams
params
{
3
,
4
,
256
,
64
,
{
3
,
3
,
3
},
{
18
,
18
,
18
},
{
1
,
1
,
1
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
2
,
2
,
2
}};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
float
>
(
conv_ptrs
);
conv
::
ConvFwdOpInstance
<
T
,
T
,
T
,
ctl
::
NDHWC
,
ctl
::
KZYXC
,
ctl
::
NDHWK
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
ck
::
tensor_operation
::
element_wise
::
PassThrough
,
FillUniformDistribution
<
T
>
,
FillUniformDistribution
<
T
>>
conv_instance
(
params
,
true
,
FillUniformDistribution
<
T
>
{},
FillUniformDistribution
<
T
>
{});
auto
reference_conv_fwd_fun
=
std
::
bind
(
conv
::
run_reference_convolution_forward
<
3
,
T
,
T
,
T
>
,
params
,
_1
,
_2
,
_3
);
OpInstanceRunEngine
<
T
,
T
,
T
>
run_engine
(
conv_instance
,
reference_conv_fwd_fun
);
run_engine
.
SetAtol
(
1e-3
);
run_engine
.
SetRtol
(
1e-3
);
EXPECT_TRUE
(
run_engine
.
Test
(
conv_ptrs
));
}
TEST
(
Conv3DFwdNDHWC
,
InputOver2GB
)
{
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
namespace
ck
::
utils
;
using
T
=
float
;
// >2GB Input
conv
::
ConvParams
params
;
params
.
num_dim_spatial_
=
3
;
params
.
N_
=
2
;
params
.
K_
=
16
;
params
.
C_
=
32
;
params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
3
,
3
,
3
};
params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
32
,
1000
,
1000
};
params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
auto
arg
=
conv_ptrs
.
back
()
->
MakeArgumentPointer
(
nullptr
,
nullptr
,
nullptr
,
params
.
N_
,
params
.
K_
,
params
.
C_
,
params
.
input_spatial_lengths_
,
params
.
filter_spatial_lengths_
,
params
.
GetOutputSpatialLengths
(),
params
.
conv_filter_strides_
,
params
.
conv_filter_dilations_
,
params
.
input_left_pads_
,
params
.
input_right_pads_
,
PassThrough
{},
PassThrough
{},
PassThrough
{});
EXPECT_FALSE
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
}
TEST
(
Conv3DFwdNDHWC
,
FiltersOver2GB
)
{
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
namespace
ck
::
utils
;
using
T
=
float
;
// >2GB Filters
conv
::
ConvParams
params
;
params
.
num_dim_spatial_
=
3
;
params
.
N_
=
2
;
params
.
K_
=
16
;
params
.
C_
=
32
;
params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
4
,
1000
,
1000
};
params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
16
,
16
,
16
};
params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
auto
arg
=
conv_ptrs
.
back
()
->
MakeArgumentPointer
(
nullptr
,
nullptr
,
nullptr
,
params
.
N_
,
params
.
K_
,
params
.
C_
,
params
.
input_spatial_lengths_
,
params
.
filter_spatial_lengths_
,
params
.
GetOutputSpatialLengths
(),
params
.
conv_filter_strides_
,
params
.
conv_filter_dilations_
,
params
.
input_left_pads_
,
params
.
input_right_pads_
,
PassThrough
{},
PassThrough
{},
PassThrough
{});
EXPECT_FALSE
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
}
TEST
(
Conv3DFwdNDHWC
,
OutputOver2GB
)
{
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
namespace
ck
::
utils
;
using
T
=
float
;
// >2GB Output
conv
::
ConvParams
params
;
params
.
num_dim_spatial_
=
3
;
params
.
N_
=
2
;
params
.
K_
=
16
;
params
.
C_
=
2
;
params
.
filter_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_spatial_lengths_
=
std
::
vector
<
ck
::
index_t
>
{
1000
,
1000
,
30
};
params
.
conv_filter_strides_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
conv_filter_dilations_
=
std
::
vector
<
ck
::
index_t
>
{
1
,
1
,
1
};
params
.
input_left_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
params
.
input_right_pads_
=
std
::
vector
<
ck
::
index_t
>
{
2
,
2
,
2
};
std
::
vector
<
test
::
conv
::
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
test
::
conv
::
get_test_convolution_fwd_instance
<
3
,
T
,
T
,
T
,
T
>
(
conv_ptrs
);
auto
arg
=
conv_ptrs
.
back
()
->
MakeArgumentPointer
(
nullptr
,
nullptr
,
nullptr
,
params
.
N_
,
params
.
K_
,
params
.
C_
,
params
.
input_spatial_lengths_
,
params
.
filter_spatial_lengths_
,
params
.
GetOutputSpatialLengths
(),
params
.
conv_filter_strides_
,
params
.
conv_filter_dilations_
,
params
.
input_left_pads_
,
params
.
input_right_pads_
,
PassThrough
{},
PassThrough
{},
PassThrough
{});
EXPECT_FALSE
(
conv_ptrs
.
back
()
->
IsSupportedArgument
(
arg
.
get
()));
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
BF16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
BF16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
BF16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
bhalf_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F16_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
ck
::
half_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F16_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F16_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
ck
::
half_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F32_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
float
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F32_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
float
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
F32_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
float
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
I8_default
)
{
EXPECT_TRUE
(
this
->
test_default
<
int8_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
I8_filter1x1_stride1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_stride1_pad0
<
int8_t
>
());
}
TEST_F
(
Conv3dFwdNDHWCInstances
,
I8_filter1x1_pad0
)
{
EXPECT_TRUE
(
this
->
test_filter1x1_pad0
<
int8_t
>
());
}
test/convnd_fwd/conv_util.hpp
deleted
100644 → 0
View file @
74603261
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#pragma once
#include <tuple>
#include "ck/ck.hpp"
#include "ck/utility/sequence.hpp"
#include "ck/utility/data_type.hpp"
#include "ck/tensor_operation/gpu/device/device_convnd_fwd_xdl_nhwc_kyxc_nhwk.hpp"
#include "ck/tensor_operation/gpu/element/element_wise_operation.hpp"
#include "ck/library/utility/host_tensor.hpp"
namespace
ck
{
namespace
tensor_operation
{
namespace
device
{
using
DeviceConvFwdNoOpPtr
=
DeviceConvFwdPtr
<
element_wise
::
PassThrough
,
element_wise
::
PassThrough
,
element_wise
::
PassThrough
>
;
namespace
instance
{
void
add_device_convnd_2d_fwd_xdl_nhwc_kyxc_nhwk_bf16_instances
(
std
::
vector
<
DeviceConvFwdNoOpPtr
>&
);
void
add_device_convnd_2d_fwd_xdl_nhwc_kyxc_nhwk_f16_instances
(
std
::
vector
<
DeviceConvFwdNoOpPtr
>&
);
void
add_device_convnd_2d_fwd_xdl_nhwc_kyxc_nhwk_f32_instances
(
std
::
vector
<
DeviceConvFwdNoOpPtr
>&
);
void
add_device_convnd_2d_fwd_xdl_nhwc_kyxc_nhwk_int8_instances
(
std
::
vector
<
DeviceConvFwdNoOpPtr
>&
);
}
// namespace instance
}
// namespace device
}
// namespace tensor_operation
}
// namespace ck
namespace
test
{
namespace
conv
{
template
<
ck
::
index_t
...
Is
>
using
S
=
ck
::
Sequence
<
Is
...
>
;
using
InElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
WeiElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
OutElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
DeviceConvFwdNoOpPtr
=
ck
::
tensor_operation
::
device
::
DeviceConvFwdPtr
<
InElementOp
,
WeiElementOp
,
OutElementOp
>
;
static
constexpr
auto
ConvFwdDefault
=
ck
::
tensor_operation
::
device
::
ConvolutionForwardSpecialization
::
Default
;
template
<
ck
::
index_t
SpatialDims
,
typename
InDataType
,
typename
WeiDataType
,
typename
OutDataType
,
typename
AccDataType
>
using
DeviceConvNDFwdInstance
=
ck
::
tensor_operation
::
device
::
DeviceConvNDFwdXdl_Input_N_Hi_Wi_C_Weight_K_Y_X_C_Output_N_Ho_Wo_K
<
// clang-format off
InDataType
,
//
WeiDataType
,
//
OutDataType
,
//
AccDataType
,
// Accumulator data type.
InElementOp
,
// Input Elementwise Operation
WeiElementOp
,
// Weights Elementwise Operation
OutElementOp
,
// Output Elementwise Operation
ConvFwdDefault
,
// ConvForwardSpecialization
SpatialDims
,
// SptialDims
256
,
// BlockSize
128
,
// MPerBlock
256
,
// NPerBlock
4
,
// K0PerBlock
8
,
// K1
32
,
// MPerXdl
32
,
// NPerXdl
2
,
// MXdlPerWave
4
,
// NXdlPerWave
S
<
4
,
64
,
1
>
,
// ABlockTransferThreadClusterLengths_K0_M_K1
S
<
1
,
0
,
2
>
,
// ABlockTransferThreadClusterArrangeOrder
S
<
1
,
0
,
2
>
,
// ABlockTransferSrcAccessOrder
2
,
// ABlockTransferSrcVectorDim
8
,
// ABlockTransferSrcScalarPerVector
8
,
// ABlockTransferDstScalarPerVector_K1
true
,
// ABlockLdsAddExtraM
S
<
4
,
64
,
1
>
,
// BBlockTransferThreadClusterLengths_K0_N_K1
S
<
1
,
0
,
2
>
,
// BBlockTransferThreadClusterArrangeOrder
S
<
1
,
0
,
2
>
,
// BBlockTransferSrcAccessOrder
2
,
// BBlockTransferSrcVectorDim
8
,
// BBlockTransferSrcScalarPerVector
8
,
// BBlockTransferDstScalarPerVector_K1
true
,
// BBlockLdsAddExtraN
7
,
// CThreadTransferSrcDstVectorDim
1
>
;
// CThreadTransferDstScalarPerVector
// clang-format on
template
<
ck
::
index_t
NDim
,
typename
InDataType
,
typename
WeiDataType
,
typename
OutDataType
,
typename
AccDataType
>
void
get_test_convolution_fwd_instance
(
std
::
vector
<
DeviceConvFwdNoOpPtr
>&
instances
)
{
using
ConvInstanceT
=
DeviceConvNDFwdInstance
<
NDim
,
InDataType
,
WeiDataType
,
OutDataType
,
AccDataType
>
;
instances
.
emplace_back
(
std
::
make_unique
<
ConvInstanceT
>
());
}
// TODO (aosewski)
// Temporary solution to get all DeviceConvNDFwdXdl_Input_N_Hi_Wi_C_Weight_K_Y_X_C_Output_N_Ho_Wo_K
// instances. When switched over to DeviceConvNDFwdXdl for 2D remove ConvolutionNDFwdInstances
// structures.
template
<
typename
InDataType
,
typename
WeiDataType
,
typename
OutDataType
>
struct
ConvolutionNDFwdInstances
;
template
<
>
struct
ConvolutionNDFwdInstances
<
float
,
float
,
float
>
{
static
std
::
vector
<
DeviceConvFwdNoOpPtr
>
Get
(
std
::
size_t
num_dim_spatial
)
{
std
::
vector
<
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
if
(
num_dim_spatial
==
2
)
{
ck
::
tensor_operation
::
device
::
instance
::
add_device_convnd_2d_fwd_xdl_nhwc_kyxc_nhwk_f32_instances
(
conv_ptrs
);
}
return
conv_ptrs
;
}
};
template
<
>
struct
ConvolutionNDFwdInstances
<
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>
{
static
std
::
vector
<
DeviceConvFwdNoOpPtr
>
Get
(
std
::
size_t
num_dim_spatial
)
{
std
::
vector
<
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
if
(
num_dim_spatial
==
2
)
{
ck
::
tensor_operation
::
device
::
instance
::
add_device_convnd_2d_fwd_xdl_nhwc_kyxc_nhwk_f16_instances
(
conv_ptrs
);
}
return
conv_ptrs
;
}
};
template
<
>
struct
ConvolutionNDFwdInstances
<
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>
{
static
std
::
vector
<
DeviceConvFwdNoOpPtr
>
Get
(
std
::
size_t
num_dim_spatial
)
{
std
::
vector
<
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
if
(
num_dim_spatial
==
2
)
{
ck
::
tensor_operation
::
device
::
instance
::
add_device_convnd_2d_fwd_xdl_nhwc_kyxc_nhwk_bf16_instances
(
conv_ptrs
);
}
return
conv_ptrs
;
}
};
template
<
>
struct
ConvolutionNDFwdInstances
<
int8_t
,
int8_t
,
int8_t
>
{
static
std
::
vector
<
DeviceConvFwdNoOpPtr
>
Get
(
std
::
size_t
num_dim_spatial
)
{
std
::
vector
<
DeviceConvFwdNoOpPtr
>
conv_ptrs
;
if
(
num_dim_spatial
==
2
)
{
ck
::
tensor_operation
::
device
::
instance
::
add_device_convnd_2d_fwd_xdl_nhwc_kyxc_nhwk_int8_instances
(
conv_ptrs
);
}
return
conv_ptrs
;
}
};
}
// namespace conv
}
// namespace test
test/convnd_fwd/convnd_fwd.cpp
0 → 100644
View file @
d84da366
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include <iostream>
#include <numeric>
#include <initializer_list>
#include <cstdlib>
#include <vector>
#include "profiler/include/profile_conv_fwd_impl.hpp"
int
main
()
{
bool
pass
=
true
;
std
::
vector
<
ck
::
tensor_operation
::
device
::
ConvParams
>
params
;
// check 1d
params
.
push_back
({
1
,
128
,
128
,
256
,
{
1
},
{
14
},
{
2
},
{
1
},
{
0
},
{
0
}});
params
.
push_back
({
1
,
128
,
128
,
256
,
{
3
},
{
28
},
{
1
},
{
1
},
{
1
},
{
1
}});
params
.
push_back
({
1
,
128
,
128
,
256
,
{
1
},
{
3
},
{
1
},
{
1
},
{
0
},
{
0
}});
for
(
auto
&
param
:
params
)
{
// fp32
pass
&=
ck
::
profiler
::
profile_conv_fwd_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
,
float
,
float
,
float
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
// fp16
pass
&=
ck
::
profiler
::
profile_conv_fwd_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
// bf16
pass
&=
ck
::
profiler
::
profile_conv_fwd_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
// int8
pass
&=
ck
::
profiler
::
profile_conv_fwd_impl
<
1
,
ck
::
tensor_layout
::
convolution
::
NWC
,
ck
::
tensor_layout
::
convolution
::
KXC
,
ck
::
tensor_layout
::
convolution
::
NWK
,
int8_t
,
int8_t
,
int8_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
}
// check 2d
params
.
clear
();
params
.
push_back
({
2
,
128
,
128
,
256
,
{
1
,
1
},
{
7
,
7
},
{
2
,
2
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
params
.
push_back
({
2
,
128
,
128
,
256
,
{
3
,
3
},
{
14
,
14
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}});
params
.
push_back
({
2
,
128
,
128
,
256
,
{
1
,
1
},
{
3
,
3
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}});
for
(
auto
&
param
:
params
)
{
// fp32
pass
&=
ck
::
profiler
::
profile_conv_fwd_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
float
,
float
,
float
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
// fp16
pass
&=
ck
::
profiler
::
profile_conv_fwd_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
// bf16
pass
&=
ck
::
profiler
::
profile_conv_fwd_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
// int8
pass
&=
ck
::
profiler
::
profile_conv_fwd_impl
<
2
,
ck
::
tensor_layout
::
convolution
::
NHWC
,
ck
::
tensor_layout
::
convolution
::
KYXC
,
ck
::
tensor_layout
::
convolution
::
NHWK
,
int8_t
,
int8_t
,
int8_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
}
// check 3d
params
.
clear
();
params
.
push_back
(
{
3
,
128
,
128
,
256
,
{
1
,
1
,
1
},
{
7
,
7
,
7
},
{
2
,
2
,
2
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}});
params
.
push_back
(
{
3
,
128
,
128
,
256
,
{
3
,
3
,
3
},
{
14
,
14
,
14
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
}});
params
.
push_back
(
{
3
,
128
,
128
,
256
,
{
1
,
1
,
1
},
{
3
,
3
,
3
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}});
for
(
auto
&
param
:
params
)
{
// fp32
pass
&=
ck
::
profiler
::
profile_conv_fwd_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
,
float
,
float
,
float
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
// fp16
pass
&=
ck
::
profiler
::
profile_conv_fwd_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
,
ck
::
half_t
,
ck
::
half_t
,
ck
::
half_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
// bf16
pass
&=
ck
::
profiler
::
profile_conv_fwd_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
,
ck
::
bhalf_t
,
ck
::
bhalf_t
,
ck
::
bhalf_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
// int8
pass
&=
ck
::
profiler
::
profile_conv_fwd_impl
<
3
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
KZYXC
,
ck
::
tensor_layout
::
convolution
::
NDHWK
,
int8_t
,
int8_t
,
int8_t
>
(
true
,
// do_verification
1
,
// init_method
false
,
// do_log
false
,
// time_kernel
param
);
}
if
(
pass
)
{
std
::
cout
<<
"test convnd fwd : Pass"
<<
std
::
endl
;
return
0
;
}
else
{
std
::
cout
<<
"test convnd fwd: Fail "
<<
std
::
endl
;
return
1
;
}
}
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