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
289f15de
"vscode:/vscode.git/clone" did not exist on "3991a1c132cd2cd51bbe074a02b0b5a4da6bc6b2"
Commit
289f15de
authored
Dec 09, 2022
by
aska-0096
Browse files
Merge branch 'develop' of
https://github.com/ROCmSoftwarePlatform/composable_kernel
into wmma_gemm
parents
9bd44685
d58b7f51
Changes
371
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
587 additions
and
181 deletions
+587
-181
example/12_reduce/reduce_blockwise_two_call.cpp
example/12_reduce/reduce_blockwise_two_call.cpp
+7
-7
example/12_reduce/reduce_multiblock_atomic_add.cpp
example/12_reduce/reduce_multiblock_atomic_add.cpp
+1
-1
example/12_reduce/reduce_multiblock_atomic_add_impl.hpp
example/12_reduce/reduce_multiblock_atomic_add_impl.hpp
+6
-5
example/13_pool2d_fwd/pool2d_fwd_common.hpp
example/13_pool2d_fwd/pool2d_fwd_common.hpp
+8
-7
example/14_gemm_quantization/CMakeLists.txt
example/14_gemm_quantization/CMakeLists.txt
+2
-0
example/14_gemm_quantization/gemm_xdl_bias_relu_quantization_int8.cpp
...emm_quantization/gemm_xdl_bias_relu_quantization_int8.cpp
+235
-0
example/14_gemm_quantization/gemm_xdl_quantization_int8.cpp
example/14_gemm_quantization/gemm_xdl_quantization_int8.cpp
+207
-0
example/14_gemm_xdl_quantization/CMakeLists.txt
example/14_gemm_xdl_quantization/CMakeLists.txt
+0
-1
example/15_grouped_gemm/grouped_gemm_xdl_bfp16.cpp
example/15_grouped_gemm/grouped_gemm_xdl_bfp16.cpp
+1
-0
example/15_grouped_gemm/grouped_gemm_xdl_fp16.cpp
example/15_grouped_gemm/grouped_gemm_xdl_fp16.cpp
+1
-0
example/15_grouped_gemm/grouped_gemm_xdl_fp32.cpp
example/15_grouped_gemm/grouped_gemm_xdl_fp32.cpp
+1
-0
example/15_grouped_gemm/grouped_gemm_xdl_int4.cpp
example/15_grouped_gemm/grouped_gemm_xdl_int4.cpp
+1
-0
example/15_grouped_gemm/grouped_gemm_xdl_int8.cpp
example/15_grouped_gemm/grouped_gemm_xdl_int8.cpp
+1
-0
example/15_grouped_gemm/run_grouped_gemm_example.inc
example/15_grouped_gemm/run_grouped_gemm_example.inc
+6
-6
example/16_gemm_multi_d_multi_reduces/gemm_add_add_mean_meansquare_xdl_fp16.cpp
...d_multi_reduces/gemm_add_add_mean_meansquare_xdl_fp16.cpp
+9
-12
example/16_gemm_multi_d_multi_reduces/gemm_add_addsquare_xdl_int8.cpp
...emm_multi_d_multi_reduces/gemm_add_addsquare_xdl_int8.cpp
+7
-11
example/16_gemm_multi_d_multi_reduces/gemm_reduce_xdl_common.hpp
.../16_gemm_multi_d_multi_reduces/gemm_reduce_xdl_common.hpp
+17
-24
example/17_convnd_bwd_data/CMakeLists.txt
example/17_convnd_bwd_data/CMakeLists.txt
+3
-0
example/17_convnd_bwd_data/convnd_bwd_data_common.hpp
example/17_convnd_bwd_data/convnd_bwd_data_common.hpp
+8
-5
example/17_convnd_bwd_data/convnd_bwd_data_dl_fp16.cpp
example/17_convnd_bwd_data/convnd_bwd_data_dl_fp16.cpp
+66
-102
No files found.
example/12_reduce/reduce_blockwise_two_call.cpp
View file @
289f15de
...
@@ -221,12 +221,12 @@ int main(int argc, char* argv[])
...
@@ -221,12 +221,12 @@ int main(int argc, char* argv[])
std
::
array
<
index_t
,
3
>
arrOutLengths
;
std
::
array
<
index_t
,
3
>
arrOutLengths
;
std
::
array
<
index_t
,
3
>
arrOutStrides
;
std
::
array
<
index_t
,
3
>
arrOutStrides
;
std
::
copy
(
inLengths_1
.
begin
(),
inLengths_1
.
end
()
,
arrInLengths_1
.
begin
());
ck
::
ranges
::
copy
(
inLengths_1
,
arrInLengths_1
.
begin
());
std
::
copy
(
inStrides_1
.
begin
(),
inStrides_1
.
end
()
,
arrInStrides_1
.
begin
());
ck
::
ranges
::
copy
(
inStrides_1
,
arrInStrides_1
.
begin
());
std
::
copy
(
inLengths_2
.
begin
(),
inLengths_2
.
end
()
,
arrInLengths_2
.
begin
());
ck
::
ranges
::
copy
(
inLengths_2
,
arrInLengths_2
.
begin
());
std
::
copy
(
inStrides_2
.
begin
(),
inStrides_2
.
end
()
,
arrInStrides_2
.
begin
());
ck
::
ranges
::
copy
(
inStrides_2
,
arrInStrides_2
.
begin
());
std
::
copy
(
outLengths
.
begin
(),
outLengths
.
end
()
,
arrOutLengths
.
begin
());
ck
::
ranges
::
copy
(
outLengths
,
arrOutLengths
.
begin
());
std
::
copy
(
outStrides
.
begin
(),
outStrides
.
end
()
,
arrOutStrides
.
begin
());
ck
::
ranges
::
copy
(
outStrides
,
arrOutStrides
.
begin
());
auto
reduce_1
=
DeviceReduceInstance_1
{};
auto
reduce_1
=
DeviceReduceInstance_1
{};
...
@@ -294,7 +294,7 @@ int main(int argc, char* argv[])
...
@@ -294,7 +294,7 @@ int main(int argc, char* argv[])
if
(
do_verify
)
if
(
do_verify
)
{
{
out_dev
.
FromDevice
(
out
.
mData
.
data
());
out_dev
.
FromDevice
(
out
.
mData
.
data
());
pass
=
pass
&&
ck
::
utils
::
check_err
(
out
.
mData
,
out_ref
.
mData
);
pass
=
pass
&&
ck
::
utils
::
check_err
(
out
,
out_ref
);
};
};
return
(
pass
?
0
:
1
);
return
(
pass
?
0
:
1
);
...
...
example/12_reduce/reduce_multiblock_atomic_add.cpp
View file @
289f15de
...
@@ -140,7 +140,7 @@ bool reduce_multiblock_atomic_add_test(bool do_verification,
...
@@ -140,7 +140,7 @@ bool reduce_multiblock_atomic_add_test(bool do_verification,
std
::
array
<
int
,
ShapeType
::
NumReduceDim_
>
a_reduceDims
;
std
::
array
<
int
,
ShapeType
::
NumReduceDim_
>
a_reduceDims
;
std
::
copy
(
reduceDims
.
begin
(),
reduceDims
.
end
()
,
a_reduceDims
.
begin
());
ck
::
ranges
::
copy
(
reduceDims
,
a_reduceDims
.
begin
());
result
=
reduce_multiblock_atomic_add_impl
<
InOutDataType
,
result
=
reduce_multiblock_atomic_add_impl
<
InOutDataType
,
AccDataType
,
AccDataType
,
...
...
example/12_reduce/reduce_multiblock_atomic_add_impl.hpp
View file @
289f15de
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include "ck/tensor_operation/gpu/device/reduction_operator_mapping.hpp"
#include "ck/tensor_operation/gpu/device/reduction_operator_mapping.hpp"
#include "ck/tensor_operation/gpu/device/impl/device_reduce_multiblock.hpp"
#include "ck/tensor_operation/gpu/device/impl/device_reduce_multiblock.hpp"
#include "ck/library/utility/algorithm.hpp"
#include "ck/library/utility/check_err.hpp"
#include "ck/library/utility/check_err.hpp"
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor.hpp"
...
@@ -176,10 +177,10 @@ int reduce_multiblock_atomic_add_impl(bool do_verification,
...
@@ -176,10 +177,10 @@ int reduce_multiblock_atomic_add_impl(bool do_verification,
std
::
array
<
index_t
,
NumOutDim
>
arrOutLengths
;
std
::
array
<
index_t
,
NumOutDim
>
arrOutLengths
;
std
::
array
<
index_t
,
NumOutDim
>
arrOutStrides
;
std
::
array
<
index_t
,
NumOutDim
>
arrOutStrides
;
std
::
copy
(
inLengths
.
begin
(),
inLengths
.
end
()
,
arrInLengths
.
begin
());
ck
::
ranges
::
copy
(
inLengths
,
arrInLengths
.
begin
());
std
::
copy
(
inStrides
.
begin
(),
inStrides
.
end
()
,
arrInStrides
.
begin
());
ck
::
ranges
::
copy
(
inStrides
,
arrInStrides
.
begin
());
std
::
copy
(
outLengths
.
begin
(),
outLengths
.
end
()
,
arrOutLengths
.
begin
());
ck
::
ranges
::
copy
(
outLengths
,
arrOutLengths
.
begin
());
std
::
copy
(
outStrides
.
begin
(),
outStrides
.
end
()
,
arrOutStrides
.
begin
());
ck
::
ranges
::
copy
(
outStrides
,
arrOutStrides
.
begin
());
auto
reduce
=
DeviceReduceInstance
{};
auto
reduce
=
DeviceReduceInstance
{};
...
@@ -225,7 +226,7 @@ int reduce_multiblock_atomic_add_impl(bool do_verification,
...
@@ -225,7 +226,7 @@ int reduce_multiblock_atomic_add_impl(bool do_verification,
if
(
do_verification
)
if
(
do_verification
)
{
{
out_dev
.
FromDevice
(
out
.
mData
.
data
());
out_dev
.
FromDevice
(
out
.
mData
.
data
());
pass
=
pass
&&
ck
::
utils
::
check_err
(
out
.
mData
,
out_ref
.
mData
);
pass
=
pass
&&
ck
::
utils
::
check_err
(
out
,
out_ref
);
};
};
return
(
pass
?
0
:
1
);
return
(
pass
?
0
:
1
);
...
...
example/13_pool2d_fwd/pool2d_fwd_common.hpp
View file @
289f15de
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/literals.hpp"
template
<
typename
InDataType
,
template
<
typename
InDataType
,
typename
OutDataType
,
typename
OutDataType
,
...
@@ -172,16 +173,16 @@ bool pool_test(bool do_verification,
...
@@ -172,16 +173,16 @@ bool pool_test(bool do_verification,
// tensor layout
// tensor layout
auto
f_host_tensor_descriptor
=
auto
f_host_tensor_descriptor
=
[](
std
::
size_t
N_
,
std
::
size_t
C_
,
std
::
size_t
H
,
std
::
size_t
W
,
auto
layout
)
{
[](
std
::
size_t
N_
,
std
::
size_t
C_
,
std
::
size_t
H
,
std
::
size_t
W
,
auto
layout
)
{
using
namespace
ck
::
literals
;
if
constexpr
(
ck
::
is_same
<
decltype
(
layout
),
ck
::
tensor_layout
::
convolution
::
NCHW
>::
value
)
if
constexpr
(
ck
::
is_same
<
decltype
(
layout
),
ck
::
tensor_layout
::
convolution
::
NCHW
>::
value
)
{
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
N_
,
C_
,
H
,
W
}),
return
HostTensorDescriptor
({
N_
,
C_
,
H
,
W
},
{
C_
*
H
*
W
,
H
*
W
,
W
,
1
_uz
});
std
::
vector
<
std
::
size_t
>
({
C_
*
H
*
W
,
H
*
W
,
W
,
1
}));
}
}
else
if
constexpr
(
ck
::
is_same
<
decltype
(
layout
),
else
if
constexpr
(
ck
::
is_same
<
decltype
(
layout
),
ck
::
tensor_layout
::
convolution
::
NHWC
>::
value
)
ck
::
tensor_layout
::
convolution
::
NHWC
>::
value
)
{
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
N_
,
C_
,
H
,
W
}),
return
HostTensorDescriptor
({
N_
,
C_
,
H
,
W
},
{
C_
*
H
*
W
,
1
_uz
,
W
*
C_
,
C_
});
std
::
vector
<
std
::
size_t
>
({
C_
*
H
*
W
,
1
,
W
*
C_
,
C_
}));
}
}
};
};
...
@@ -267,14 +268,14 @@ bool pool_test(bool do_verification,
...
@@ -267,14 +268,14 @@ bool pool_test(bool do_verification,
out_device_buf
.
FromDevice
(
out_n_c_ho_wo_device
.
mData
.
data
());
out_device_buf
.
FromDevice
(
out_n_c_ho_wo_device
.
mData
.
data
());
pass
=
pass
&&
ck
::
utils
::
check_err
(
out_n_c_ho_wo_device
.
mData
,
out_n_c_ho_wo_host
.
mData
);
pass
=
pass
&&
ck
::
utils
::
check_err
(
out_n_c_ho_wo_device
,
out_n_c_ho_wo_host
);
if
constexpr
(
OutputIndex
)
if
constexpr
(
OutputIndex
)
{
{
out_indices_device_buf
.
FromDevice
(
out_indices_n_c_ho_wo_device
.
mData
.
data
());
out_indices_device_buf
.
FromDevice
(
out_indices_n_c_ho_wo_device
.
mData
.
data
());
pass
=
pass
&&
ck
::
utils
::
check_err
(
out_indices_n_c_ho_wo_device
.
mData
,
pass
=
pass
&&
out_indices_n_c_ho_wo_host
.
mData
);
ck
::
utils
::
check_err
(
out_indices_n_c_ho_wo_device
,
out_indices_n_c_ho_wo_host
);
};
};
}
}
...
...
example/14_gemm_quantization/CMakeLists.txt
0 → 100644
View file @
289f15de
add_example_executable
(
example_gemm_xdl_bias_relu_quantization_int8 gemm_xdl_bias_relu_quantization_int8.cpp
)
add_example_executable
(
example_gemm_xdl_quantization_int8 gemm_xdl_quantization_int8.cpp
)
\ No newline at end of file
example/14_gemm_quantization/gemm_xdl_bias_relu_quantization_int8.cpp
0 → 100644
View file @
289f15de
// 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 "ck/ck.hpp"
#include "ck/tensor_operation/gpu/device/tensor_layout.hpp"
#include "ck/tensor_operation/gpu/device/gemm_specialization.hpp"
#include "ck/tensor_operation/gpu/device/impl/device_gemm_multiple_d_xdl_cshuffle.hpp"
#include "ck/tensor_operation/gpu/element/element_wise_operation.hpp"
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/literals.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
#include "ck/library/utility/check_err.hpp"
template
<
ck
::
index_t
...
Is
>
using
S
=
ck
::
Sequence
<
Is
...
>
;
using
I8
=
int8_t
;
using
I32
=
int32_t
;
using
Row
=
ck
::
tensor_layout
::
gemm
::
RowMajor
;
using
Col
=
ck
::
tensor_layout
::
gemm
::
ColumnMajor
;
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
ActivationOp
=
ck
::
tensor_operation
::
element_wise
::
Relu
;
using
CDEElementOp
=
ck
::
tensor_operation
::
element_wise
::
Add_Activation_Mul_Clamp
<
ActivationOp
>
;
using
ADataType
=
I8
;
using
BDataType
=
I8
;
using
AccDataType
=
I32
;
using
CShuffleDataType
=
I32
;
using
BiasDataType
=
I32
;
using
DsDataType
=
ck
::
Tuple
<
BiasDataType
>
;
using
EDataType
=
I8
;
using
ALayout
=
Row
;
using
BLayout
=
Col
;
using
BiasLayout
=
Row
;
using
DsLayout
=
ck
::
Tuple
<
BiasLayout
>
;
using
ELayout
=
Row
;
static
constexpr
auto
GemmDefault
=
ck
::
tensor_operation
::
device
::
GemmSpecialization
::
Default
;
// clang-format off
using
DeviceGemmInstance
=
ck
::
tensor_operation
::
device
::
DeviceGemmMultipleD_Xdl_CShuffle
<
ALayout
,
BLayout
,
DsLayout
,
ELayout
,
ADataType
,
BDataType
,
AccDataType
,
CShuffleDataType
,
DsDataType
,
EDataType
,
PassThrough
,
// AElementwiseOperation,
PassThrough
,
// BElementwiseOperation,
CDEElementOp
,
// CDEElementwiseOperation,
GemmDefault
,
// GemmSpecialization GemmSpec,
1
,
// NumGemmKPrefetchStage,
256
,
// BlockSize,
256
,
// MPerBlock,
128
,
// NPerBlock,
64
,
// KPerBlock,
16
,
// AK1,
16
,
// BK1,
32
,
// MPerXDL,
32
,
// NPerXDL,
4
,
// MXdlPerWave,
2
,
// NXdlPerWave,
S
<
4
,
64
,
1
>
,
// ABlockTransferThreadClusterLengths_AK0_M_AK1,
S
<
1
,
0
,
2
>
,
// ABlockTransferThreadClusterArrangeOrder,
S
<
1
,
0
,
2
>
,
// ABlockTransferSrcAccessOrder,
2
,
// index_t ABlockTransferSrcVectorDim,
16
,
// index_t ABlockTransferSrcScalarPerVector,
16
,
// index_t ABlockTransferDstScalarPerVector_AK1,
1
,
// bool ABlockLdsExtraM,
S
<
4
,
64
,
1
>
,
// typename BBlockTransferThreadClusterLengths_BK0_N_BK1,
S
<
1
,
0
,
2
>
,
// typename BBlockTransferThreadClusterArrangeOrder,
S
<
1
,
0
,
2
>
,
// typename BBlockTransferSrcAccessOrder,
2
,
// index_t BBlockTransferSrcVectorDim,
8
,
// index_t BBlockTransferSrcScalarPerVector,
8
,
// index_t BBlockTransferDstScalarPerVector_BK1,
1
,
// bool BBlockLdsExtraN,
1
,
// index_t CShuffleMXdlPerWavePerShuffle,
1
,
// index_t CShuffleNXdlPerWavePerShuffle,
S
<
1
,
64
,
1
,
4
>
,
// typename CShuffleBlockTransferClusterLengths_MBlock_MPerBlock_NBlock_NPerBlock,
8
>
;
// index_t CShuffleBlockTransferScalarPerVector_NPerBlock>
// clang-format on
using
ReferenceGemmInstance
=
ck
::
tensor_operation
::
host
::
ReferenceGemm
<
ADataType
,
BDataType
,
AccDataType
,
AccDataType
,
PassThrough
,
PassThrough
,
PassThrough
>
;
int
main
()
{
bool
do_verification
=
true
;
bool
time_kernel
=
false
;
// GEMM shape
ck
::
index_t
M
=
1024
;
ck
::
index_t
N
=
1024
;
ck
::
index_t
K
=
1024
;
ck
::
index_t
StrideA
=
1024
;
ck
::
index_t
StrideB
=
1024
;
ck
::
index_t
StrideBias
=
0
;
ck
::
index_t
StrideE
=
1024
;
float
requant_scale
=
0.03
;
auto
f_host_tensor_descriptor2d
=
[](
std
::
size_t
row
,
std
::
size_t
col
,
std
::
size_t
stride
,
auto
layout
)
{
using
namespace
ck
::
literals
;
if
(
std
::
is_same
<
decltype
(
layout
),
ck
::
tensor_layout
::
gemm
::
RowMajor
>::
value
)
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
row
,
col
}),
std
::
vector
<
std
::
size_t
>
({
stride
,
1
_uz
}));
}
else
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
row
,
col
}),
std
::
vector
<
std
::
size_t
>
({
1
_uz
,
stride
}));
}
};
auto
f_host_tensor_descriptor1d
=
[](
std
::
size_t
len
,
std
::
size_t
stride
)
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
len
}),
std
::
vector
<
std
::
size_t
>
({
stride
}));
};
Tensor
<
ADataType
>
a_m_k
(
f_host_tensor_descriptor2d
(
M
,
K
,
StrideA
,
ALayout
{}));
Tensor
<
BDataType
>
b_k_n
(
f_host_tensor_descriptor2d
(
K
,
N
,
StrideB
,
BLayout
{}));
Tensor
<
BiasDataType
>
bias_n
(
f_host_tensor_descriptor1d
(
N
,
1
));
Tensor
<
EDataType
>
e_m_n_host_result
(
f_host_tensor_descriptor2d
(
M
,
N
,
StrideE
,
ELayout
{}));
Tensor
<
EDataType
>
e_m_n_device_result
(
f_host_tensor_descriptor2d
(
M
,
N
,
StrideE
,
ELayout
{}));
std
::
cout
<<
"a_m_k: "
<<
a_m_k
.
mDesc
<<
std
::
endl
;
std
::
cout
<<
"b_k_n: "
<<
b_k_n
.
mDesc
<<
std
::
endl
;
std
::
cout
<<
"bias_n: "
<<
bias_n
.
mDesc
<<
std
::
endl
;
std
::
cout
<<
"e_m_n: "
<<
e_m_n_host_result
.
mDesc
<<
std
::
endl
;
a_m_k
.
GenerateTensorValue
(
GeneratorTensor_2
<
ADataType
>
{
-
128
,
127
});
b_k_n
.
GenerateTensorValue
(
GeneratorTensor_2
<
BDataType
>
{
-
128
,
127
});
bias_n
.
GenerateTensorValue
(
GeneratorTensor_2
<
BiasDataType
>
{
-
128
,
127
});
DeviceMem
a_device_buf
(
sizeof
(
ADataType
)
*
a_m_k
.
mDesc
.
GetElementSpaceSize
());
DeviceMem
b_device_buf
(
sizeof
(
BDataType
)
*
b_k_n
.
mDesc
.
GetElementSpaceSize
());
DeviceMem
bias_device_buf
(
sizeof
(
BiasDataType
)
*
bias_n
.
mDesc
.
GetElementSpaceSize
());
DeviceMem
e_device_buf
(
sizeof
(
EDataType
)
*
e_m_n_device_result
.
mDesc
.
GetElementSpaceSize
());
a_device_buf
.
ToDevice
(
a_m_k
.
mData
.
data
());
b_device_buf
.
ToDevice
(
b_k_n
.
mData
.
data
());
bias_device_buf
.
ToDevice
(
bias_n
.
mData
.
data
());
auto
a_element_op
=
PassThrough
{};
auto
b_element_op
=
PassThrough
{};
auto
cde_element_op
=
CDEElementOp
{
requant_scale
,
ActivationOp
{}};
// do GEMM
auto
gemm
=
DeviceGemmInstance
{};
auto
invoker
=
gemm
.
MakeInvoker
();
auto
argument
=
gemm
.
MakeArgument
(
a_device_buf
.
GetDeviceBuffer
(),
b_device_buf
.
GetDeviceBuffer
(),
{
bias_device_buf
.
GetDeviceBuffer
()},
e_device_buf
.
GetDeviceBuffer
(),
M
,
N
,
K
,
StrideA
,
StrideB
,
{
StrideBias
},
StrideE
,
a_element_op
,
b_element_op
,
cde_element_op
);
if
(
!
gemm
.
IsSupportedArgument
(
argument
))
{
throw
std
::
runtime_error
(
"wrong! device_gemm with the specified compilation parameters does "
"not support this GEMM problem"
);
}
float
ave_time
=
invoker
.
Run
(
argument
,
StreamConfig
{
nullptr
,
time_kernel
});
std
::
size_t
flop
=
std
::
size_t
(
2
)
*
M
*
N
*
K
;
std
::
size_t
num_btype
=
sizeof
(
ADataType
)
*
M
*
K
+
sizeof
(
BDataType
)
*
K
*
N
+
sizeof
(
EDataType
)
*
M
*
N
;
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, "
<<
gemm
.
GetTypeString
()
<<
std
::
endl
;
e_device_buf
.
FromDevice
(
e_m_n_device_result
.
mData
.
data
());
if
(
do_verification
)
{
Tensor
<
AccDataType
>
c_m_n
(
HostTensorDescriptor
{
M
,
N
});
auto
ref_gemm
=
ReferenceGemmInstance
{};
auto
ref_invoker
=
ref_gemm
.
MakeInvoker
();
auto
ref_argument
=
ref_gemm
.
MakeArgument
(
a_m_k
,
b_k_n
,
c_m_n
,
a_element_op
,
b_element_op
,
PassThrough
{});
ref_invoker
.
Run
(
ref_argument
);
for
(
int
m
=
0
;
m
<
M
;
++
m
)
{
for
(
int
n
=
0
;
n
<
N
;
++
n
)
{
cde_element_op
(
e_m_n_host_result
(
m
,
n
),
c_m_n
(
m
,
n
),
bias_n
(
n
));
}
}
return
ck
::
utils
::
check_err
(
e_m_n_device_result
,
e_m_n_host_result
)
?
0
:
1
;
}
return
0
;
}
example/14_gemm_
xdl_
quantization/gemm_xdl_
relu_
quantization_int8.cpp
→
example/14_gemm_quantization/gemm_xdl_quantization_int8.cpp
View file @
289f15de
...
@@ -9,62 +9,72 @@
...
@@ -9,62 +9,72 @@
#include "ck/ck.hpp"
#include "ck/ck.hpp"
#include "ck/tensor_operation/gpu/device/tensor_layout.hpp"
#include "ck/tensor_operation/gpu/device/tensor_layout.hpp"
#include "ck/tensor_operation/gpu/device/gemm_specialization.hpp"
#include "ck/tensor_operation/gpu/device/gemm_specialization.hpp"
#include "ck/tensor_operation/gpu/device/impl/device_gemm_xdl_cshuffle.hpp"
#include "ck/tensor_operation/gpu/device/impl/device_gemm_
multiple_d_
xdl_cshuffle.hpp"
#include "ck/tensor_operation/gpu/element/element_wise_operation.hpp"
#include "ck/tensor_operation/gpu/element/element_wise_operation.hpp"
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/literals.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
#include "ck/library/utility/check_err.hpp"
#include "ck/library/utility/check_err.hpp"
template
<
ck
::
index_t
...
Is
>
template
<
ck
::
index_t
...
Is
>
using
S
=
ck
::
Sequence
<
Is
...
>
;
using
S
=
ck
::
Sequence
<
Is
...
>
;
using
I8
=
int8_t
;
using
I32
=
int32_t
;
using
Row
=
ck
::
tensor_layout
::
gemm
::
RowMajor
;
using
Col
=
ck
::
tensor_layout
::
gemm
::
ColumnMajor
;
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
ActivationOp
=
ck
::
tensor_operation
::
element_wise
::
Relu
;
using
ActivationOp
=
PassThrough
;
using
CElementOp
=
ck
::
tensor_operation
::
element_wise
::
Activation_Mul_Clamp
<
ActivationOp
>
;
using
C
DE
ElementOp
=
ck
::
tensor_operation
::
element_wise
::
Activation_Mul_Clamp
<
ActivationOp
>
;
using
ADataType
=
int8_t
;
using
ADataType
=
I8
;
using
BDataType
=
int8_t
;
using
BDataType
=
I8
;
using
CDataType
=
int8_t
;
using
AccDataType
=
I32
;
using
AccDataType
=
int32_t
;
using
CShuffleDataType
=
I32
;
using
CShuffleDataType
=
float
;
using
DsDataType
=
ck
::
Tuple
<>
;
using
EDataType
=
I8
;
using
ALayout
=
ck
::
tensor_layout
::
gemm
::
RowMajor
;
using
ALayout
=
Row
;
using
BLayout
=
ck
::
tensor_layout
::
gemm
::
ColumnMajor
;
using
BLayout
=
Col
;
using
CLayout
=
ck
::
tensor_layout
::
gemm
::
RowMajor
;
using
DsLayout
=
ck
::
Tuple
<>
;
using
ELayout
=
Row
;
static
constexpr
auto
GemmDefault
=
ck
::
tensor_operation
::
device
::
GemmSpecialization
::
Default
;
static
constexpr
auto
GemmDefault
=
ck
::
tensor_operation
::
device
::
GemmSpecialization
::
Default
;
// clang-format off
// clang-format off
using
DeviceGemmInstance
=
ck
::
tensor_operation
::
device
::
DeviceGemm_Xdl_CShuffle
<
using
DeviceGemmInstance
=
ck
::
tensor_operation
::
device
::
DeviceGemmMultipleD_Xdl_CShuffle
<
ALayout
,
// typename ALayout,
ALayout
,
BLayout
,
// typename BLayout,
BLayout
,
CLayout
,
// typename CLayout,
DsLayout
,
ADataType
,
// typename ADataType,
ELayout
,
BDataType
,
// typename BDataType,
ADataType
,
CDataType
,
// typename CDataType,
BDataType
,
AccDataType
,
// typename GemmAccDataType,
AccDataType
,
CShuffleDataType
,
// typename CShuffleDataType,
CShuffleDataType
,
PassThrough
,
// typename AElementwiseOperation,
DsDataType
,
PassThrough
,
// typename BElementwiseOperation,
EDataType
,
CElementOp
,
// typename CElementwiseOperation,
PassThrough
,
// AElementwiseOperation,
PassThrough
,
// BElementwiseOperation,
CDEElementOp
,
// CDEElementwiseOperation,
GemmDefault
,
// GemmSpecialization GemmSpec,
GemmDefault
,
// GemmSpecialization GemmSpec,
1
,
//
index_t
NumGemmKPrefetchStage,
1
,
// NumGemmKPrefetchStage,
256
,
//
index_t
BlockSize,
256
,
// BlockSize,
256
,
//
index_t
MPerBlock,
256
,
// MPerBlock,
128
,
//
index_t
NPerBlock,
128
,
// NPerBlock,
64
,
//
index_t
KPerBlock,
64
,
// KPerBlock,
16
,
//
index_t
AK1,
16
,
// AK1,
16
,
//
index_t
BK1,
16
,
// BK1,
32
,
//
index_t
MPerXDL,
32
,
// MPerXDL,
32
,
//
index_t
NPerXDL,
32
,
// NPerXDL,
4
,
//
index_t
MXdlPerWave,
4
,
// MXdlPerWave,
2
,
//
index_t
NXdlPerWave,
2
,
// NXdlPerWave,
S
<
4
,
64
,
1
>
,
//
typename
ABlockTransferThreadClusterLengths_AK0_M_AK1,
S
<
4
,
64
,
1
>
,
// ABlockTransferThreadClusterLengths_AK0_M_AK1,
S
<
1
,
0
,
2
>
,
//
typename
ABlockTransferThreadClusterArrangeOrder,
S
<
1
,
0
,
2
>
,
// ABlockTransferThreadClusterArrangeOrder,
S
<
1
,
0
,
2
>
,
//
typename
ABlockTransferSrcAccessOrder,
S
<
1
,
0
,
2
>
,
// ABlockTransferSrcAccessOrder,
2
,
// index_t ABlockTransferSrcVectorDim,
2
,
// index_t ABlockTransferSrcVectorDim,
16
,
// index_t ABlockTransferSrcScalarPerVector,
16
,
// index_t ABlockTransferSrcScalarPerVector,
16
,
// index_t ABlockTransferDstScalarPerVector_AK1,
16
,
// index_t ABlockTransferDstScalarPerVector_AK1,
...
@@ -83,115 +93,80 @@ using DeviceGemmInstance = ck::tensor_operation::device::DeviceGemm_Xdl_CShuffle
...
@@ -83,115 +93,80 @@ using DeviceGemmInstance = ck::tensor_operation::device::DeviceGemm_Xdl_CShuffle
// clang-format on
// clang-format on
using
ReferenceGemmInstance
=
ck
::
tensor_operation
::
host
::
using
ReferenceGemmInstance
=
ck
::
tensor_operation
::
host
::
ReferenceGemm
<
ADataType
,
BDataType
,
C
DataType
,
float
,
PassThrough
,
PassThrough
,
CElementOp
>
;
ReferenceGemm
<
ADataType
,
BDataType
,
E
DataType
,
float
,
PassThrough
,
PassThrough
,
C
DE
ElementOp
>
;
int
main
(
int
argc
,
char
*
argv
[]
)
int
main
()
{
{
bool
do_verification
=
true
;
bool
do_verification
=
true
;
int
init_method
=
1
;
bool
time_kernel
=
false
;
bool
time_kernel
=
false
;
// GEMM shape
// GEMM shape
ck
::
index_t
M
=
3840
;
ck
::
index_t
M
=
1024
;
ck
::
index_t
N
=
4096
;
ck
::
index_t
N
=
1024
;
ck
::
index_t
K
=
4096
;
ck
::
index_t
K
=
1024
;
ck
::
index_t
StrideA
=
4096
;
ck
::
index_t
StrideB
=
4096
;
ck
::
index_t
StrideC
=
4096
;
float
quant_multiplier
=
0.03
;
if
(
argc
==
4
)
{
do_verification
=
std
::
stoi
(
argv
[
1
]);
init_method
=
std
::
stoi
(
argv
[
2
]);
time_kernel
=
std
::
stoi
(
argv
[
3
]);
}
else
if
(
argc
==
10
)
{
do_verification
=
std
::
stoi
(
argv
[
1
]);
init_method
=
std
::
stoi
(
argv
[
2
]);
time_kernel
=
std
::
stoi
(
argv
[
3
]);
M
=
std
::
stoi
(
argv
[
4
])
;
ck
::
index_t
StrideA
=
1024
;
N
=
std
::
stoi
(
argv
[
5
])
;
ck
::
index_t
StrideB
=
1024
;
K
=
std
::
stoi
(
argv
[
6
])
;
ck
::
index_t
StrideE
=
1024
;
StrideA
=
std
::
stoi
(
argv
[
7
]);
float
requant_scale
=
0.03
;
StrideB
=
std
::
stoi
(
argv
[
8
]);
StrideC
=
std
::
stoi
(
argv
[
9
]);
}
else
{
printf
(
"arg1: verification (0=no, 1=yes)
\n
"
);
printf
(
"arg2: initialization (0=no init, 1=integer value, 2=decimal value)
\n
"
);
printf
(
"arg3: time kernel (0=n0, 1=yes)
\n
"
);
printf
(
"arg4 to 9: M (256x), N(128x), K(32x), StrideA, StrideB, StrideC
\n
"
);
exit
(
0
);
}
auto
f_host_tensor_descriptor
=
auto
f_host_tensor_descriptor
=
[](
std
::
size_t
row
,
std
::
size_t
col
,
std
::
size_t
stride
,
auto
layout
)
{
[](
std
::
size_t
row
,
std
::
size_t
col
,
std
::
size_t
stride
,
auto
layout
)
{
using
namespace
ck
::
literals
;
if
(
std
::
is_same
<
decltype
(
layout
),
ck
::
tensor_layout
::
gemm
::
RowMajor
>::
value
)
if
(
std
::
is_same
<
decltype
(
layout
),
ck
::
tensor_layout
::
gemm
::
RowMajor
>::
value
)
{
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
row
,
col
}),
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
row
,
col
}),
std
::
vector
<
std
::
size_t
>
({
stride
,
1
}));
std
::
vector
<
std
::
size_t
>
({
stride
,
1
_uz
}));
}
}
else
else
{
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
row
,
col
}),
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
row
,
col
}),
std
::
vector
<
std
::
size_t
>
({
1
,
stride
}));
std
::
vector
<
std
::
size_t
>
({
1
_uz
,
stride
}));
}
}
};
};
Tensor
<
ADataType
>
a_m_k
(
f_host_tensor_descriptor
(
M
,
K
,
StrideA
,
ALayout
{}));
Tensor
<
ADataType
>
a_m_k
(
f_host_tensor_descriptor
(
M
,
K
,
StrideA
,
ALayout
{}));
Tensor
<
BDataType
>
b_k_n
(
f_host_tensor_descriptor
(
K
,
N
,
StrideB
,
BLayout
{}));
Tensor
<
BDataType
>
b_k_n
(
f_host_tensor_descriptor
(
K
,
N
,
StrideB
,
BLayout
{}));
Tensor
<
C
DataType
>
c
_m_n_host_result
(
f_host_tensor_descriptor
(
M
,
N
,
Stride
C
,
C
Layout
{}));
Tensor
<
E
DataType
>
e
_m_n_host_result
(
f_host_tensor_descriptor
(
M
,
N
,
Stride
E
,
E
Layout
{}));
Tensor
<
C
DataType
>
c
_m_n_device_result
(
f_host_tensor_descriptor
(
M
,
N
,
Stride
C
,
C
Layout
{}));
Tensor
<
E
DataType
>
e
_m_n_device_result
(
f_host_tensor_descriptor
(
M
,
N
,
Stride
E
,
E
Layout
{}));
std
::
cout
<<
"a_m_k: "
<<
a_m_k
.
mDesc
<<
std
::
endl
;
std
::
cout
<<
"a_m_k: "
<<
a_m_k
.
mDesc
<<
std
::
endl
;
std
::
cout
<<
"b_k_n: "
<<
b_k_n
.
mDesc
<<
std
::
endl
;
std
::
cout
<<
"b_k_n: "
<<
b_k_n
.
mDesc
<<
std
::
endl
;
std
::
cout
<<
"
c
_m_n: "
<<
c
_m_n_host_result
.
mDesc
<<
std
::
endl
;
std
::
cout
<<
"
e
_m_n: "
<<
e
_m_n_host_result
.
mDesc
<<
std
::
endl
;
switch
(
init_method
)
a_m_k
.
GenerateTensorValue
(
GeneratorTensor_2
<
ADataType
>
{
-
128
,
127
});
{
b_k_n
.
GenerateTensorValue
(
GeneratorTensor_2
<
BDataType
>
{
-
128
,
127
});
case
0
:
break
;
case
1
:
a_m_k
.
GenerateTensorValue
(
GeneratorTensor_2
<
ADataType
>
{
-
5
,
5
});
b_k_n
.
GenerateTensorValue
(
GeneratorTensor_2
<
BDataType
>
{
-
5
,
5
});
break
;
default:
a_m_k
.
GenerateTensorValue
(
GeneratorTensor_3
<
ADataType
>
{
0.0
,
1.0
});
b_k_n
.
GenerateTensorValue
(
GeneratorTensor_3
<
BDataType
>
{
-
0.5
,
0.5
});
}
DeviceMem
a_
m_k_
device_buf
(
sizeof
(
ADataType
)
*
a_m_k
.
mDesc
.
GetElementSpaceSize
());
DeviceMem
a_device_buf
(
sizeof
(
ADataType
)
*
a_m_k
.
mDesc
.
GetElementSpaceSize
());
DeviceMem
b_
k_n_
device_buf
(
sizeof
(
BDataType
)
*
b_k_n
.
mDesc
.
GetElementSpaceSize
());
DeviceMem
b_device_buf
(
sizeof
(
BDataType
)
*
b_k_n
.
mDesc
.
GetElementSpaceSize
());
DeviceMem
c_m_n
_device_buf
(
sizeof
(
C
DataType
)
*
c
_m_n_device_result
.
mDesc
.
GetElementSpaceSize
());
DeviceMem
e
_device_buf
(
sizeof
(
E
DataType
)
*
e
_m_n_device_result
.
mDesc
.
GetElementSpaceSize
());
a_
m_k_
device_buf
.
ToDevice
(
a_m_k
.
mData
.
data
());
a_device_buf
.
ToDevice
(
a_m_k
.
mData
.
data
());
b_
k_n_
device_buf
.
ToDevice
(
b_k_n
.
mData
.
data
());
b_device_buf
.
ToDevice
(
b_k_n
.
mData
.
data
());
auto
a_element_op
=
PassThrough
{};
auto
a_element_op
=
PassThrough
{};
auto
b_element_op
=
PassThrough
{};
auto
b_element_op
=
PassThrough
{};
auto
c_element_op
=
CElementOp
{
quant_
multiplier
,
ActivationOp
{}};
auto
c
de
_element_op
=
C
DE
ElementOp
{
re
quant_
scale
,
ActivationOp
{}};
// do GEMM
// do GEMM
auto
gemm
=
DeviceGemmInstance
{};
auto
gemm
=
DeviceGemmInstance
{};
auto
invoker
=
gemm
.
MakeInvoker
();
auto
invoker
=
gemm
.
MakeInvoker
();
auto
argument
=
gemm
.
MakeArgument
(
static_cast
<
ADataType
*>
(
a_m_k_device_buf
.
GetDeviceBuffer
()),
auto
argument
=
gemm
.
MakeArgument
(
a_device_buf
.
GetDeviceBuffer
(),
static_cast
<
BDataType
*>
(
b_k_n_device_buf
.
GetDeviceBuffer
()),
b_device_buf
.
GetDeviceBuffer
(),
static_cast
<
CDataType
*>
(
c_m_n_device_buf
.
GetDeviceBuffer
()),
{},
e_device_buf
.
GetDeviceBuffer
(),
M
,
M
,
N
,
N
,
K
,
K
,
StrideA
,
StrideA
,
StrideB
,
StrideB
,
StrideC
,
{},
StrideE
,
a_element_op
,
a_element_op
,
b_element_op
,
b_element_op
,
c_element_op
);
c
de
_element_op
);
if
(
!
gemm
.
IsSupportedArgument
(
argument
))
if
(
!
gemm
.
IsSupportedArgument
(
argument
))
{
{
...
@@ -204,7 +179,7 @@ int main(int argc, char* argv[])
...
@@ -204,7 +179,7 @@ int main(int argc, char* argv[])
std
::
size_t
flop
=
std
::
size_t
(
2
)
*
M
*
N
*
K
;
std
::
size_t
flop
=
std
::
size_t
(
2
)
*
M
*
N
*
K
;
std
::
size_t
num_btype
=
std
::
size_t
num_btype
=
sizeof
(
ADataType
)
*
M
*
K
+
sizeof
(
BDataType
)
*
K
*
N
+
sizeof
(
C
DataType
)
*
M
*
N
;
sizeof
(
ADataType
)
*
M
*
K
+
sizeof
(
BDataType
)
*
K
*
N
+
sizeof
(
E
DataType
)
*
M
*
N
;
float
tflops
=
static_cast
<
float
>
(
flop
)
/
1.E9
/
ave_time
;
float
tflops
=
static_cast
<
float
>
(
flop
)
/
1.E9
/
ave_time
;
...
@@ -213,7 +188,7 @@ int main(int argc, char* argv[])
...
@@ -213,7 +188,7 @@ int main(int argc, char* argv[])
std
::
cout
<<
"Perf: "
<<
ave_time
<<
" ms, "
<<
tflops
<<
" TFlops, "
<<
gb_per_sec
<<
" GB/s, "
std
::
cout
<<
"Perf: "
<<
ave_time
<<
" ms, "
<<
tflops
<<
" TFlops, "
<<
gb_per_sec
<<
" GB/s, "
<<
gemm
.
GetTypeString
()
<<
std
::
endl
;
<<
gemm
.
GetTypeString
()
<<
std
::
endl
;
c_m_n
_device_buf
.
FromDevice
(
c
_m_n_device_result
.
mData
.
data
());
e
_device_buf
.
FromDevice
(
e
_m_n_device_result
.
mData
.
data
());
if
(
do_verification
)
if
(
do_verification
)
{
{
...
@@ -221,11 +196,11 @@ int main(int argc, char* argv[])
...
@@ -221,11 +196,11 @@ int main(int argc, char* argv[])
auto
ref_invoker
=
ref_gemm
.
MakeInvoker
();
auto
ref_invoker
=
ref_gemm
.
MakeInvoker
();
auto
ref_argument
=
ref_gemm
.
MakeArgument
(
auto
ref_argument
=
ref_gemm
.
MakeArgument
(
a_m_k
,
b_k_n
,
c
_m_n_host_result
,
a_element_op
,
b_element_op
,
c_element_op
);
a_m_k
,
b_k_n
,
e
_m_n_host_result
,
a_element_op
,
b_element_op
,
c
de
_element_op
);
ref_invoker
.
Run
(
ref_argument
);
ref_invoker
.
Run
(
ref_argument
);
return
ck
::
utils
::
check_err
(
c
_m_n_device_result
.
mData
,
c
_m_n_host_result
.
mData
)
?
0
:
1
;
return
ck
::
utils
::
check_err
(
e
_m_n_device_result
,
e
_m_n_host_result
)
?
0
:
1
;
}
}
return
0
;
return
0
;
...
...
example/14_gemm_xdl_quantization/CMakeLists.txt
deleted
100644 → 0
View file @
9bd44685
add_example_executable
(
example_gemm_xdl_relu_quantization_int8 gemm_xdl_relu_quantization_int8.cpp
)
\ No newline at end of file
example/15_grouped_gemm/grouped_gemm_xdl_bfp16.cpp
View file @
289f15de
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/literals.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
template
<
ck
::
index_t
...
Is
>
template
<
ck
::
index_t
...
Is
>
...
...
example/15_grouped_gemm/grouped_gemm_xdl_fp16.cpp
View file @
289f15de
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/literals.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
template
<
ck
::
index_t
...
Is
>
template
<
ck
::
index_t
...
Is
>
...
...
example/15_grouped_gemm/grouped_gemm_xdl_fp32.cpp
View file @
289f15de
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/literals.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
template
<
ck
::
index_t
...
Is
>
template
<
ck
::
index_t
...
Is
>
...
...
example/15_grouped_gemm/grouped_gemm_xdl_int4.cpp
View file @
289f15de
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/literals.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
template
<
ck
::
index_t
...
Is
>
template
<
ck
::
index_t
...
Is
>
...
...
example/15_grouped_gemm/grouped_gemm_xdl_int8.cpp
View file @
289f15de
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/literals.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
template
<
ck
::
index_t
...
Is
>
template
<
ck
::
index_t
...
Is
>
...
...
example/15_grouped_gemm/run_grouped_gemm_example.inc
View file @
289f15de
...
@@ -52,15 +52,15 @@ bool run_grouped_gemm(const ProblemSize& problem_size, const ExecutionConfig& co
...
@@ -52,15 +52,15 @@ bool run_grouped_gemm(const ProblemSize& problem_size, const ExecutionConfig& co
auto
f_host_tensor_descriptor
=
auto
f_host_tensor_descriptor
=
[](
std
::
size_t
row
,
std
::
size_t
col
,
std
::
size_t
stride
,
auto
layout
)
{
[](
std
::
size_t
row
,
std
::
size_t
col
,
std
::
size_t
stride
,
auto
layout
)
{
using
namespace
ck
::
literals
;
if
(
std
::
is_same
<
decltype
(
layout
),
ck
::
tensor_layout
::
gemm
::
RowMajor
>::
value
)
if
(
std
::
is_same
<
decltype
(
layout
),
ck
::
tensor_layout
::
gemm
::
RowMajor
>::
value
)
{
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
row
,
col
}),
return
HostTensorDescriptor
({
row
,
col
},
{
stride
,
1_
uz
});
std
::
vector
<
std
::
size_t
>
({
stride
,
1
}));
}
}
else
else
{
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
row
,
col
}),
return
HostTensorDescriptor
({
row
,
col
},
{
1_
uz
,
stride
});
std
::
vector
<
std
::
size_t
>
({
1
,
stride
}));
}
}
};
};
...
@@ -208,10 +208,10 @@ bool run_grouped_gemm(const ProblemSize& problem_size, const ExecutionConfig& co
...
@@ -208,10 +208,10 @@ bool run_grouped_gemm(const ProblemSize& problem_size, const ExecutionConfig& co
#ifdef BUILD_INT4_EXAMPLE
#ifdef BUILD_INT4_EXAMPLE
const
Tensor
<
EDataType
>
c_device_result_converted
(
c_device_tensors
[
i
]);
const
Tensor
<
EDataType
>
c_device_result_converted
(
c_device_tensors
[
i
]);
pass
&=
ck
::
utils
::
check_err
(
c_device_result_converted
.
mData
,
c_host_tensors
[
i
]
.
mData
);
pass
&=
ck
::
utils
::
check_err
(
c_device_result_converted
,
c_host_tensors
[
i
]);
#else
#else
pass
&=
ck
::
utils
::
check_err
(
c_device_tensors
[
i
]
.
mData
,
c_host_tensors
[
i
]
.
mData
);
pass
&=
ck
::
utils
::
check_err
(
c_device_tensors
[
i
],
c_host_tensors
[
i
]);
#endif
#endif
}
}
}
}
...
...
example/16_gemm_multi_d_multi_reduces/gemm_add_add_mean_meansquare_xdl_fp16.cpp
View file @
289f15de
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/device_memory.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
#include "ck/library/utility/literals.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_gemm.hpp"
#include "ck/library/utility/check_err.hpp"
#include "ck/library/utility/check_err.hpp"
...
@@ -109,21 +110,20 @@ void DumpPerf(float ave_time, int M, int N, int K)
...
@@ -109,21 +110,20 @@ void DumpPerf(float ave_time, int M, int N, int K)
}
}
auto
f_host_tensor_descriptor1d
=
[](
std
::
size_t
len
,
std
::
size_t
stride
)
{
auto
f_host_tensor_descriptor1d
=
[](
std
::
size_t
len
,
std
::
size_t
stride
)
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
len
}),
return
HostTensorDescriptor
({
len
},
{
stride
});
std
::
vector
<
std
::
size_t
>
({
stride
}));
};
};
auto
f_host_tensor_descriptor2d
=
auto
f_host_tensor_descriptor2d
=
[](
std
::
size_t
row
,
std
::
size_t
col
,
std
::
size_t
stride
,
auto
layout
)
{
[](
std
::
size_t
row
,
std
::
size_t
col
,
std
::
size_t
stride
,
auto
layout
)
{
using
namespace
ck
::
literals
;
if
(
std
::
is_same
<
decltype
(
layout
),
ck
::
tensor_layout
::
gemm
::
RowMajor
>::
value
)
if
(
std
::
is_same
<
decltype
(
layout
),
ck
::
tensor_layout
::
gemm
::
RowMajor
>::
value
)
{
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
row
,
col
}),
return
HostTensorDescriptor
({
row
,
col
},
{
stride
,
1
_uz
});
std
::
vector
<
std
::
size_t
>
({
stride
,
1
}));
}
}
else
else
{
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
row
,
col
}),
return
HostTensorDescriptor
({
row
,
col
},
{
1
_uz
,
stride
});
std
::
vector
<
std
::
size_t
>
({
1
,
stride
}));
}
}
};
};
...
@@ -259,12 +259,9 @@ int main()
...
@@ -259,12 +259,9 @@ int main()
r0_device_buf
.
FromDevice
(
r0_m
.
mData
.
data
());
r0_device_buf
.
FromDevice
(
r0_m
.
mData
.
data
());
r1_device_buf
.
FromDevice
(
r1_m
.
mData
.
data
());
r1_device_buf
.
FromDevice
(
r1_m
.
mData
.
data
());
pass
=
ck
::
utils
::
check_err
(
pass
=
ck
::
utils
::
check_err
(
e_m_n
,
e_m_n_host
,
"Error: Incorrect results c"
,
1e-2
,
1e-2
);
e_m_n
.
mData
,
e_m_n_host
.
mData
,
"Error: Incorrect results c"
,
1e-2
,
1e-2
);
pass
&=
ck
::
utils
::
check_err
(
r0_m
,
r0_m_host
,
"Error: Incorrect results d0"
,
1e-2
,
1e-2
);
pass
&=
ck
::
utils
::
check_err
(
pass
&=
ck
::
utils
::
check_err
(
r1_m
,
r1_m_host
,
"Error: Incorrect results d1"
,
1e-2
,
1e-2
);
r0_m
.
mData
,
r0_m_host
.
mData
,
"Error: Incorrect results d0"
,
1e-2
,
1e-2
);
pass
&=
ck
::
utils
::
check_err
(
r1_m
.
mData
,
r1_m_host
.
mData
,
"Error: Incorrect results d1"
,
1e-2
,
1e-2
);
}
}
bool
time_kernel
=
true
;
bool
time_kernel
=
true
;
...
...
example/16_gemm_multi_d_multi_reduces/gemm_add_addsquare_xdl_int8.cpp
View file @
289f15de
...
@@ -160,14 +160,12 @@ bool run_gemm_reduce_add_addsquare_xdl(ck::index_t M,
...
@@ -160,14 +160,12 @@ bool run_gemm_reduce_add_addsquare_xdl(ck::index_t M,
{
{
case
0
:
break
;
case
0
:
break
;
case
1
:
case
1
:
ck
::
utils
::
FillUniformDistributionIntegerValue
<
ADataType
>
{
-
5.
f
,
5.
f
}(
a_m_k
.
begin
(),
ck
::
utils
::
FillUniformDistributionIntegerValue
<
ADataType
>
{
-
5.
f
,
5.
f
}(
a_m_k
);
a_m_k
.
end
());
ck
::
utils
::
FillUniformDistributionIntegerValue
<
BDataType
>
{
-
5.
f
,
5.
f
}(
b_k_n
);
ck
::
utils
::
FillUniformDistributionIntegerValue
<
BDataType
>
{
-
5.
f
,
5.
f
}(
b_k_n
.
begin
(),
b_k_n
.
end
());
break
;
break
;
default:
default:
ck
::
utils
::
FillUniformDistribution
<
ADataType
>
{
-
1.
f
,
1.
f
}(
a_m_k
.
begin
(),
a_m_k
.
end
()
);
ck
::
utils
::
FillUniformDistribution
<
ADataType
>
{
-
1.
f
,
1.
f
}(
a_m_k
);
ck
::
utils
::
FillUniformDistribution
<
BDataType
>
{
-
1.
f
,
1.
f
}(
b_k_n
.
begin
(),
b_k_n
.
end
()
);
ck
::
utils
::
FillUniformDistribution
<
BDataType
>
{
-
1.
f
,
1.
f
}(
b_k_n
);
break
;
break
;
}
}
...
@@ -264,15 +262,13 @@ bool run_gemm_reduce_add_addsquare_xdl(ck::index_t M,
...
@@ -264,15 +262,13 @@ bool run_gemm_reduce_add_addsquare_xdl(ck::index_t M,
Tensor
<
EDataType
>
e_m_n_host_converted
(
e_m_n_host
);
Tensor
<
EDataType
>
e_m_n_host_converted
(
e_m_n_host
);
pass
=
ck
::
utils
::
check_err
(
pass
=
ck
::
utils
::
check_err
(
e_m_n
.
mData
,
e_m_n_host_converted
.
mData
,
"Error: Incorrect results c"
,
1e-2
,
1e-2
);
e_m_n
,
e_m_n_host_converted
,
"Error: Incorrect results c"
,
1e-2
,
1e-2
);
r0_device_buf
.
FromDevice
(
r0_m
.
mData
.
data
());
r0_device_buf
.
FromDevice
(
r0_m
.
mData
.
data
());
r1_device_buf
.
FromDevice
(
r1_m
.
mData
.
data
());
r1_device_buf
.
FromDevice
(
r1_m
.
mData
.
data
());
pass
&=
ck
::
utils
::
check_err
(
pass
&=
ck
::
utils
::
check_err
(
r0_m
,
r0_m_host
,
"Error: Incorrect results d0"
,
1e-2
,
1e-2
);
r0_m
.
mData
,
r0_m_host
.
mData
,
"Error: Incorrect results d0"
,
1e-2
,
1e-2
);
pass
&=
ck
::
utils
::
check_err
(
r1_m
,
r1_m_host
,
"Error: Incorrect results d1"
,
1e-2
,
1e-2
);
pass
&=
ck
::
utils
::
check_err
(
r1_m
.
mData
,
r1_m_host
.
mData
,
"Error: Incorrect results d1"
,
1e-2
,
1e-2
);
if
(
pass
)
if
(
pass
)
{
{
...
...
example/16_gemm_multi_d_multi_reduces/gemm_reduce_xdl_common.hpp
View file @
289f15de
...
@@ -134,14 +134,12 @@ auto run_gemm_reduce_max_xdl(ck::index_t M,
...
@@ -134,14 +134,12 @@ auto run_gemm_reduce_max_xdl(ck::index_t M,
{
{
case
0
:
break
;
case
0
:
break
;
case
1
:
case
1
:
ck
::
utils
::
FillUniformDistributionIntegerValue
<
ADataType
>
{
-
5.
f
,
5.
f
}(
a_m_k
.
begin
(),
ck
::
utils
::
FillUniformDistributionIntegerValue
<
ADataType
>
{
-
5.
f
,
5.
f
}(
a_m_k
);
a_m_k
.
end
());
ck
::
utils
::
FillUniformDistributionIntegerValue
<
BDataType
>
{
-
5.
f
,
5.
f
}(
b_k_n
);
ck
::
utils
::
FillUniformDistributionIntegerValue
<
BDataType
>
{
-
5.
f
,
5.
f
}(
b_k_n
.
begin
(),
b_k_n
.
end
());
break
;
break
;
default:
default:
ck
::
utils
::
FillUniformDistribution
<
ADataType
>
{
-
1.
f
,
1.
f
}(
a_m_k
.
begin
(),
a_m_k
.
end
()
);
ck
::
utils
::
FillUniformDistribution
<
ADataType
>
{
-
1.
f
,
1.
f
}(
a_m_k
);
ck
::
utils
::
FillUniformDistribution
<
BDataType
>
{
-
1.
f
,
1.
f
}(
b_k_n
.
begin
(),
b_k_n
.
end
()
);
ck
::
utils
::
FillUniformDistribution
<
BDataType
>
{
-
1.
f
,
1.
f
}(
b_k_n
);
break
;
break
;
}
}
...
@@ -243,8 +241,8 @@ auto run_gemm_reduce_max_xdl(ck::index_t M,
...
@@ -243,8 +241,8 @@ auto run_gemm_reduce_max_xdl(ck::index_t M,
if
constexpr
(
std
::
is_same_v
<
ADataType
,
ck
::
int4_t
>
)
if
constexpr
(
std
::
is_same_v
<
ADataType
,
ck
::
int4_t
>
)
{
{
Tensor
<
EDataType
>
e_m_n_device_converted
(
e_m_n
);
Tensor
<
EDataType
>
e_m_n_device_converted
(
e_m_n
);
pass
=
ck
::
utils
::
check_err
(
e_m_n_device_converted
.
mData
,
pass
=
ck
::
utils
::
check_err
(
e_m_n_device_converted
,
e_m_n_host_converted
.
mData
,
e_m_n_host_converted
,
"Error: Incorrect results c"
,
"Error: Incorrect results c"
,
1e-2
,
1e-2
,
1e-2
);
1e-2
);
...
@@ -253,12 +251,11 @@ auto run_gemm_reduce_max_xdl(ck::index_t M,
...
@@ -253,12 +251,11 @@ auto run_gemm_reduce_max_xdl(ck::index_t M,
#endif // CK_EXPERIMENTAL_BIT_INT_EXTENSION_INT4
#endif // CK_EXPERIMENTAL_BIT_INT_EXTENSION_INT4
{
{
pass
=
ck
::
utils
::
check_err
(
pass
=
ck
::
utils
::
check_err
(
e_m_n
.
mData
,
e_m_n_host_converted
.
mData
,
"Error: Incorrect results c"
,
1e-2
,
1e-2
);
e_m_n
,
e_m_n_host_converted
,
"Error: Incorrect results c"
,
1e-2
,
1e-2
);
}
}
r0_device_buf
.
FromDevice
(
r0_m
.
mData
.
data
());
r0_device_buf
.
FromDevice
(
r0_m
.
mData
.
data
());
pass
&=
ck
::
utils
::
check_err
(
pass
&=
ck
::
utils
::
check_err
(
r0_m
,
r0_m_host
,
"Error: Incorrect results d0"
,
1e-2
,
1e-2
);
r0_m
.
mData
,
r0_m_host
.
mData
,
"Error: Incorrect results d0"
,
1e-2
,
1e-2
);
if
(
pass
)
if
(
pass
)
{
{
...
@@ -339,14 +336,12 @@ bool run_gemm_reduce_mean_meansquare_xdl(ck::index_t M,
...
@@ -339,14 +336,12 @@ bool run_gemm_reduce_mean_meansquare_xdl(ck::index_t M,
{
{
case
0
:
break
;
case
0
:
break
;
case
1
:
case
1
:
ck
::
utils
::
FillUniformDistributionIntegerValue
<
ADataType
>
{
-
5.
f
,
5.
f
}(
a_m_k
.
begin
(),
ck
::
utils
::
FillUniformDistributionIntegerValue
<
ADataType
>
{
-
5.
f
,
5.
f
}(
a_m_k
);
a_m_k
.
end
());
ck
::
utils
::
FillUniformDistributionIntegerValue
<
BDataType
>
{
-
5.
f
,
5.
f
}(
b_k_n
);
ck
::
utils
::
FillUniformDistributionIntegerValue
<
BDataType
>
{
-
5.
f
,
5.
f
}(
b_k_n
.
begin
(),
b_k_n
.
end
());
break
;
break
;
default:
default:
ck
::
utils
::
FillUniformDistribution
<
ADataType
>
{
-
1.
f
,
1.
f
}(
a_m_k
.
begin
(),
a_m_k
.
end
()
);
ck
::
utils
::
FillUniformDistribution
<
ADataType
>
{
-
1.
f
,
1.
f
}(
a_m_k
);
ck
::
utils
::
FillUniformDistribution
<
BDataType
>
{
-
1.
f
,
1.
f
}(
b_k_n
.
begin
(),
b_k_n
.
end
()
);
ck
::
utils
::
FillUniformDistribution
<
BDataType
>
{
-
1.
f
,
1.
f
}(
b_k_n
);
break
;
break
;
}
}
...
@@ -460,8 +455,8 @@ bool run_gemm_reduce_mean_meansquare_xdl(ck::index_t M,
...
@@ -460,8 +455,8 @@ bool run_gemm_reduce_mean_meansquare_xdl(ck::index_t M,
if
constexpr
(
std
::
is_same_v
<
ADataType
,
ck
::
int4_t
>
)
if
constexpr
(
std
::
is_same_v
<
ADataType
,
ck
::
int4_t
>
)
{
{
Tensor
<
EDataType
>
e_m_n_device_converted
(
e_m_n
);
Tensor
<
EDataType
>
e_m_n_device_converted
(
e_m_n
);
pass
=
ck
::
utils
::
check_err
(
e_m_n_device_converted
.
mData
,
pass
=
ck
::
utils
::
check_err
(
e_m_n_device_converted
,
e_m_n_host_converted
.
mData
,
e_m_n_host_converted
,
"Error: Incorrect results c"
,
"Error: Incorrect results c"
,
1e-2
,
1e-2
,
1e-2
);
1e-2
);
...
@@ -470,16 +465,14 @@ bool run_gemm_reduce_mean_meansquare_xdl(ck::index_t M,
...
@@ -470,16 +465,14 @@ bool run_gemm_reduce_mean_meansquare_xdl(ck::index_t M,
#endif // CK_EXPERIMENTAL_BIT_INT_EXTENSION_INT4
#endif // CK_EXPERIMENTAL_BIT_INT_EXTENSION_INT4
{
{
pass
=
ck
::
utils
::
check_err
(
pass
=
ck
::
utils
::
check_err
(
e_m_n
.
mData
,
e_m_n_host_converted
.
mData
,
"Error: Incorrect results c"
,
1e-2
,
1e-2
);
e_m_n
,
e_m_n_host_converted
,
"Error: Incorrect results c"
,
1e-2
,
1e-2
);
}
}
r0_device_buf
.
FromDevice
(
r0_m
.
mData
.
data
());
r0_device_buf
.
FromDevice
(
r0_m
.
mData
.
data
());
r1_device_buf
.
FromDevice
(
r1_m
.
mData
.
data
());
r1_device_buf
.
FromDevice
(
r1_m
.
mData
.
data
());
pass
&=
ck
::
utils
::
check_err
(
pass
&=
ck
::
utils
::
check_err
(
r0_m
,
r0_m_host
,
"Error: Incorrect results d0"
,
1e-2
,
1e-2
);
r0_m
.
mData
,
r0_m_host
.
mData
,
"Error: Incorrect results d0"
,
1e-2
,
1e-2
);
pass
&=
ck
::
utils
::
check_err
(
r1_m
,
r1_m_host
,
"Error: Incorrect results d1"
,
1e-2
,
1e-2
);
pass
&=
ck
::
utils
::
check_err
(
r1_m
.
mData
,
r1_m_host
.
mData
,
"Error: Incorrect results d1"
,
1e-2
,
1e-2
);
if
(
pass
)
if
(
pass
)
{
{
...
...
example/17_convnd_bwd_data/CMakeLists.txt
View file @
289f15de
add_example_executable
(
example_convnd_bwd_data_xdl_fp16 convnd_bwd_data_xdl_fp16.cpp
)
add_example_executable
(
example_convnd_bwd_data_xdl_fp16 convnd_bwd_data_xdl_fp16.cpp
)
target_link_libraries
(
example_convnd_bwd_data_xdl_fp16 PRIVATE utility
)
target_link_libraries
(
example_convnd_bwd_data_xdl_fp16 PRIVATE utility
)
add_example_executable
(
example_convnd_bwd_data_dl_fp16 convnd_bwd_data_dl_fp16.cpp
)
target_link_libraries
(
example_convnd_bwd_data_dl_fp16 PRIVATE utility
)
example/17_convnd_bwd_data/convnd_bwd_data_common.hpp
View file @
289f15de
...
@@ -61,9 +61,13 @@ int run_conv_bwd_data(bool do_verification,
...
@@ -61,9 +61,13 @@ int run_conv_bwd_data(bool do_verification,
out
.
GenerateTensorValue
(
GeneratorTensor_2
<
OutDataType
>
{
-
5
,
5
});
out
.
GenerateTensorValue
(
GeneratorTensor_2
<
OutDataType
>
{
-
5
,
5
});
wei
.
GenerateTensorValue
(
GeneratorTensor_2
<
WeiDataType
>
{
-
5
,
5
});
wei
.
GenerateTensorValue
(
GeneratorTensor_2
<
WeiDataType
>
{
-
5
,
5
});
break
;
break
;
default
:
case
2
:
out
.
GenerateTensorValue
(
GeneratorTensor_3
<
OutDataType
>
{
0.0
,
1.0
});
out
.
GenerateTensorValue
(
GeneratorTensor_3
<
OutDataType
>
{
0.0
,
1.0
});
wei
.
GenerateTensorValue
(
GeneratorTensor_3
<
WeiDataType
>
{
-
0.5
,
0.5
});
wei
.
GenerateTensorValue
(
GeneratorTensor_3
<
WeiDataType
>
{
-
0.5
,
0.5
});
break
;
default:
out
.
GenerateTensorValue
(
GeneratorTensor_1
<
OutDataType
>
{
1
});
wei
.
GenerateTensorValue
(
GeneratorTensor_1
<
WeiDataType
>
{
1
});
}
}
DeviceMem
in_device_buf
(
sizeof
(
InDataType
)
*
in_device
.
mDesc
.
GetElementSpaceSize
());
DeviceMem
in_device_buf
(
sizeof
(
InDataType
)
*
in_device
.
mDesc
.
GetElementSpaceSize
());
...
@@ -98,9 +102,8 @@ int run_conv_bwd_data(bool do_verification,
...
@@ -98,9 +102,8 @@ int run_conv_bwd_data(bool do_verification,
if
(
!
conv
.
IsSupportedArgument
(
argument
))
if
(
!
conv
.
IsSupportedArgument
(
argument
))
{
{
throw
std
::
runtime_error
(
std
::
cout
<<
"Not support,please check parameters or device"
;
"wrong! device_conv with the specified compilation parameters does "
return
0
;
"not support this Conv problem"
);
}
}
float
ave_time
=
invoker
.
Run
(
argument
,
StreamConfig
{
nullptr
,
time_kernel
});
float
ave_time
=
invoker
.
Run
(
argument
,
StreamConfig
{
nullptr
,
time_kernel
});
...
@@ -142,7 +145,7 @@ int run_conv_bwd_data(bool do_verification,
...
@@ -142,7 +145,7 @@ int run_conv_bwd_data(bool do_verification,
in_device_buf
.
FromDevice
(
in_device
.
mData
.
data
());
in_device_buf
.
FromDevice
(
in_device
.
mData
.
data
());
return
ck
::
utils
::
check_err
(
in_device
.
mData
,
in_host
.
mData
)
?
0
:
1
;
return
ck
::
utils
::
check_err
(
in_device
,
in_host
)
?
0
:
1
;
}
}
return
0
;
return
0
;
...
...
example/
20
_convnd_bwd_
weight
/convnd_bwd_
weight_x
dl_fp16.cpp
→
example/
17
_convnd_bwd_
data
/convnd_bwd_
data_
dl_fp16.cpp
View file @
289f15de
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
#include "convnd_bwd_
weight
_common.hpp"
#include "convnd_bwd_
data
_common.hpp"
#include "ck/tensor_operation/gpu/device/impl/device_convnd_bwd_
weight
_nwc_kxc_nwk_
x
dl
_cshuffle
.hpp"
#include "ck/tensor_operation/gpu/device/impl/device_convnd_bwd_
data
_nwc_kxc_nwk_dl.hpp"
using
InDataType
=
ck
::
half_t
;
using
InDataType
=
ck
::
half_t
;
using
WeiDataType
=
ck
::
half_t
;
using
WeiDataType
=
ck
::
half_t
;
...
@@ -17,61 +17,31 @@ using InElementOp = ck::tensor_operation::element_wise::PassThrough;
...
@@ -17,61 +17,31 @@ using InElementOp = ck::tensor_operation::element_wise::PassThrough;
using
WeiElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
WeiElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
OutElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
OutElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
static
constexpr
auto
ConvBwd
Weight
Default
=
static
constexpr
auto
ConvBwdDefault
=
ck
::
tensor_operation
::
device
::
ConvolutionBackward
Weight
Specialization
::
Default
;
ck
::
tensor_operation
::
device
::
ConvolutionBackward
Data
Specialization
::
Default
;
template
<
ck
::
index_t
NDimSpatial
>
template
<
ck
::
index_t
NDimSpatial
>
using
DeviceConvndBwdWeightInstance
=
// clang-format off
ck
::
tensor_operation
::
device
::
DeviceConvNdBwdWeightNwcKxcNwk_Xdl_CShuffle
<
using
DeviceConvNdBwdDataInstance
=
ck
::
tensor_operation
::
device
::
DeviceConvNdBwdDataNwcKxcNwk_Dl
<
NDimSpatial
,
// NDimSpatial
// ######| NDim| InData| WeiData| OutData| AccData| In| Wei| Out| Convolution| Block| MPer| NPer| K0Per| K1| M1Per| N1Per| KPer| M11N11Thread| M11N11Thread| ABlockTransfer| ABlockTransfer| ABlockTransfer| ABlockTransfer| ABlockTransfer| ABlockTransfer| ABlockTransfer| BBlockTransfer| BBlockTransfer| BBlockTransfer| BBlockTransfer| BBlockTransfer| BBlockTransfer| BBlockTransfer| CThreadTransfer| CThreadTransfer| CThreadTransfer|
InDataType
,
// InDataType
// ######| Spatial| Type| Type| Type| Type| Elementwise| Elementwise| Elementwise| Forward| Size| Block| Block| Block| | ThreadM111| ThreadN111| Thread| ClusterM110Xs| ClusterN110Xs| ThreadSliceLengths| ThreadClusterLengths| ThreadCluster| SrcAccess| SrcVectorTensor| SrcVectorTensor| DstVectorTensor| ThreadSliceLengths| ThreadClusterLengths| ThreadCluster| SrcAccess| SrcVectorTensor| SrcVectorTensor| DstVectorTensor| SrcDstAccess| SrcDstVectorDim| DstScalarPerVector|
WeiDataType
,
// WeiDataType
// ######| | | | | | Operation| Operation| Operation| Specialization| | | | | | | | | | | K0_M0_M1_K1| K0_M0_M1_K1| ArrangeOrder| Order| Lengths_K0_M0_M1_K1| ContiguousDimOrder| Lengths_K0_M0_M1_K1| K0_N0_N1_K1| K0_N0_N1_K1| ArrangeOrder| Order| Lengths_K0_N0_N1_K1| ContiguousDimOrder| Lengths_K0_N0_N1_K1| Order| | |
OutDataType
,
// OutDataType
// ######| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
AccDataType
,
// AccDataType
NDimSpatial
,
InDataType
,
WeiDataType
,
OutDataType
,
AccDataType
,
InElementOp
,
WeiElementOp
,
OutElementOp
,
ConvBwdDefault
,
256
,
128
,
128
,
16
,
2
,
4
,
4
,
1
,
S
<
8
,
2
>
,
S
<
8
,
2
>
,
S
<
8
,
1
,
1
,
2
>
,
S
<
2
,
1
,
128
,
1
>
,
S
<
1
,
2
,
0
,
3
>
,
S
<
1
,
2
,
0
,
3
>
,
S
<
4
,
1
,
1
,
2
>
,
S
<
1
,
2
,
0
,
3
>
,
S
<
1
,
1
,
1
,
2
>
,
S
<
1
,
1
,
8
,
2
>
,
S
<
16
,
1
,
16
,
1
>
,
S
<
0
,
3
,
1
,
2
>
,
S
<
0
,
3
,
1
,
2
>
,
S
<
1
,
1
,
8
,
1
>
,
S
<
0
,
3
,
1
,
2
>
,
S
<
1
,
1
,
1
,
2
>
,
S
<
0
,
1
,
2
,
3
,
4
,
5
>
,
5
,
4
>
;
InElementOp
,
// InElementwiseOperation
// clang-format on
WeiElementOp
,
// WeiElementwiseOperation
OutElementOp
,
// OutElementwiseOperation
ConvBwdWeightDefault
,
// ConvolutionBackwardWeightSpecialization
256
,
// BlockSize
128
,
// MPerBlock
128
,
// NPerBlock
4
,
// K0PerBlock
8
,
// K1
32
,
// MPerXdl
32
,
// NPerXdl
2
,
// MXdlPerWave
2
,
// NXdlPerWave
S
<
1
,
4
,
16
,
4
>
,
// ABlockTransferThreadClusterLengths_K0_M_K1
S
<
0
,
3
,
1
,
2
>
,
// ABlockTransferThreadClusterArrangeOrder
S
<
0
,
2
,
1
,
3
>
,
// ABlockTransferSrcAccessOrder
2
,
// ABlockTransferSrcVectorDim
8
,
// ABlockTransferSrcScalarPerVector
2
,
// ABlockTransferDstScalarPerVector_K1
true
,
// ABlockLdsAddExtraM
S
<
1
,
4
,
16
,
4
>
,
// BBlockTransferThreadClusterLengths_K0_N_K1
S
<
0
,
3
,
1
,
2
>
,
// BBlockTransferThreadClusterArrangeOrder
S
<
0
,
2
,
1
,
3
>
,
// BBlockTransferSrcAccessOrder
2
,
// BBlockTransferSrcVectorDim
8
,
// BBlockTransferSrcScalarPerVector
2
,
// BBlockTransferDstScalarPerVector_K1
true
,
// BBlockLdsAddExtraN
1
,
// CShuffleMXdlPerWavePerShuffle
1
,
// CShuffleNXdlPerWavePerShuffle
S
<
1
,
32
,
1
,
4
>
,
// CBlockTransferClusterLengths_MBlock_MPerBlock_NBlock_NPerBlock
8
>
;
// CBlockTransferScalarPerVector_NWaveNPerXdl
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
namespace
ctc
=
ck
::
tensor_layout
::
convolution
;
namespace
ctc
=
ck
::
tensor_layout
::
convolution
;
print_helper_msg
();
bool
do_verification
=
true
;
bool
do_verification
=
true
;
int
init_method
=
1
;
int
init_method
=
1
;
bool
time_kernel
=
false
;
bool
time_kernel
=
false
;
ck
::
utils
::
conv
::
ConvParam
conv_param
{
ck
::
utils
::
conv
::
ConvParam
conv_param
{
2
,
1
,
32
,
256
,
1024
,
{
3
,
3
},
{
14
,
14
},
{
2
,
2
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}};
2
,
1
,
128
,
256
,
256
,
{
3
,
3
},
{
71
,
71
},
{
2
,
2
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}};
ck
::
index_t
split_k
=
4
;
if
(
argc
==
1
)
if
(
argc
==
1
)
{
{
...
@@ -91,9 +61,6 @@ int main(int argc, char* argv[])
...
@@ -91,9 +61,6 @@ int main(int argc, char* argv[])
const
ck
::
index_t
num_dim_spatial
=
std
::
stoi
(
argv
[
4
]);
const
ck
::
index_t
num_dim_spatial
=
std
::
stoi
(
argv
[
4
]);
conv_param
=
ck
::
utils
::
conv
::
parse_conv_param
(
num_dim_spatial
,
5
,
argv
);
conv_param
=
ck
::
utils
::
conv
::
parse_conv_param
(
num_dim_spatial
,
5
,
argv
);
split_k
=
std
::
stoi
(
argv
[
5
+
3
+
6
*
num_dim_spatial
-
1
]);
split_k
=
std
::
max
(
1
,
split_k
);
}
}
const
auto
in_element_op
=
InElementOp
{};
const
auto
in_element_op
=
InElementOp
{};
...
@@ -118,14 +85,14 @@ int main(int argc, char* argv[])
...
@@ -118,14 +85,14 @@ int main(int argc, char* argv[])
ck
::
utils
::
conv
::
make_output_host_tensor_descriptor_g_n_k_wos_packed
<
OutLayout
>
(
ck
::
utils
::
conv
::
make_output_host_tensor_descriptor_g_n_k_wos_packed
<
OutLayout
>
(
conv_param
);
conv_param
);
return
run_conv_bwd_
weight
<
1
,
return
run_conv_bwd_
data
<
1
,
InDataType
,
InDataType
,
WeiDataType
,
WeiDataType
,
OutDataType
,
OutDataType
,
InElementOp
,
InElementOp
,
WeiElementOp
,
WeiElementOp
,
OutElementOp
,
OutElementOp
,
DeviceConv
n
dBwd
Weight
Instance
<
1
>>
(
do_verification
,
DeviceConv
N
dBwd
Data
Instance
<
1
>>
(
do_verification
,
init_method
,
init_method
,
time_kernel
,
time_kernel
,
conv_param
,
conv_param
,
...
@@ -134,8 +101,7 @@ int main(int argc, char* argv[])
...
@@ -134,8 +101,7 @@ int main(int argc, char* argv[])
out_g_n_k_wos_desc
,
out_g_n_k_wos_desc
,
in_element_op
,
in_element_op
,
wei_element_op
,
wei_element_op
,
out_element_op
,
out_element_op
);
split_k
);
}
}
else
if
(
conv_param
.
num_dim_spatial_
==
2
)
else
if
(
conv_param
.
num_dim_spatial_
==
2
)
{
{
...
@@ -155,14 +121,14 @@ int main(int argc, char* argv[])
...
@@ -155,14 +121,14 @@ int main(int argc, char* argv[])
ck
::
utils
::
conv
::
make_output_host_tensor_descriptor_g_n_k_wos_packed
<
OutLayout
>
(
ck
::
utils
::
conv
::
make_output_host_tensor_descriptor_g_n_k_wos_packed
<
OutLayout
>
(
conv_param
);
conv_param
);
return
run_conv_bwd_
weight
<
2
,
return
run_conv_bwd_
data
<
2
,
InDataType
,
InDataType
,
WeiDataType
,
WeiDataType
,
OutDataType
,
OutDataType
,
InElementOp
,
InElementOp
,
WeiElementOp
,
WeiElementOp
,
OutElementOp
,
OutElementOp
,
DeviceConv
n
dBwd
Weight
Instance
<
2
>>
(
do_verification
,
DeviceConv
N
dBwd
Data
Instance
<
2
>>
(
do_verification
,
init_method
,
init_method
,
time_kernel
,
time_kernel
,
conv_param
,
conv_param
,
...
@@ -171,8 +137,7 @@ int main(int argc, char* argv[])
...
@@ -171,8 +137,7 @@ int main(int argc, char* argv[])
out_g_n_k_wos_desc
,
out_g_n_k_wos_desc
,
in_element_op
,
in_element_op
,
wei_element_op
,
wei_element_op
,
out_element_op
,
out_element_op
);
split_k
);
}
}
else
if
(
conv_param
.
num_dim_spatial_
==
3
)
else
if
(
conv_param
.
num_dim_spatial_
==
3
)
{
{
...
@@ -192,14 +157,14 @@ int main(int argc, char* argv[])
...
@@ -192,14 +157,14 @@ int main(int argc, char* argv[])
ck
::
utils
::
conv
::
make_output_host_tensor_descriptor_g_n_k_wos_packed
<
OutLayout
>
(
ck
::
utils
::
conv
::
make_output_host_tensor_descriptor_g_n_k_wos_packed
<
OutLayout
>
(
conv_param
);
conv_param
);
return
run_conv_bwd_
weight
<
3
,
return
run_conv_bwd_
data
<
3
,
InDataType
,
InDataType
,
WeiDataType
,
WeiDataType
,
OutDataType
,
OutDataType
,
InElementOp
,
InElementOp
,
WeiElementOp
,
WeiElementOp
,
OutElementOp
,
OutElementOp
,
DeviceConv
n
dBwd
Weight
Instance
<
3
>>
(
do_verification
,
DeviceConv
N
dBwd
Data
Instance
<
3
>>
(
do_verification
,
init_method
,
init_method
,
time_kernel
,
time_kernel
,
conv_param
,
conv_param
,
...
@@ -208,8 +173,7 @@ int main(int argc, char* argv[])
...
@@ -208,8 +173,7 @@ int main(int argc, char* argv[])
out_g_n_k_wos_desc
,
out_g_n_k_wos_desc
,
in_element_op
,
in_element_op
,
wei_element_op
,
wei_element_op
,
out_element_op
,
out_element_op
);
split_k
);
}
}
return
0
;
return
0
;
...
...
Prev
1
2
3
4
5
6
7
…
19
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