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
4698993d
Unverified
Commit
4698993d
authored
Nov 15, 2022
by
Po Yen Chen
Committed by
GitHub
Nov 15, 2022
Browse files
Merge branch 'develop' into wmma_op
parents
ab663329
7038723a
Changes
202
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
114 additions
and
129 deletions
+114
-129
example/10_convnd_fwd_multiple_d_multiple_reduce/run_convnd_fwd_max_example.inc
...multiple_d_multiple_reduce/run_convnd_fwd_max_example.inc
+12
-18
example/12_reduce/reduce_blockwise.cpp
example/12_reduce/reduce_blockwise.cpp
+1
-1
example/12_reduce/reduce_blockwise_impl.hpp
example/12_reduce/reduce_blockwise_impl.hpp
+7
-6
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_xdl_quantization/gemm_xdl_relu_quantization_int8.cpp
...gemm_xdl_quantization/gemm_xdl_relu_quantization_int8.cpp
+6
-5
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/convnd_bwd_data_common.hpp
example/17_convnd_bwd_data/convnd_bwd_data_common.hpp
+1
-1
example/18_batched_gemm_reduce/batched_gemm_reduce_xdl_fp16.cpp
...e/18_batched_gemm_reduce/batched_gemm_reduce_xdl_fp16.cpp
+15
-19
example/19_binary_elementwise/broadcast_add_2d_amn_bn.cpp
example/19_binary_elementwise/broadcast_add_2d_amn_bn.cpp
+6
-6
No files found.
example/10_convnd_fwd_multiple_d_multiple_reduce/run_convnd_fwd_max_example.inc
View file @
4698993d
...
...
@@ -77,15 +77,12 @@ bool run_convnd_fwd_max(const ck::utils::conv::ConvParam& problem_size,
{
case
0
:
break
;
case
1
:
ck
::
utils
::
FillUniformDistributionIntegerValue
<
ADataType
>
{
-
8
,
7
}(
conv_input
.
begin
(),
conv_input
.
end
());
ck
::
utils
::
FillUniformDistributionIntegerValue
<
BDataType
>
{
-
8
,
7
}(
conv_weight
.
begin
(),
conv_weight
.
end
());
ck
::
utils
::
FillUniformDistributionIntegerValue
<
ADataType
>
{
-
8
,
7
}(
conv_input
);
ck
::
utils
::
FillUniformDistributionIntegerValue
<
BDataType
>
{
-
8
,
7
}(
conv_weight
);
break
;
default
:
ck
::
utils
::
FillUniformDistribution
<
ADataType
>
{
-
5
,
5
}(
conv_input
.
begin
(),
conv_input
.
end
());
ck
::
utils
::
FillUniformDistribution
<
BDataType
>
{
-
5
,
5
}(
conv_weight
.
begin
(),
conv_weight
.
end
());
ck
::
utils
::
FillUniformDistribution
<
ADataType
>
{
-
5
,
5
}(
conv_input
);
ck
::
utils
::
FillUniformDistribution
<
BDataType
>
{
-
5
,
5
}(
conv_weight
);
}
DeviceMem
conv_input_device_buf
(
sizeof
(
ADataType
)
*
conv_input
.
mDesc
.
GetElementSpaceSize
());
...
...
@@ -123,10 +120,10 @@ bool run_convnd_fwd_max(const ck::utils::conv::ConvParam& problem_size,
conv_output_g_n_k_wos_desc
,
conv_output_g_n_k_wos_lengths
,
conv_output_g_n_k_wos_strides
);
unpack_host_tensor_descriptor
(
r0_desc
,
r0_lengths
,
r0_strides
);
copy
(
problem_size
.
conv_filter_strides_
,
begin
(
conv_filter_strides
));
copy
(
problem_size
.
conv_filter_dilations_
,
begin
(
conv_filter_dilations
));
copy
(
problem_size
.
input_left_pads_
,
begin
(
input_left_pads
));
copy
(
problem_size
.
input_right_pads_
,
begin
(
input_right_pads
));
ck
::
ranges
::
copy
(
problem_size
.
conv_filter_strides_
,
begin
(
conv_filter_strides
));
ck
::
ranges
::
copy
(
problem_size
.
conv_filter_dilations_
,
begin
(
conv_filter_dilations
));
ck
::
ranges
::
copy
(
problem_size
.
input_left_pads_
,
begin
(
input_left_pads
));
ck
::
ranges
::
copy
(
problem_size
.
input_right_pads_
,
begin
(
input_right_pads
));
// run Conv + Reduction on device
auto
conv
=
DeviceInstance
<
NDimSpatial
>
{};
...
...
@@ -276,16 +273,13 @@ bool run_convnd_fwd_max(const ck::utils::conv::ConvParam& problem_size,
conv_output_device_buf
.
FromDevice
(
conv_output_device
.
mData
.
data
());
r0_device_buf
.
FromDevice
(
r0_device
.
mData
.
data
());
return
ck
::
utils
::
check_err
(
conv_output_device
.
mData
,
conv_output_host
.
mData
,
return
ck
::
utils
::
check_err
(
conv_output_device
,
conv_output_host
,
"Error: incorrect results! (Matrix E)"
,
1
e
-
5
f
,
1
e
-
4
f
)
&&
ck
::
utils
::
check_err
(
r0_device
.
mData
,
r0_host
.
mData
,
"Error: incorrect results! (Matrix R0)"
,
1
e
-
5
f
,
1
e
-
4
f
);
ck
::
utils
::
check_err
(
r0_device
,
r0_host
,
"Error: incorrect results! (Matrix R0)"
,
1
e
-
5
f
,
1
e
-
4
f
);
}
return
true
;
...
...
example/12_reduce/reduce_blockwise.cpp
View file @
4698993d
...
...
@@ -142,7 +142,7 @@ bool reduce_blockwise_test(bool do_verification,
std
::
array
<
int
,
ShapeType
::
NumReduceDim_
>
arrReduceDims
;
std
::
copy
(
reduceDims
.
begin
(),
reduceDims
.
end
()
,
arrReduceDims
.
begin
());
ck
::
ranges
::
copy
(
reduceDims
,
arrReduceDims
.
begin
());
result
=
reduce_blockwise_impl
<
InOutDataType
,
AccDataType
,
...
...
example/12_reduce/reduce_blockwise_impl.hpp
View file @
4698993d
...
...
@@ -10,6 +10,7 @@
#include "ck/tensor_operation/gpu/device/reduction_operator_mapping.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/device_memory.hpp"
#include "ck/library/utility/host_tensor.hpp"
...
...
@@ -263,10 +264,10 @@ int reduce_blockwise_impl(bool do_verification,
std
::
array
<
index_t
,
NumOutDim
>
arrOutLengths
;
std
::
array
<
index_t
,
NumOutDim
>
arrOutStrides
;
std
::
copy
(
inLengths
.
begin
(),
inLengths
.
end
()
,
arrInLengths
.
begin
());
std
::
copy
(
inStrides
.
begin
(),
inStrides
.
end
()
,
arrInStrides
.
begin
());
std
::
copy
(
outLengths
.
begin
(),
outLengths
.
end
()
,
arrOutLengths
.
begin
());
std
::
copy
(
outStrides
.
begin
(),
outStrides
.
end
()
,
arrOutStrides
.
begin
());
ck
::
ranges
::
copy
(
inLengths
,
arrInLengths
.
begin
());
ck
::
ranges
::
copy
(
inStrides
,
arrInStrides
.
begin
());
ck
::
ranges
::
copy
(
outLengths
,
arrOutLengths
.
begin
());
ck
::
ranges
::
copy
(
outStrides
,
arrOutStrides
.
begin
());
auto
reduce
=
DeviceReduceInstance
{};
...
...
@@ -324,12 +325,12 @@ int reduce_blockwise_impl(bool do_verification,
#endif
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
);
if
(
OutputIndex
)
{
out_index_dev
.
FromDevice
(
out_indices
.
mData
.
data
());
pass
=
pass
&&
ck
::
utils
::
check_err
(
out_indices
.
mData
,
out_indices_ref
.
mData
);
pass
=
pass
&&
ck
::
utils
::
check_err
(
out_indices
,
out_indices_ref
);
};
};
...
...
example/12_reduce/reduce_blockwise_two_call.cpp
View file @
4698993d
...
...
@@ -221,12 +221,12 @@ int main(int argc, char* argv[])
std
::
array
<
index_t
,
3
>
arrOutLengths
;
std
::
array
<
index_t
,
3
>
arrOutStrides
;
std
::
copy
(
inLengths_1
.
begin
(),
inLengths_1
.
end
()
,
arrInLengths_1
.
begin
());
std
::
copy
(
inStrides_1
.
begin
(),
inStrides_1
.
end
()
,
arrInStrides_1
.
begin
());
std
::
copy
(
inLengths_2
.
begin
(),
inLengths_2
.
end
()
,
arrInLengths_2
.
begin
());
std
::
copy
(
inStrides_2
.
begin
(),
inStrides_2
.
end
()
,
arrInStrides_2
.
begin
());
std
::
copy
(
outLengths
.
begin
(),
outLengths
.
end
()
,
arrOutLengths
.
begin
());
std
::
copy
(
outStrides
.
begin
(),
outStrides
.
end
()
,
arrOutStrides
.
begin
());
ck
::
ranges
::
copy
(
inLengths_1
,
arrInLengths_1
.
begin
());
ck
::
ranges
::
copy
(
inStrides_1
,
arrInStrides_1
.
begin
());
ck
::
ranges
::
copy
(
inLengths_2
,
arrInLengths_2
.
begin
());
ck
::
ranges
::
copy
(
inStrides_2
,
arrInStrides_2
.
begin
());
ck
::
ranges
::
copy
(
outLengths
,
arrOutLengths
.
begin
());
ck
::
ranges
::
copy
(
outStrides
,
arrOutStrides
.
begin
());
auto
reduce_1
=
DeviceReduceInstance_1
{};
...
...
@@ -294,7 +294,7 @@ int main(int argc, char* argv[])
if
(
do_verify
)
{
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
);
...
...
example/12_reduce/reduce_multiblock_atomic_add.cpp
View file @
4698993d
...
...
@@ -140,7 +140,7 @@ bool reduce_multiblock_atomic_add_test(bool do_verification,
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
,
AccDataType
,
...
...
example/12_reduce/reduce_multiblock_atomic_add_impl.hpp
View file @
4698993d
...
...
@@ -10,6 +10,7 @@
#include "ck/tensor_operation/gpu/device/reduction_operator_mapping.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/device_memory.hpp"
#include "ck/library/utility/host_tensor.hpp"
...
...
@@ -176,10 +177,10 @@ int reduce_multiblock_atomic_add_impl(bool do_verification,
std
::
array
<
index_t
,
NumOutDim
>
arrOutLengths
;
std
::
array
<
index_t
,
NumOutDim
>
arrOutStrides
;
std
::
copy
(
inLengths
.
begin
(),
inLengths
.
end
()
,
arrInLengths
.
begin
());
std
::
copy
(
inStrides
.
begin
(),
inStrides
.
end
()
,
arrInStrides
.
begin
());
std
::
copy
(
outLengths
.
begin
(),
outLengths
.
end
()
,
arrOutLengths
.
begin
());
std
::
copy
(
outStrides
.
begin
(),
outStrides
.
end
()
,
arrOutStrides
.
begin
());
ck
::
ranges
::
copy
(
inLengths
,
arrInLengths
.
begin
());
ck
::
ranges
::
copy
(
inStrides
,
arrInStrides
.
begin
());
ck
::
ranges
::
copy
(
outLengths
,
arrOutLengths
.
begin
());
ck
::
ranges
::
copy
(
outStrides
,
arrOutStrides
.
begin
());
auto
reduce
=
DeviceReduceInstance
{};
...
...
@@ -225,7 +226,7 @@ int reduce_multiblock_atomic_add_impl(bool do_verification,
if
(
do_verification
)
{
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
);
...
...
example/13_pool2d_fwd/pool2d_fwd_common.hpp
View file @
4698993d
...
...
@@ -16,6 +16,7 @@
#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"
template
<
typename
InDataType
,
typename
OutDataType
,
...
...
@@ -172,16 +173,16 @@ bool pool_test(bool do_verification,
// tensor layout
auto
f_host_tensor_descriptor
=
[](
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
)
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
N_
,
C_
,
H
,
W
}),
std
::
vector
<
std
::
size_t
>
({
C_
*
H
*
W
,
H
*
W
,
W
,
1
}));
return
HostTensorDescriptor
({
N_
,
C_
,
H
,
W
},
{
C_
*
H
*
W
,
H
*
W
,
W
,
1
_uz
});
}
else
if
constexpr
(
ck
::
is_same
<
decltype
(
layout
),
ck
::
tensor_layout
::
convolution
::
NHWC
>::
value
)
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
N_
,
C_
,
H
,
W
}),
std
::
vector
<
std
::
size_t
>
({
C_
*
H
*
W
,
1
,
W
*
C_
,
C_
}));
return
HostTensorDescriptor
({
N_
,
C_
,
H
,
W
},
{
C_
*
H
*
W
,
1
_uz
,
W
*
C_
,
C_
});
}
};
...
...
@@ -267,14 +268,14 @@ bool pool_test(bool do_verification,
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
)
{
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
,
out_indices_n_c_ho_wo_host
.
mData
);
pass
=
pass
&&
ck
::
utils
::
check_err
(
out_indices_n_c_ho_wo_device
,
out_indices_n_c_ho_wo_host
);
};
}
...
...
example/14_gemm_xdl_quantization/gemm_xdl_relu_quantization_int8.cpp
View file @
4698993d
...
...
@@ -15,6 +15,7 @@
#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"
...
...
@@ -133,15 +134,15 @@ int main(int argc, char* argv[])
auto
f_host_tensor_descriptor
=
[](
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
}));
return
HostTensorDescriptor
({
row
,
col
},
{
stride
,
1
_uz
});
}
else
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
row
,
col
}),
std
::
vector
<
std
::
size_t
>
({
1
,
stride
}));
return
HostTensorDescriptor
({
row
,
col
},
{
1
_uz
,
stride
});
}
};
...
...
@@ -225,7 +226,7 @@ int main(int argc, char* argv[])
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
(
c_m_n_device_result
,
c_m_n_host_result
)
?
0
:
1
;
}
return
0
;
...
...
example/15_grouped_gemm/grouped_gemm_xdl_bfp16.cpp
View file @
4698993d
...
...
@@ -16,6 +16,7 @@
#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"
template
<
ck
::
index_t
...
Is
>
...
...
example/15_grouped_gemm/grouped_gemm_xdl_fp16.cpp
View file @
4698993d
...
...
@@ -16,6 +16,7 @@
#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"
template
<
ck
::
index_t
...
Is
>
...
...
example/15_grouped_gemm/grouped_gemm_xdl_fp32.cpp
View file @
4698993d
...
...
@@ -16,6 +16,7 @@
#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"
template
<
ck
::
index_t
...
Is
>
...
...
example/15_grouped_gemm/grouped_gemm_xdl_int4.cpp
View file @
4698993d
...
...
@@ -16,6 +16,7 @@
#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"
template
<
ck
::
index_t
...
Is
>
...
...
example/15_grouped_gemm/grouped_gemm_xdl_int8.cpp
View file @
4698993d
...
...
@@ -16,6 +16,7 @@
#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"
template
<
ck
::
index_t
...
Is
>
...
...
example/15_grouped_gemm/run_grouped_gemm_example.inc
View file @
4698993d
...
...
@@ -52,15 +52,15 @@ bool run_grouped_gemm(const ProblemSize& problem_size, const ExecutionConfig& co
auto
f_host_tensor_descriptor
=
[](
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
}));
return
HostTensorDescriptor
({
row
,
col
},
{
stride
,
1_
uz
});
}
else
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
row
,
col
}),
std
::
vector
<
std
::
size_t
>
({
1
,
stride
}));
return
HostTensorDescriptor
({
row
,
col
},
{
1_
uz
,
stride
});
}
};
...
...
@@ -208,10 +208,10 @@ bool run_grouped_gemm(const ProblemSize& problem_size, const ExecutionConfig& co
#ifdef BUILD_INT4_EXAMPLE
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
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
}
}
...
...
example/16_gemm_multi_d_multi_reduces/gemm_add_add_mean_meansquare_xdl_fp16.cpp
View file @
4698993d
...
...
@@ -15,6 +15,7 @@
#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"
...
...
@@ -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
)
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
len
}),
std
::
vector
<
std
::
size_t
>
({
stride
}));
return
HostTensorDescriptor
({
len
},
{
stride
});
};
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
}));
return
HostTensorDescriptor
({
row
,
col
},
{
stride
,
1
_uz
});
}
else
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
row
,
col
}),
std
::
vector
<
std
::
size_t
>
({
1
,
stride
}));
return
HostTensorDescriptor
({
row
,
col
},
{
1
_uz
,
stride
});
}
};
...
...
@@ -259,12 +259,9 @@ int main()
r0_device_buf
.
FromDevice
(
r0_m
.
mData
.
data
());
r1_device_buf
.
FromDevice
(
r1_m
.
mData
.
data
());
pass
=
ck
::
utils
::
check_err
(
e_m_n
.
mData
,
e_m_n_host
.
mData
,
"Error: Incorrect results c"
,
1e-2
,
1e-2
);
pass
&=
ck
::
utils
::
check_err
(
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
);
pass
=
ck
::
utils
::
check_err
(
e_m_n
,
e_m_n_host
,
"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
(
r1_m
,
r1_m_host
,
"Error: Incorrect results d1"
,
1e-2
,
1e-2
);
}
bool
time_kernel
=
true
;
...
...
example/16_gemm_multi_d_multi_reduces/gemm_add_addsquare_xdl_int8.cpp
View file @
4698993d
...
...
@@ -160,14 +160,12 @@ bool run_gemm_reduce_add_addsquare_xdl(ck::index_t M,
{
case
0
:
break
;
case
1
:
ck
::
utils
::
FillUniformDistributionIntegerValue
<
ADataType
>
{
-
5.
f
,
5.
f
}(
a_m_k
.
begin
(),
a_m_k
.
end
());
ck
::
utils
::
FillUniformDistributionIntegerValue
<
BDataType
>
{
-
5.
f
,
5.
f
}(
b_k_n
.
begin
(),
b_k_n
.
end
());
ck
::
utils
::
FillUniformDistributionIntegerValue
<
ADataType
>
{
-
5.
f
,
5.
f
}(
a_m_k
);
ck
::
utils
::
FillUniformDistributionIntegerValue
<
BDataType
>
{
-
5.
f
,
5.
f
}(
b_k_n
);
break
;
default:
ck
::
utils
::
FillUniformDistribution
<
ADataType
>
{
-
1.
f
,
1.
f
}(
a_m_k
.
begin
(),
a_m_k
.
end
()
);
ck
::
utils
::
FillUniformDistribution
<
BDataType
>
{
-
1.
f
,
1.
f
}(
b_k_n
.
begin
(),
b_k_n
.
end
()
);
ck
::
utils
::
FillUniformDistribution
<
ADataType
>
{
-
1.
f
,
1.
f
}(
a_m_k
);
ck
::
utils
::
FillUniformDistribution
<
BDataType
>
{
-
1.
f
,
1.
f
}(
b_k_n
);
break
;
}
...
...
@@ -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
);
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
());
r1_device_buf
.
FromDevice
(
r1_m
.
mData
.
data
());
pass
&=
ck
::
utils
::
check_err
(
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
);
pass
&=
ck
::
utils
::
check_err
(
r0_m
,
r0_m_host
,
"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
);
if
(
pass
)
{
...
...
example/16_gemm_multi_d_multi_reduces/gemm_reduce_xdl_common.hpp
View file @
4698993d
...
...
@@ -134,14 +134,12 @@ auto run_gemm_reduce_max_xdl(ck::index_t M,
{
case
0
:
break
;
case
1
:
ck
::
utils
::
FillUniformDistributionIntegerValue
<
ADataType
>
{
-
5.
f
,
5.
f
}(
a_m_k
.
begin
(),
a_m_k
.
end
());
ck
::
utils
::
FillUniformDistributionIntegerValue
<
BDataType
>
{
-
5.
f
,
5.
f
}(
b_k_n
.
begin
(),
b_k_n
.
end
());
ck
::
utils
::
FillUniformDistributionIntegerValue
<
ADataType
>
{
-
5.
f
,
5.
f
}(
a_m_k
);
ck
::
utils
::
FillUniformDistributionIntegerValue
<
BDataType
>
{
-
5.
f
,
5.
f
}(
b_k_n
);
break
;
default:
ck
::
utils
::
FillUniformDistribution
<
ADataType
>
{
-
1.
f
,
1.
f
}(
a_m_k
.
begin
(),
a_m_k
.
end
()
);
ck
::
utils
::
FillUniformDistribution
<
BDataType
>
{
-
1.
f
,
1.
f
}(
b_k_n
.
begin
(),
b_k_n
.
end
()
);
ck
::
utils
::
FillUniformDistribution
<
ADataType
>
{
-
1.
f
,
1.
f
}(
a_m_k
);
ck
::
utils
::
FillUniformDistribution
<
BDataType
>
{
-
1.
f
,
1.
f
}(
b_k_n
);
break
;
}
...
...
@@ -243,8 +241,8 @@ auto run_gemm_reduce_max_xdl(ck::index_t M,
if
constexpr
(
std
::
is_same_v
<
ADataType
,
ck
::
int4_t
>
)
{
Tensor
<
EDataType
>
e_m_n_device_converted
(
e_m_n
);
pass
=
ck
::
utils
::
check_err
(
e_m_n_device_converted
.
mData
,
e_m_n_host_converted
.
mData
,
pass
=
ck
::
utils
::
check_err
(
e_m_n_device_converted
,
e_m_n_host_converted
,
"Error: Incorrect results c"
,
1e-2
,
1e-2
);
...
...
@@ -253,12 +251,11 @@ auto run_gemm_reduce_max_xdl(ck::index_t M,
#endif // CK_EXPERIMENTAL_BIT_INT_EXTENSION_INT4
{
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
());
pass
&=
ck
::
utils
::
check_err
(
r0_m
.
mData
,
r0_m_host
.
mData
,
"Error: Incorrect results d0"
,
1e-2
,
1e-2
);
pass
&=
ck
::
utils
::
check_err
(
r0_m
,
r0_m_host
,
"Error: Incorrect results d0"
,
1e-2
,
1e-2
);
if
(
pass
)
{
...
...
@@ -339,14 +336,12 @@ bool run_gemm_reduce_mean_meansquare_xdl(ck::index_t M,
{
case
0
:
break
;
case
1
:
ck
::
utils
::
FillUniformDistributionIntegerValue
<
ADataType
>
{
-
5.
f
,
5.
f
}(
a_m_k
.
begin
(),
a_m_k
.
end
());
ck
::
utils
::
FillUniformDistributionIntegerValue
<
BDataType
>
{
-
5.
f
,
5.
f
}(
b_k_n
.
begin
(),
b_k_n
.
end
());
ck
::
utils
::
FillUniformDistributionIntegerValue
<
ADataType
>
{
-
5.
f
,
5.
f
}(
a_m_k
);
ck
::
utils
::
FillUniformDistributionIntegerValue
<
BDataType
>
{
-
5.
f
,
5.
f
}(
b_k_n
);
break
;
default:
ck
::
utils
::
FillUniformDistribution
<
ADataType
>
{
-
1.
f
,
1.
f
}(
a_m_k
.
begin
(),
a_m_k
.
end
()
);
ck
::
utils
::
FillUniformDistribution
<
BDataType
>
{
-
1.
f
,
1.
f
}(
b_k_n
.
begin
(),
b_k_n
.
end
()
);
ck
::
utils
::
FillUniformDistribution
<
ADataType
>
{
-
1.
f
,
1.
f
}(
a_m_k
);
ck
::
utils
::
FillUniformDistribution
<
BDataType
>
{
-
1.
f
,
1.
f
}(
b_k_n
);
break
;
}
...
...
@@ -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
>
)
{
Tensor
<
EDataType
>
e_m_n_device_converted
(
e_m_n
);
pass
=
ck
::
utils
::
check_err
(
e_m_n_device_converted
.
mData
,
e_m_n_host_converted
.
mData
,
pass
=
ck
::
utils
::
check_err
(
e_m_n_device_converted
,
e_m_n_host_converted
,
"Error: Incorrect results c"
,
1e-2
,
1e-2
);
...
...
@@ -470,16 +465,14 @@ bool run_gemm_reduce_mean_meansquare_xdl(ck::index_t M,
#endif // CK_EXPERIMENTAL_BIT_INT_EXTENSION_INT4
{
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
());
r1_device_buf
.
FromDevice
(
r1_m
.
mData
.
data
());
pass
&=
ck
::
utils
::
check_err
(
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
);
pass
&=
ck
::
utils
::
check_err
(
r0_m
,
r0_m_host
,
"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
);
if
(
pass
)
{
...
...
example/17_convnd_bwd_data/convnd_bwd_data_common.hpp
View file @
4698993d
...
...
@@ -142,7 +142,7 @@ int run_conv_bwd_data(bool do_verification,
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
;
...
...
example/18_batched_gemm_reduce/batched_gemm_reduce_xdl_fp16.cpp
View file @
4698993d
...
...
@@ -16,6 +16,7 @@
#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_batched_gemm.hpp"
template
<
ck
::
index_t
...
Is
>
...
...
@@ -132,15 +133,15 @@ int main(int argc, char* argv[])
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
>
({
batch_count
,
row
,
col
}),
std
::
vector
<
std
::
size_t
>
({
row
*
stride
,
stride
,
1
}));
return
HostTensorDescriptor
({
batch_count
,
row
,
col
},
{
row
*
stride
,
stride
,
1
_uz
});
}
else
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
batch_count
,
row
,
col
}),
std
::
vector
<
std
::
size_t
>
({
col
*
stride
,
1
,
stride
}));
return
HostTensorDescriptor
({
batch_count
,
row
,
col
},
{
col
*
stride
,
1
_uz
,
stride
});
}
};
...
...
@@ -149,17 +150,13 @@ int main(int argc, char* argv[])
Tensor
<
CDataType
>
c_g_m_n_host_result
(
f_host_tensor_descriptor
(
BatchCount
,
M
,
N
,
StrideC
,
CLayout
{}));
Tensor
<
ReduceDataType
>
d0_g_m_host_result
(
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
(
{
static_cast
<
std
::
size_t
>
(
BatchCount
),
static_cast
<
std
::
size_t
>
(
M
)})));
Tensor
<
ReduceDataType
>
d1_g_m_host_result
(
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
(
{
static_cast
<
std
::
size_t
>
(
BatchCount
),
static_cast
<
std
::
size_t
>
(
M
)})));
Tensor
<
ReduceDataType
>
d0_g_m_host_result
({
BatchCount
,
M
});
Tensor
<
ReduceDataType
>
d1_g_m_host_result
({
BatchCount
,
M
});
Tensor
<
CDataType
>
c_g_m_n_device_result
(
f_host_tensor_descriptor
(
BatchCount
,
M
,
N
,
StrideC
,
CLayout
{}));
Tensor
<
ReduceDataType
>
d0_g_m_device_result
(
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
(
{
static_cast
<
std
::
size_t
>
(
BatchCount
),
static_cast
<
std
::
size_t
>
(
M
)})));
Tensor
<
ReduceDataType
>
d1_g_m_device_result
(
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
(
{
static_cast
<
std
::
size_t
>
(
BatchCount
),
static_cast
<
std
::
size_t
>
(
M
)})));
Tensor
<
ReduceDataType
>
d0_g_m_device_result
({
BatchCount
,
M
});
Tensor
<
ReduceDataType
>
d1_g_m_device_result
({
BatchCount
,
M
});
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
;
...
...
@@ -296,16 +293,15 @@ int main(int argc, char* argv[])
}
}
pass
=
ck
::
utils
::
check_err
(
c_g_m_n_host_result
.
mData
,
c_g_m_n_device_result
.
mData
,
"Error: Incorrect results c"
)
&&
ck
::
utils
::
check_err
(
d0_g_m_device_result
.
mData
,
d0_g_m_host_result
.
mData
,
pass
=
ck
::
utils
::
check_err
(
c_g_m_n_host_result
,
c_g_m_n_device_result
,
"Error: Incorrect results c"
)
&&
ck
::
utils
::
check_err
(
d0_g_m_device_result
,
d0_g_m_host_result
,
"Error: Incorrect results! D0"
,
1e-4
,
1e-5
)
&&
ck
::
utils
::
check_err
(
d1_g_m_device_result
.
mData
,
d1_g_m_host_result
.
mData
,
ck
::
utils
::
check_err
(
d1_g_m_device_result
,
d1_g_m_host_result
,
"Error: Incorrect results! D1"
,
1e-3
,
1e-5
);
...
...
example/19_binary_elementwise/broadcast_add_2d_amn_bn.cpp
View file @
4698993d
...
...
@@ -12,6 +12,7 @@
#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"
using
F16
=
ck
::
half_t
;
using
F32
=
float
;
...
...
@@ -71,13 +72,13 @@ int main()
ck
::
index_t
Stride
=
1024
;
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
}));
return
HostTensorDescriptor
({
len
},
{
stride
});
};
auto
f_host_tensor_descriptor2d
=
[](
std
::
size_t
row
,
std
::
size_t
col
,
std
::
size_t
stride
)
{
return
HostTensorDescriptor
(
std
::
vector
<
std
::
size_t
>
({
row
,
col
}),
std
::
vector
<
std
::
size_t
>
({
stride
,
1
}));
using
namespace
ck
::
literals
;
return
HostTensorDescriptor
({
row
,
col
},
{
stride
,
1
_uz
});
};
Tensor
<
ABDataType
>
a_m_n
(
f_host_tensor_descriptor2d
(
M
,
N
,
Stride
));
...
...
@@ -128,8 +129,7 @@ int main()
host_broadcast2D
<
Tensor
<
ABDataType
>
,
Tensor
<
ABDataType
>
,
Tensor
<
CDataType
>
,
Add
,
0
>
(
host_c_m_n
,
a_m_n
,
b_n
,
M
,
N
,
Add
{});
pass
&=
ck
::
utils
::
check_err
(
c_m_n
.
mData
,
host_c_m_n
.
mData
,
"Error: Incorrect results c"
,
1e-3
,
1e-3
);
pass
&=
ck
::
utils
::
check_err
(
c_m_n
,
host_c_m_n
,
"Error: Incorrect results c"
,
1e-3
,
1e-3
);
}
return
pass
?
0
:
1
;
...
...
Prev
1
2
3
4
5
6
…
11
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment