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
95a83c6e
Commit
95a83c6e
authored
Nov 18, 2022
by
Adam Osewski
Browse files
Merge remote-tracking branch 'origin/develop' into wavelet_model
parents
5b7c2432
892a8d76
Changes
618
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
173 additions
and
241 deletions
+173
-241
example/13_pool2d_fwd/pool2d_fwd_common.hpp
example/13_pool2d_fwd/pool2d_fwd_common.hpp
+8
-7
example/14_gemm_xdl_quantization/CMakeLists.txt
example/14_gemm_xdl_quantization/CMakeLists.txt
+1
-0
example/14_gemm_xdl_quantization/gemm_xdl_relu_quantization_int8.cpp
...gemm_xdl_quantization/gemm_xdl_relu_quantization_int8.cpp
+14
-37
example/14_gemm_xdl_requant_relu_requant/CMakeLists.txt
example/14_gemm_xdl_requant_relu_requant/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
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
example/19_binary_elementwise/broadcast_add_3d_am_bmnk.cpp
example/19_binary_elementwise/broadcast_add_3d_am_bmnk.cpp
+6
-7
example/19_binary_elementwise/elementwise_add_1d.cpp
example/19_binary_elementwise/elementwise_add_1d.cpp
+2
-4
No files found.
example/13_pool2d_fwd/pool2d_fwd_common.hpp
View file @
95a83c6e
...
...
@@ -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/CMakeLists.txt
0 → 100644
View file @
95a83c6e
add_example_executable
(
example_gemm_xdl_relu_quantization_int8 gemm_xdl_relu_quantization_int8.cpp
)
\ No newline at end of file
example/14_gemm_xdl_
re
quant
_relu_requant
/gemm_xdl_
requant_
relu_
re
quant_int8.cpp
→
example/14_gemm_xdl_quant
ization
/gemm_xdl_relu_quant
ization
_int8.cpp
View file @
95a83c6e
...
...
@@ -15,33 +15,16 @@
#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"
struct
RequantReluRequant
{
// FIXME: We just need one scale for Relu / Leaky Relu / PRelu
RequantReluRequant
(
float
scaleGemm
,
float
scaleRelu
)
:
scaleGemm_
(
scaleGemm
),
scaleRelu_
(
scaleRelu
)
{
}
__host__
__device__
constexpr
void
operator
()(
float
&
y
,
const
float
&
x
)
const
{
float
gemm_requant
=
scaleGemm_
*
x
;
float
relu
=
gemm_requant
>
0
?
gemm_requant
:
0
;
float
relu_requant
=
scaleRelu_
*
relu
;
y
=
relu_requant
>
127
?
127
:
relu_requant
<
-
128
?
-
128
:
relu_requant
;
}
float
scaleGemm_
;
float
scaleRelu_
;
};
template
<
ck
::
index_t
...
Is
>
using
S
=
ck
::
Sequence
<
Is
...
>
;
using
PassThrough
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
ActivationOp
=
ck
::
tensor_operation
::
element_wise
::
Relu
;
using
CElementOp
=
ck
::
tensor_operation
::
element_wise
::
Activation_Mul_Clamp
<
ActivationOp
>
;
using
ADataType
=
int8_t
;
using
BDataType
=
int8_t
;
...
...
@@ -67,7 +50,7 @@ using DeviceGemmInstance = ck::tensor_operation::device::DeviceGemm_Xdl_CShuffle
CShuffleDataType
,
// typename CShuffleDataType,
PassThrough
,
// typename AElementwiseOperation,
PassThrough
,
// typename BElementwiseOperation,
RequantReluRequant
,
// typename CElementwiseOperation,
CElementOp
,
// typename CElementwiseOperation,
GemmDefault
,
// GemmSpecialization GemmSpec,
1
,
// index_t NumGemmKPrefetchStage,
256
,
// index_t BlockSize,
...
...
@@ -100,13 +83,8 @@ using DeviceGemmInstance = ck::tensor_operation::device::DeviceGemm_Xdl_CShuffle
16
>
;
// index_t CShuffleBlockTransferScalarPerVector_NPerBlock>
// clang-format on
using
ReferenceGemmInstance
=
ck
::
tensor_operation
::
host
::
ReferenceGemm
<
ADataType
,
BDataType
,
CDataType
,
float
,
PassThrough
,
PassThrough
,
RequantReluRequant
>
;
using
ReferenceGemmInstance
=
ck
::
tensor_operation
::
host
::
ReferenceGemm
<
ADataType
,
BDataType
,
CDataType
,
float
,
PassThrough
,
PassThrough
,
CElementOp
>
;
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -123,8 +101,7 @@ int main(int argc, char* argv[])
ck
::
index_t
StrideB
=
4096
;
ck
::
index_t
StrideC
=
4096
;
float
scale_gemm
=
0.03
;
float
scale_relu
=
1
;
float
quant_multiplier
=
0.03
;
if
(
argc
==
4
)
{
...
...
@@ -157,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
});
}
};
...
...
@@ -199,7 +176,7 @@ int main(int argc, char* argv[])
auto
a_element_op
=
PassThrough
{};
auto
b_element_op
=
PassThrough
{};
auto
c_element_op
=
RequantReluRequant
{
scale_gemm
,
scale_relu
};
auto
c_element_op
=
CElementOp
{
quant_multiplier
,
ActivationOp
{}
};
// do GEMM
auto
gemm
=
DeviceGemmInstance
{};
...
...
@@ -249,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/14_gemm_xdl_requant_relu_requant/CMakeLists.txt
deleted
100644 → 0
View file @
5b7c2432
add_example_executable
(
example_gemm_xdl_requant_relu_requant_int8 gemm_xdl_requant_relu_requant_int8.cpp
)
\ No newline at end of file
example/15_grouped_gemm/grouped_gemm_xdl_bfp16.cpp
View file @
95a83c6e
...
...
@@ -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 @
95a83c6e
...
...
@@ -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 @
95a83c6e
...
...
@@ -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 @
95a83c6e
...
...
@@ -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 @
95a83c6e
...
...
@@ -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 @
95a83c6e
...
...
@@ -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 @
95a83c6e
...
...
@@ -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 @
95a83c6e
...
...
@@ -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 @
95a83c6e
...
...
@@ -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/CMakeLists.txt
View file @
95a83c6e
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
)
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 @
95a83c6e
...
...
@@ -61,9 +61,13 @@ int run_conv_bwd_data(bool do_verification,
out
.
GenerateTensorValue
(
GeneratorTensor_2
<
OutDataType
>
{
-
5
,
5
});
wei
.
GenerateTensorValue
(
GeneratorTensor_2
<
WeiDataType
>
{
-
5
,
5
});
break
;
default
:
case
2
:
out
.
GenerateTensorValue
(
GeneratorTensor_3
<
OutDataType
>
{
0.0
,
1.0
});
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
());
...
...
@@ -98,9 +102,8 @@ int run_conv_bwd_data(bool do_verification,
if
(
!
conv
.
IsSupportedArgument
(
argument
))
{
throw
std
::
runtime_error
(
"wrong! device_conv with the specified compilation parameters does "
"not support this Conv problem"
);
std
::
cout
<<
"Not support,please check parameters or device"
;
return
0
;
}
float
ave_time
=
invoker
.
Run
(
argument
,
StreamConfig
{
nullptr
,
time_kernel
});
...
...
@@ -142,7 +145,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/
20
_convnd_bwd_
weight
/convnd_bwd_
weight_x
dl_fp16.cpp
→
example/
17
_convnd_bwd_
data
/convnd_bwd_
data_
dl_fp16.cpp
View file @
95a83c6e
// SPDX-License-Identifier: MIT
// 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
WeiDataType
=
ck
::
half_t
;
...
...
@@ -17,61 +17,31 @@ using InElementOp = ck::tensor_operation::element_wise::PassThrough;
using
WeiElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
using
OutElementOp
=
ck
::
tensor_operation
::
element_wise
::
PassThrough
;
static
constexpr
auto
ConvBwd
Weight
Default
=
ck
::
tensor_operation
::
device
::
ConvolutionBackward
Weight
Specialization
::
Default
;
static
constexpr
auto
ConvBwdDefault
=
ck
::
tensor_operation
::
device
::
ConvolutionBackward
Data
Specialization
::
Default
;
template
<
ck
::
index_t
NDimSpatial
>
using
DeviceConvndBwdWeightInstance
=
ck
::
tensor_operation
::
device
::
DeviceConvNdBwdWeightNwcKxcNwk_Xdl_CShuffle
<
NDimSpatial
,
// NDimSpatial
InDataType
,
// InDataType
WeiDataType
,
// WeiDataType
OutDataType
,
// OutDataType
AccDataType
,
// AccDataType
InElementOp
,
// InElementwiseOperation
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
// clang-format off
using
DeviceConvNdBwdDataInstance
=
ck
::
tensor_operation
::
device
::
DeviceConvNdBwdDataNwcKxcNwk_Dl
<
// ######| 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|
// ######| 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|
// ######| | | | | | 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| | |
// ######| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
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
>
;
// clang-format on
int
main
(
int
argc
,
char
*
argv
[])
{
namespace
ctc
=
ck
::
tensor_layout
::
convolution
;
print_helper_msg
();
bool
do_verification
=
true
;
int
init_method
=
1
;
bool
time_kernel
=
false
;
ck
::
utils
::
conv
::
ConvParam
conv_param
{
2
,
1
,
32
,
256
,
1024
,
{
3
,
3
},
{
14
,
14
},
{
2
,
2
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}};
ck
::
index_t
split_k
=
4
;
2
,
1
,
128
,
256
,
256
,
{
3
,
3
},
{
71
,
71
},
{
2
,
2
},
{
1
,
1
},
{
1
,
1
},
{
1
,
1
}};
if
(
argc
==
1
)
{
...
...
@@ -91,9 +61,6 @@ int main(int argc, char* argv[])
const
ck
::
index_t
num_dim_spatial
=
std
::
stoi
(
argv
[
4
]);
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
{};
...
...
@@ -118,14 +85,14 @@ int main(int argc, char* argv[])
ck
::
utils
::
conv
::
make_output_host_tensor_descriptor_g_n_k_wos_packed
<
OutLayout
>
(
conv_param
);
return
run_conv_bwd_
weight
<
1
,
return
run_conv_bwd_
data
<
1
,
InDataType
,
WeiDataType
,
OutDataType
,
InElementOp
,
WeiElementOp
,
OutElementOp
,
DeviceConv
n
dBwd
Weight
Instance
<
1
>>
(
do_verification
,
DeviceConv
N
dBwd
Data
Instance
<
1
>>
(
do_verification
,
init_method
,
time_kernel
,
conv_param
,
...
...
@@ -134,8 +101,7 @@ int main(int argc, char* argv[])
out_g_n_k_wos_desc
,
in_element_op
,
wei_element_op
,
out_element_op
,
split_k
);
out_element_op
);
}
else
if
(
conv_param
.
num_dim_spatial_
==
2
)
{
...
...
@@ -155,14 +121,14 @@ int main(int argc, char* argv[])
ck
::
utils
::
conv
::
make_output_host_tensor_descriptor_g_n_k_wos_packed
<
OutLayout
>
(
conv_param
);
return
run_conv_bwd_
weight
<
2
,
return
run_conv_bwd_
data
<
2
,
InDataType
,
WeiDataType
,
OutDataType
,
InElementOp
,
WeiElementOp
,
OutElementOp
,
DeviceConv
n
dBwd
Weight
Instance
<
2
>>
(
do_verification
,
DeviceConv
N
dBwd
Data
Instance
<
2
>>
(
do_verification
,
init_method
,
time_kernel
,
conv_param
,
...
...
@@ -171,8 +137,7 @@ int main(int argc, char* argv[])
out_g_n_k_wos_desc
,
in_element_op
,
wei_element_op
,
out_element_op
,
split_k
);
out_element_op
);
}
else
if
(
conv_param
.
num_dim_spatial_
==
3
)
{
...
...
@@ -192,14 +157,14 @@ int main(int argc, char* argv[])
ck
::
utils
::
conv
::
make_output_host_tensor_descriptor_g_n_k_wos_packed
<
OutLayout
>
(
conv_param
);
return
run_conv_bwd_
weight
<
3
,
return
run_conv_bwd_
data
<
3
,
InDataType
,
WeiDataType
,
OutDataType
,
InElementOp
,
WeiElementOp
,
OutElementOp
,
DeviceConv
n
dBwd
Weight
Instance
<
3
>>
(
do_verification
,
DeviceConv
N
dBwd
Data
Instance
<
3
>>
(
do_verification
,
init_method
,
time_kernel
,
conv_param
,
...
...
@@ -208,8 +173,7 @@ int main(int argc, char* argv[])
out_g_n_k_wos_desc
,
in_element_op
,
wei_element_op
,
out_element_op
,
split_k
);
out_element_op
);
}
return
0
;
...
...
example/18_batched_gemm_reduce/batched_gemm_reduce_xdl_fp16.cpp
View file @
95a83c6e
...
...
@@ -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 @
95a83c6e
...
...
@@ -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
;
...
...
example/19_binary_elementwise/broadcast_add_3d_am_bmnk.cpp
View file @
95a83c6e
...
...
@@ -8,6 +8,7 @@
#include "ck/tensor_operation/gpu/element/binary_element_wise_operation.hpp"
#include "ck/tensor_operation/gpu/device/impl/device_elementwise.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"
...
...
@@ -82,11 +83,9 @@ int main()
std
::
array
<
ck
::
index_t
,
3
>
b_strides
;
std
::
array
<
ck
::
index_t
,
3
>
c_strides
;
std
::
copy
(
mnk
.
begin
(),
mnk
.
end
(),
abc_lengths
.
begin
());
std
::
copy
(
b_m_n_k
.
mDesc
.
GetStrides
().
begin
(),
b_m_n_k
.
mDesc
.
GetStrides
().
end
(),
b_strides
.
begin
());
std
::
copy
(
c_m_n_k
.
mDesc
.
GetStrides
().
begin
(),
c_m_n_k
.
mDesc
.
GetStrides
().
end
(),
c_strides
.
begin
());
ck
::
ranges
::
copy
(
mnk
,
abc_lengths
.
begin
());
ck
::
ranges
::
copy
(
b_m_n_k
.
mDesc
.
GetStrides
(),
b_strides
.
begin
());
ck
::
ranges
::
copy
(
c_m_n_k
.
mDesc
.
GetStrides
(),
c_strides
.
begin
());
auto
broadcastAdd
=
DeviceElementwiseAddInstance
{};
auto
argument
=
broadcastAdd
.
MakeArgumentPointer
(
...
...
@@ -113,8 +112,8 @@ int main()
host_broadcast3D_am_bmnk
<
Tensor
<
ABDataType
>
,
Tensor
<
ABDataType
>
,
Tensor
<
CDataType
>
,
Add
>
(
host_c_m_n_k
,
a_m
,
b_m_n_k
,
mnk
,
Add
{});
pass
&=
ck
::
utils
::
check_err
(
c_m_n_k
.
mData
,
host_c_m_n_k
.
mData
,
"Error: Incorrect results c"
,
1e-3
,
1e-3
);
pass
&=
c
k
::
utils
::
check_err
(
c
_m_n_k
,
host_c_m_n_k
,
"Error: Incorrect results c"
,
1e-3
,
1e-3
);
}
return
pass
?
0
:
1
;
...
...
example/19_binary_elementwise/elementwise_add_1d.cpp
View file @
95a83c6e
...
...
@@ -53,8 +53,7 @@ int main()
ck
::
index_t
M
=
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
});
};
Tensor
<
ABDataType
>
a_m
(
f_host_tensor_descriptor1d
(
M
,
1
));
...
...
@@ -105,8 +104,7 @@ int main()
host_elementwise1D
<
Tensor
<
ABDataType
>
,
Tensor
<
ABDataType
>
,
Tensor
<
CDataType
>
,
Add
>
(
host_c_m
,
a_m
,
b_m
,
M
,
Add
{});
pass
&=
ck
::
utils
::
check_err
(
c_m
.
mData
,
host_c_m
.
mData
,
"Error: Incorrect results c"
,
1e-3
,
1e-3
);
pass
&=
ck
::
utils
::
check_err
(
c_m
,
host_c_m
,
"Error: Incorrect results c"
,
1e-3
,
1e-3
);
}
return
pass
?
0
:
1
;
...
...
Prev
1
2
3
4
5
6
7
…
31
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment