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
0ade7981
Commit
0ade7981
authored
Jun 26, 2022
by
Jing Zhang
Browse files
add mnk padding
parent
ab04f22f
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
276 additions
and
94 deletions
+276
-94
example/24_batched_gemm_c_permute/batched_gemm_c_permute_xdl_fp16.cpp
...atched_gemm_c_permute/batched_gemm_c_permute_xdl_fp16.cpp
+19
-20
include/ck/tensor_operation/gpu/device/device_batched_gemm_c_permute_xdl.hpp
...peration/gpu/device/device_batched_gemm_c_permute_xdl.hpp
+257
-74
No files found.
example/24_batched_gemm_c_permute/batched_gemm_c_permute_xdl_fp16.cpp
View file @
0ade7981
...
...
@@ -39,7 +39,9 @@ using AElementOp = ck::tensor_operation::element_wise::PassThrough;
using
BElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
CElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
static
constexpr
auto
GemmDefault
=
ck
::
tensor_operation
::
device
::
GemmSpecialization
::
Default
;
// static constexpr auto GemmDefault = ck::tensor_operation::device::GemmSpecialization::Default;
// static constexpr auto MNPadding = ck::tensor_operation::device::GemmSpecialization::MNPadding;
static
constexpr
auto
MNKPadding
=
ck
::
tensor_operation
::
device
::
GemmSpecialization
::
MNKPadding
;
// clang-format off
using
DeviceGemmInstance
=
ck
::
tensor_operation
::
device
::
DeviceBatchedGemmCPermuteXdl
...
...
@@ -47,7 +49,8 @@ using DeviceGemmInstance = ck::tensor_operation::device::DeviceBatchedGemmCPermu
//######| | | Type| Type| Type| Type| Elementwise| Elementwise| Elementwise|Spacialization| Prefetch| Size| Block| Block| Block| | | XDL| XDL| Per| Per| ThreadCluster| ThreadCluster| SrcAccessOrder| SrcVectorDim| SrcScalar| DstScalar| AddExtraM| ThreadCluster| ThreadCluster| SrcAccessOrder| SrcVectorDim| SrcScalar| DstScalar| AddExtraN| MXdlPerWave| NXdlPerWave| _MBlock_MWaveMPerXdl| ScalarPerVector|
//######| | | | | | | Operation| Operation| Operation| | | | | | | | | | | Wave| Wave| Lengths_K0_M_K1| ArrangeOrder| | | PerVector| PerVector_K1| | Lengths_K0_N_K1| ArrangeOrder| | | PerVector| PerVector_K1| | PerShuffle| PerShuffle| _NBlock_NWaveNPerXdl| _NWaveNPerXdl|
//######| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
<
Row
,
Col
,
F16
,
F16
,
F16
,
F32
,
PassThrough
,
PassThrough
,
PassThrough
,
GemmDefault
,
1
,
256
,
256
,
128
,
32
,
8
,
8
,
32
,
32
,
4
,
2
,
S
<
4
,
64
,
1
>
,
S
<
1
,
0
,
2
>
,
S
<
1
,
0
,
2
>
,
2
,
8
,
8
,
true
,
S
<
4
,
64
,
1
>
,
S
<
1
,
0
,
2
>
,
S
<
1
,
0
,
2
>
,
2
,
8
,
8
,
true
,
1
,
1
,
S
<
1
,
32
,
1
,
8
>
,
8
>
;
// < Row, Col, F16, F16, F16, F32, PassThrough, PassThrough, PassThrough, MNPadding, 1, 256, 256, 128, 32, 8, 8, 32, 32, 4, 2, S<4, 64, 1>, S<1, 0, 2>, S<1, 0, 2>, 2, 8, 8, true, S<4, 64, 1>, S<1, 0, 2>, S<1, 0, 2>, 2, 8, 8, true, 1, 1, S<1, 32, 1, 8>, 8>;
<
Row
,
Col
,
F16
,
F16
,
F16
,
F32
,
PassThrough
,
PassThrough
,
PassThrough
,
MNKPadding
,
1
,
256
,
128
,
64
,
32
,
8
,
8
,
32
,
32
,
2
,
1
,
S
<
4
,
64
,
1
>
,
S
<
1
,
0
,
2
>
,
S
<
1
,
0
,
2
>
,
2
,
8
,
8
,
true
,
S
<
4
,
32
,
1
>
,
S
<
1
,
0
,
2
>
,
S
<
1
,
0
,
2
>
,
2
,
8
,
8
,
true
,
1
,
1
,
S
<
1
,
32
,
1
,
8
>
,
8
>
;
// clang-format on
using
ReferenceBatchedGemmInstance
=
ck
::
tensor_operation
::
host
::
...
...
@@ -59,13 +62,9 @@ int main(int argc, char* argv[])
int
init_method
=
1
;
bool
time_kernel
=
false
;
// const int M = 88;
// const int N = 64;
// const int K = 88;
const
int
M
=
256
;
const
int
N
=
128
;
const
int
K
=
64
;
const
int
M
=
88
;
const
int
N
=
64
;
const
int
K
=
88
;
const
int
stride_A
=
K
;
const
int
stride_B
=
K
;
...
...
@@ -76,8 +75,8 @@ int main(int argc, char* argv[])
const
int
batch_count
=
G0
*
G1
;
// output layout - [G0, M, G1, N]
const
int
stride_
B
0
=
M
*
G1
*
N
;
const
int
stride_
B
1
=
N
;
const
int
stride_
G
0
=
M
*
G1
*
N
;
const
int
stride_
G
1
=
N
;
const
int
stride_M
=
G1
*
N
;
const
int
stride_N
=
1
;
...
...
@@ -97,7 +96,7 @@ int main(int argc, char* argv[])
// GEMM shape
ck
::
tensor_operation
::
device
::
BatchedGemmCPermuteDesc
batched_gemm_c_permute_desc
{
G0
,
G1
,
M
,
N
,
stride_
B
0
,
stride_
B
1
,
stride_M
,
stride_N
};
G0
,
G1
,
M
,
N
,
stride_
G
0
,
stride_
G
1
,
stride_M
,
stride_N
};
auto
f_host_tensor_descriptor
=
[](
std
::
size_t
batch_count_
,
std
::
size_t
row
,
...
...
@@ -119,24 +118,24 @@ int main(int argc, char* argv[])
Tensor
<
ADataType
>
a_g_m_k
(
f_host_tensor_descriptor
(
batch_count
,
M
,
K
,
stride_A
,
ALayout
{}));
Tensor
<
BDataType
>
b_g_k_n
(
f_host_tensor_descriptor
(
batch_count
,
K
,
N
,
stride_B
,
BLayout
{}));
auto
f_host_c_tensor_descriptor
=
[](
std
::
size_t
B
0_
,
std
::
size_t
B
1_
,
auto
f_host_c_tensor_descriptor
=
[](
std
::
size_t
G
0_
,
std
::
size_t
G
1_
,
std
::
size_t
M_
,
std
::
size_t
N_
,
std
::
size_t
stride_
B
0_
,
std
::
size_t
stride_
B
1_
,
std
::
size_t
stride_
G
0_
,
std
::
size_t
stride_
G
1_
,
std
::
size_t
stride_M_
,
std
::
size_t
stride_N_
)
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
B
0_
,
B
1_
,
M_
,
N_
}),
std
::
vector
<
std
::
size_t
>
({
stride_
B
0_
,
stride_
B
1_
,
stride_M_
,
stride_N_
}));
std
::
vector
<
std
::
size_t
>
({
G
0_
,
G
1_
,
M_
,
N_
}),
std
::
vector
<
std
::
size_t
>
({
stride_
G
0_
,
stride_
G
1_
,
stride_M_
,
stride_N_
}));
};
Tensor
<
CDataType
>
c_g0_g1_m_n_host_result
(
f_host_c_tensor_descriptor
(
G0
,
G1
,
M
,
N
,
stride_
B
0
,
stride_
B
1
,
stride_M
,
stride_N
));
f_host_c_tensor_descriptor
(
G0
,
G1
,
M
,
N
,
stride_
G
0
,
stride_
G
1
,
stride_M
,
stride_N
));
Tensor
<
CDataType
>
c_g0_g1_m_n_device_result
(
f_host_c_tensor_descriptor
(
G0
,
G1
,
M
,
N
,
stride_
B
0
,
stride_
B
1
,
stride_M
,
stride_N
));
f_host_c_tensor_descriptor
(
G0
,
G1
,
M
,
N
,
stride_
G
0
,
stride_
G
1
,
stride_M
,
stride_N
));
std
::
cout
<<
"a_g_m_k: "
<<
a_g_m_k
.
mDesc
<<
std
::
endl
;
std
::
cout
<<
"b_g_k_n: "
<<
b_g_k_n
.
mDesc
<<
std
::
endl
;
...
...
include/ck/tensor_operation/gpu/device/device_batched_gemm_c_permute_xdl.hpp
View file @
0ade7981
This diff is collapsed.
Click to expand it.
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