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
4100d1d8
Commit
4100d1d8
authored
Aug 23, 2023
by
Alan Turner
Browse files
Merge remote-tracking branch 'origin/develop' into migx-flash-attn
parents
48717006
c8a8385f
Changes
609
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
129 additions
and
160 deletions
+129
-160
test/pool_fwd/CMakeLists.txt
test/pool_fwd/CMakeLists.txt
+2
-8
test/pool_fwd/test_avg_pool2d_fwd.cpp
test/pool_fwd/test_avg_pool2d_fwd.cpp
+0
-56
test/pool_fwd/test_avg_pool3d_fwd.cpp
test/pool_fwd/test_avg_pool3d_fwd.cpp
+12
-6
test/pool_fwd/test_max_pool2d_fwd.cpp
test/pool_fwd/test_max_pool2d_fwd.cpp
+0
-75
test/pool_fwd/test_max_pool3d_fwd.cpp
test/pool_fwd/test_max_pool3d_fwd.cpp
+16
-5
test/pool_fwd/test_pool_fwd_common.hpp
test/pool_fwd/test_pool_fwd_common.hpp
+3
-0
test/softmax/test_softmax_rank3.cpp
test/softmax/test_softmax_rank3.cpp
+5
-4
test/softmax/test_softmax_rank4.cpp
test/softmax/test_softmax_rank4.cpp
+5
-4
test/softmax/test_softmax_util.hpp
test/softmax/test_softmax_util.hpp
+86
-2
No files found.
test/pool_fwd/CMakeLists.txt
View file @
4100d1d8
add_custom_target
(
test_pool_fwd
)
add_gtest_executable
(
test_avg_pool2d_fwd test_avg_pool2d_fwd.cpp
)
add_gtest_executable
(
test_avg_pool3d_fwd test_avg_pool3d_fwd.cpp
)
add_gtest_executable
(
test_max_pool2d_fwd test_max_pool2d_fwd.cpp
)
add_gtest_executable
(
test_max_pool3d_fwd test_max_pool3d_fwd.cpp
)
target_link_libraries
(
test_avg_pool2d_fwd PRIVATE utility device_pool_fwd_instance
)
target_link_libraries
(
test_avg_pool3d_fwd PRIVATE utility device_pool_fwd_instance
)
target_link_libraries
(
test_max_pool2d_fwd PRIVATE utility device_pool_fwd_instance
)
target_link_libraries
(
test_max_pool3d_fwd PRIVATE utility device_pool_fwd_instance
)
target_link_libraries
(
test_avg_pool3d_fwd PRIVATE utility device_pool3d_fwd_instance
)
target_link_libraries
(
test_max_pool3d_fwd PRIVATE utility device_pool3d_fwd_instance
)
add_dependencies
(
test_pool_fwd test_avg_pool2d_fwd
)
add_dependencies
(
test_pool_fwd test_avg_pool3d_fwd
)
add_dependencies
(
test_pool_fwd test_max_pool2d_fwd
)
add_dependencies
(
test_pool_fwd test_max_pool3d_fwd
)
test/pool_fwd/test_avg_pool2d_fwd.cpp
deleted
100644 → 0
View file @
48717006
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2023, Advanced Micro Devices, Inc. All rights reserved.
#include "gtest/gtest.h"
#include "profiler/profile_pool2d_fwd_impl.hpp"
#include "test_pool_fwd_common.hpp"
template
<
typename
Tuple
>
class
TestAvgPool2dFwd
:
public
::
testing
::
Test
{
protected:
using
InDataType
=
std
::
tuple_element_t
<
0
,
Tuple
>
;
using
OutDataType
=
std
::
tuple_element_t
<
1
,
Tuple
>
;
using
ComputeDataType
=
std
::
tuple_element_t
<
2
,
Tuple
>
;
using
IndexDataType
=
std
::
tuple_element_t
<
3
,
Tuple
>
;
std
::
vector
<
PoolingParam
>
params
;
void
Run
()
{
for
(
auto
param
:
params
)
{
bool
success
=
ck
::
profiler
::
profile_pool2d_fwd_impl
<
InDataType
,
OutDataType
,
ComputeDataType
,
IndexDataType
,
ck
::
ReduceTensorOp
::
AVG
,
false
,
false
>
(
true
,
2
,
false
,
false
,
param
.
length_
,
param
.
window_spatial_lengths_
,
param
.
window_strides_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
);
EXPECT_TRUE
(
success
);
}
}
};
using
KernelTypes
=
::
testing
::
Types
<
std
::
tuple
<
F16
,
F16
,
F32
,
I32
>
,
std
::
tuple
<
F32
,
F32
,
F32
,
I32
>>
;
TYPED_TEST_SUITE
(
TestAvgPool2dFwd
,
KernelTypes
);
TYPED_TEST
(
TestAvgPool2dFwd
,
Test_Pool
)
{
// length, window_length, window_stride, left_pad, right_pad
this
->
params
=
{{{
1
,
1
,
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}},
{{
2
,
16
,
64
,
64
},
{
64
,
64
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}},
{{
2
,
32
,
30
,
30
},
{
2
,
2
},
{
2
,
2
},
{
1
,
1
},
{
1
,
1
}}};
this
->
Run
();
}
test/pool_fwd/test_avg_pool3d_fwd.cpp
View file @
4100d1d8
...
...
@@ -25,6 +25,8 @@ class TestAvgPool3dFwd : public ::testing::Test
OutDataType
,
ComputeDataType
,
IndexDataType
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
ReduceTensorOp
::
AVG
,
false
,
false
>
(
true
,
...
...
@@ -34,23 +36,27 @@ class TestAvgPool3dFwd : public ::testing::Test
param
.
length_
,
param
.
window_spatial_lengths_
,
param
.
window_strides_
,
param
.
window_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
);
EXPECT_TRUE
(
success
);
}
}
};
#ifdef CK_ENABLE_FP16
using
KernelTypes
=
::
testing
::
Types
<
std
::
tuple
<
F16
,
F16
,
F32
,
I32
>
,
std
::
tuple
<
F32
,
F32
,
F32
,
I32
>>
;
#else
using
KernelTypes
=
::
testing
::
Types
<
std
::
tuple
<
F32
,
F32
,
F32
,
I32
>>
;
#endif
TYPED_TEST_SUITE
(
TestAvgPool3dFwd
,
KernelTypes
);
TYPED_TEST
(
TestAvgPool3dFwd
,
Test_Pool
)
{
// length, window_length, window_stride, left_pad, right_pad
this
->
params
=
{{{
1
,
1
,
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}},
{{
2
,
16
,
64
,
64
,
64
},
{
64
,
64
,
64
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}},
{{
2
,
32
,
30
,
30
,
30
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
1
,
1
,
1
},
{
1
,
1
,
1
}}};
// length, window_length, window_stride, window_dilation, left_pad, right_pad
this
->
params
=
{{{
1
,
1
,
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}},
{{
2
,
16
,
64
,
64
,
64
},
{
64
,
64
,
64
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}},
{{
2
,
16
,
64
,
64
,
64
},
{
4
,
4
,
4
},
{
4
,
4
,
4
},
{
2
,
2
,
2
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}},
{{
2
,
32
,
30
,
30
,
30
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
}}};
this
->
Run
();
}
test/pool_fwd/test_max_pool2d_fwd.cpp
deleted
100644 → 0
View file @
48717006
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2023, Advanced Micro Devices, Inc. All rights reserved.
#include "gtest/gtest.h"
#include "profiler/profile_pool2d_fwd_impl.hpp"
#include "test_pool_fwd_common.hpp"
template
<
typename
Tuple
>
class
TestMaxPool2dFwd
:
public
::
testing
::
Test
{
protected:
using
InDataType
=
std
::
tuple_element_t
<
0
,
Tuple
>
;
using
OutDataType
=
std
::
tuple_element_t
<
1
,
Tuple
>
;
using
ComputeDataType
=
std
::
tuple_element_t
<
2
,
Tuple
>
;
using
IndexDataType
=
std
::
tuple_element_t
<
3
,
Tuple
>
;
std
::
vector
<
PoolingParam
>
params
;
void
Run
()
{
for
(
auto
param
:
params
)
{
// max pool
bool
success
=
ck
::
profiler
::
profile_pool2d_fwd_impl
<
InDataType
,
OutDataType
,
ComputeDataType
,
IndexDataType
,
ck
::
ReduceTensorOp
::
MAX
,
false
,
false
>
(
true
,
2
,
false
,
false
,
param
.
length_
,
param
.
window_spatial_lengths_
,
param
.
window_strides_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
);
EXPECT_TRUE
(
success
);
// max pool + index
success
=
ck
::
profiler
::
profile_pool2d_fwd_impl
<
InDataType
,
OutDataType
,
ComputeDataType
,
IndexDataType
,
ck
::
ReduceTensorOp
::
MAX
,
false
,
true
>
(
true
,
2
,
false
,
false
,
param
.
length_
,
param
.
window_spatial_lengths_
,
param
.
window_strides_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
);
EXPECT_TRUE
(
success
);
}
}
};
using
KernelTypes
=
::
testing
::
Types
<
std
::
tuple
<
F16
,
F16
,
F16
,
I32
>
,
std
::
tuple
<
F32
,
F32
,
F32
,
I32
>>
;
TYPED_TEST_SUITE
(
TestMaxPool2dFwd
,
KernelTypes
);
TYPED_TEST
(
TestMaxPool2dFwd
,
Test_Pool
)
{
// length, window_length, window_stride, left_pad, right_pad
this
->
params
=
{{{
1
,
1
,
1
,
1
},
{
1
,
1
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}},
{{
2
,
16
,
64
,
64
},
{
64
,
64
},
{
1
,
1
},
{
0
,
0
},
{
0
,
0
}},
{{
2
,
32
,
30
,
30
},
{
2
,
2
},
{
2
,
2
},
{
1
,
1
},
{
1
,
1
}}};
this
->
Run
();
}
test/pool_fwd/test_max_pool3d_fwd.cpp
View file @
4100d1d8
...
...
@@ -26,6 +26,8 @@ class TestMaxPool3dFwd : public ::testing::Test
OutDataType
,
ComputeDataType
,
IndexDataType
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
ReduceTensorOp
::
MAX
,
false
,
false
>
(
true
,
...
...
@@ -35,6 +37,7 @@ class TestMaxPool3dFwd : public ::testing::Test
param
.
length_
,
param
.
window_spatial_lengths_
,
param
.
window_strides_
,
param
.
window_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
);
EXPECT_TRUE
(
success
);
...
...
@@ -44,6 +47,8 @@ class TestMaxPool3dFwd : public ::testing::Test
OutDataType
,
ComputeDataType
,
IndexDataType
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
tensor_layout
::
convolution
::
NDHWC
,
ck
::
ReduceTensorOp
::
MAX
,
false
,
true
>
(
true
,
...
...
@@ -53,6 +58,7 @@ class TestMaxPool3dFwd : public ::testing::Test
param
.
length_
,
param
.
window_spatial_lengths_
,
param
.
window_strides_
,
param
.
window_dilations_
,
param
.
input_left_pads_
,
param
.
input_right_pads_
);
EXPECT_TRUE
(
success
);
...
...
@@ -60,16 +66,21 @@ class TestMaxPool3dFwd : public ::testing::Test
}
};
#ifdef CK_ENABLE_FP16
using
KernelTypes
=
::
testing
::
Types
<
std
::
tuple
<
F16
,
F16
,
F16
,
I32
>
,
std
::
tuple
<
F32
,
F32
,
F32
,
I32
>>
;
::
testing
::
Types
<
std
::
tuple
<
F16
,
F16
,
F32
,
I32
>
,
std
::
tuple
<
F32
,
F32
,
F32
,
I32
>>
;
#else
using
KernelTypes
=
::
testing
::
Types
<
std
::
tuple
<
F32
,
F32
,
F32
,
I32
>>
;
#endif
TYPED_TEST_SUITE
(
TestMaxPool3dFwd
,
KernelTypes
);
TYPED_TEST
(
TestMaxPool3dFwd
,
Test_Pool
)
{
// length, window_length, window_stride, left_pad, right_pad
this
->
params
=
{{{
1
,
1
,
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}},
{{
2
,
16
,
64
,
64
,
64
},
{
64
,
64
,
64
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}},
{{
2
,
32
,
30
,
30
,
30
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
1
,
1
,
1
},
{
1
,
1
,
1
}}};
// length, window_length, window_stride, window_dilation, left_pad, right_pad
this
->
params
=
{{{
1
,
1
,
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}},
{{
2
,
16
,
64
,
64
,
64
},
{
64
,
64
,
64
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}},
{{
2
,
16
,
64
,
64
,
64
},
{
4
,
4
,
4
},
{
4
,
4
,
4
},
{
2
,
2
,
2
},
{
0
,
0
,
0
},
{
0
,
0
,
0
}},
{{
2
,
32
,
30
,
30
,
30
},
{
2
,
2
,
2
},
{
2
,
2
,
2
},
{
1
,
1
,
1
},
{
1
,
1
,
1
},
{
1
,
1
,
1
}}};
this
->
Run
();
}
test/pool_fwd/test_pool_fwd_common.hpp
View file @
4100d1d8
...
...
@@ -14,11 +14,13 @@ struct PoolingParam
PoolingParam
(
const
std
::
vector
<
index_t
>&
length
,
const
std
::
vector
<
index_t
>&
window_spatial_lengths
,
const
std
::
vector
<
index_t
>&
window_strides
,
const
std
::
vector
<
index_t
>&
window_dilations
,
const
std
::
vector
<
index_t
>&
input_left_pads
,
const
std
::
vector
<
index_t
>&
input_right_pads
)
:
length_
(
length
),
window_spatial_lengths_
(
window_spatial_lengths
),
window_strides_
(
window_strides
),
window_dilations_
(
window_dilations
),
input_left_pads_
(
input_left_pads
),
input_right_pads_
(
input_right_pads
)
{
...
...
@@ -26,6 +28,7 @@ struct PoolingParam
std
::
vector
<
index_t
>
length_
;
std
::
vector
<
index_t
>
window_spatial_lengths_
;
std
::
vector
<
index_t
>
window_strides_
;
std
::
vector
<
index_t
>
window_dilations_
;
std
::
vector
<
index_t
>
input_left_pads_
;
std
::
vector
<
index_t
>
input_right_pads_
;
};
test/softmax/test_softmax_rank3.cpp
View file @
4100d1d8
...
...
@@ -10,10 +10,10 @@
template
<
ck
::
index_t
N
>
using
I
=
ck
::
Number
<
N
>
;
#ifdef CK_ENABLE_FP16
using
F16
=
ck
::
half_t
;
#endif
using
F32
=
float
;
using
I8
=
int8_t
;
template
<
typename
Tuple
>
class
TestSoftmax
:
public
ck
::
TestSoftmax
<
Tuple
>
...
...
@@ -23,9 +23,10 @@ class TestSoftmax : public ck::TestSoftmax<Tuple>
// clang-format off
using
KernelTypes
=
::
testing
::
Types
<
// InDataType, AccDataType, OutDataType, Rank
#ifdef CK_ENABLE_FP16
std
::
tuple
<
F16
,
F32
,
F16
,
I
<
3
>>
,
std
::
tuple
<
F32
,
F32
,
F32
,
I
<
3
>>
,
std
::
tuple
<
I8
,
F32
,
I8
,
I
<
3
>>
#endif
std
::
tuple
<
F32
,
F32
,
F32
,
I
<
3
>>
>
;
// clang-format on
...
...
test/softmax/test_softmax_rank4.cpp
View file @
4100d1d8
...
...
@@ -10,10 +10,10 @@
template
<
ck
::
index_t
N
>
using
I
=
ck
::
Number
<
N
>
;
#ifdef CK_ENABLE_FP16
using
F16
=
ck
::
half_t
;
#endif
using
F32
=
float
;
using
I8
=
int8_t
;
template
<
typename
Tuple
>
class
TestSoftmax
:
public
ck
::
TestSoftmax
<
Tuple
>
...
...
@@ -23,9 +23,10 @@ class TestSoftmax : public ck::TestSoftmax<Tuple>
// clang-format off
using
KernelTypes
=
::
testing
::
Types
<
// InDataType, AccDataType, OutDataType, Rank
#ifdef CK_ENABLE_FP16
std
::
tuple
<
F16
,
F32
,
F16
,
I
<
4
>>
,
std
::
tuple
<
F32
,
F32
,
F32
,
I
<
4
>>
,
std
::
tuple
<
I8
,
F32
,
I8
,
I
<
4
>>
#endif
std
::
tuple
<
F32
,
F32
,
F32
,
I
<
4
>>
>
;
// clang-format on
...
...
test/softmax/test_softmax_util.hpp
View file @
4100d1d8
...
...
@@ -61,8 +61,92 @@ class TestSoftmax : public ::testing::Test
int
init_method
=
1
;
// integer value initialization
bool
log
=
false
;
std
::
vector
<
ck
::
index_t
>
strides
;
// intenionally empty, to get packed layout.
bool
pass
=
ck
::
profiler
::
profile_softmax_impl
<
InDataType
,
AccDataType
,
OutDataType
,
Rank
>
(
verify_
,
init_method
,
log
,
bench_
,
in_length
,
strides
,
reduce_dims
,
alpha
,
beta
);
bool
pass
=
false
;
if
constexpr
(
Rank
==
3
)
{
if
(
reduce_dims
.
size
()
==
1
)
pass
=
ck
::
profiler
::
profile_softmax_impl
<
InDataType
,
AccDataType
,
OutDataType
,
Rank
,
1
>
(
verify_
,
init_method
,
log
,
bench_
,
in_length
,
strides
,
reduce_dims
,
alpha
,
beta
);
else
if
(
reduce_dims
.
size
()
==
2
)
pass
=
ck
::
profiler
::
profile_softmax_impl
<
InDataType
,
AccDataType
,
OutDataType
,
Rank
,
2
>
(
verify_
,
init_method
,
log
,
bench_
,
in_length
,
strides
,
reduce_dims
,
alpha
,
beta
);
else
if
(
reduce_dims
.
size
()
==
3
)
pass
=
ck
::
profiler
::
profile_softmax_impl
<
InDataType
,
AccDataType
,
OutDataType
,
Rank
,
3
>
(
verify_
,
init_method
,
log
,
bench_
,
in_length
,
strides
,
reduce_dims
,
alpha
,
beta
);
}
else
if
constexpr
(
Rank
==
4
)
{
if
(
reduce_dims
.
size
()
==
1
)
pass
=
ck
::
profiler
::
profile_softmax_impl
<
InDataType
,
AccDataType
,
OutDataType
,
Rank
,
1
>
(
verify_
,
init_method
,
log
,
bench_
,
in_length
,
strides
,
reduce_dims
,
alpha
,
beta
);
else
if
(
reduce_dims
.
size
()
==
2
)
pass
=
ck
::
profiler
::
profile_softmax_impl
<
InDataType
,
AccDataType
,
OutDataType
,
Rank
,
2
>
(
verify_
,
init_method
,
log
,
bench_
,
in_length
,
strides
,
reduce_dims
,
alpha
,
beta
);
else
if
(
reduce_dims
.
size
()
==
3
)
pass
=
ck
::
profiler
::
profile_softmax_impl
<
InDataType
,
AccDataType
,
OutDataType
,
Rank
,
3
>
(
verify_
,
init_method
,
log
,
bench_
,
in_length
,
strides
,
reduce_dims
,
alpha
,
beta
);
else
if
(
reduce_dims
.
size
()
==
4
)
pass
=
ck
::
profiler
::
profile_softmax_impl
<
InDataType
,
AccDataType
,
OutDataType
,
Rank
,
4
>
(
verify_
,
init_method
,
log
,
bench_
,
in_length
,
strides
,
reduce_dims
,
alpha
,
beta
);
};
EXPECT_TRUE
(
pass
);
}
...
...
Prev
1
…
27
28
29
30
31
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