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
557d7aa3
Commit
557d7aa3
authored
Oct 12, 2022
by
rocking
Browse files
1. Rename gemm quantization
2. shares the requantization lambda function with conv
parent
42c5e890
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
33 deletions
+9
-33
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
+8
-32
example/14_gemm_xdl_requant_relu_requant/CMakeLists.txt
example/14_gemm_xdl_requant_relu_requant/CMakeLists.txt
+0
-1
No files found.
example/14_gemm_xdl_quantization/CMakeLists.txt
0 → 100644
View file @
557d7aa3
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 @
557d7aa3
...
...
@@ -18,30 +18,12 @@
#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 +49,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 +82,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 +100,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
)
{
...
...
@@ -199,7 +175,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
{};
...
...
example/14_gemm_xdl_requant_relu_requant/CMakeLists.txt
deleted
100644 → 0
View file @
42c5e890
add_example_executable
(
example_gemm_xdl_requant_relu_requant_int8 gemm_xdl_requant_relu_requant_int8.cpp
)
\ No newline at end of file
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