Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
bf078a01
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
bf078a01
编写于
11月 28, 2018
作者:
Z
Zhen Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove the ugly code matmul_int8.
上级
a80b04b9
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
31 addition
and
28 deletion
+31
-28
src/operators/kernel/central-arm-func/conv_add_relu_int8_arm_func.h
...ors/kernel/central-arm-func/conv_add_relu_int8_arm_func.h
+2
-2
src/operators/kernel/central-arm-func/conv_arm_func.h
src/operators/kernel/central-arm-func/conv_arm_func.h
+6
-6
src/operators/kernel/central-arm-func/mul_arm_func.h
src/operators/kernel/central-arm-func/mul_arm_func.h
+4
-4
src/operators/math/math_function.h
src/operators/math/math_function.h
+5
-4
src/operators/math/math_function_int8.cpp
src/operators/math/math_function_int8.cpp
+6
-4
test/common/test_gemm_perf.cpp
test/common/test_gemm_perf.cpp
+8
-8
未找到文件。
src/operators/kernel/central-arm-func/conv_add_relu_int8_arm_func.h
浏览文件 @
bf078a01
...
...
@@ -113,8 +113,8 @@ void ConvAddReluInt8Compute(const FusionConvAddReluInt8Param<CPU> ¶m) {
Tensor
out_slice
=
out_batch
.
Slice
(
g
*
out_step
,
(
g
+
1
)
*
out_step
);
Tensor
filter_slice
=
filter
.
Slice
(
g
*
out_step
,
(
g
+
1
)
*
out_step
);
math
::
matmul
_int8
(
filter_slice
,
false
,
col_matrix
,
false
,
scale_v
,
&
out_slice
,
static_cast
<
float
>
(
0
),
true
,
biase_data
);
math
::
matmul
(
filter_slice
,
false
,
col_matrix
,
false
,
scale_v
,
&
out_slice
,
static_cast
<
float
>
(
0
),
true
,
biase_data
);
}
}
}
...
...
src/operators/kernel/central-arm-func/conv_arm_func.h
浏览文件 @
bf078a01
...
...
@@ -108,13 +108,13 @@ inline void GemmConv(const ConvParam<CPU> ¶m) {
Tensor
filter_slice
=
filter
.
Slice
(
g
*
out_step
,
(
g
+
1
)
*
out_step
);
if
(
param
.
Input
()
->
type
()
==
typeid
(
int8_t
))
{
math
::
matmul
_int8
(
filter_slice
,
false
,
col_matrix
,
false
,
static_cast
<
float
>
(
1
),
&
out_slice
,
static_cast
<
float
>
(
0
));
math
::
matmul
(
filter_slice
,
false
,
col_matrix
,
false
,
static_cast
<
float
>
(
1
),
&
out_slice
,
static_cast
<
float
>
(
0
)
,
false
,
static_cast
<
int32_t
*>
(
nullptr
));
}
else
{
math
::
matmul
<
float
>
(
filter_slice
,
false
,
col_matrix
,
false
,
static_cast
<
float
>
(
1
),
&
out_slice
,
static_cast
<
float
>
(
0
));
math
::
matmul
(
filter_slice
,
false
,
col_matrix
,
false
,
static_cast
<
float
>
(
1
),
&
out_slice
,
static_cast
<
float
>
(
0
)
,
false
,
static_cast
<
float
*>
(
nullptr
));
}
}
}
...
...
src/operators/kernel/central-arm-func/mul_arm_func.h
浏览文件 @
bf078a01
...
...
@@ -73,13 +73,13 @@ void MulCompute(const MulParam<CPU> ¶m) {
}
if
(
param
.
InputX
()
->
type
()
==
typeid
(
int8_t
))
{
out
->
mutable_data
<
int32_t
>
();
math
::
matmul
_int8
(
x_matrix
,
false
,
y_matrix
,
false
,
static_cast
<
float
>
(
1
)
,
out
,
static_cast
<
float
>
(
0
));
math
::
matmul
(
x_matrix
,
false
,
y_matrix
,
false
,
static_cast
<
float
>
(
1
),
out
,
static_cast
<
float
>
(
0
),
false
,
static_cast
<
int32_t
*>
(
nullptr
));
}
else
{
out
->
mutable_data
<
float
>
();
math
::
matmul
<
float
>
(
x_matrix
,
false
,
y_matrix
,
false
,
static_cast
<
float
>
(
1
)
,
out
,
static_cast
<
float
>
(
0
));
math
::
matmul
(
x_matrix
,
false
,
y_matrix
,
false
,
static_cast
<
float
>
(
1
),
out
,
static_cast
<
float
>
(
0
),
false
,
static_cast
<
float
*>
(
nullptr
));
}
if
(
out_dim
.
size
()
!=
2
)
{
out
->
Resize
(
out_dim
);
...
...
src/operators/math/math_function.h
浏览文件 @
bf078a01
...
...
@@ -30,10 +30,11 @@ void matmul(const framework::Tensor &matrix_a, bool trans_a,
framework
::
Tensor
*
matrix_out
,
T
beta
,
bool
relu
=
false
,
float
*
bias
=
nullptr
);
void
matmul_int8
(
const
framework
::
Tensor
&
matrix_a
,
bool
trans_a
,
const
framework
::
Tensor
&
matrix_b
,
bool
trans_b
,
float
alpha
,
framework
::
Tensor
*
matrix_out
,
float
beta
,
bool
relu
=
false
,
int32_t
*
bias
=
nullptr
);
template
<
typename
T
,
typename
S
>
void
matmul
(
const
framework
::
Tensor
&
matrix_a
,
bool
trans_a
,
const
framework
::
Tensor
&
matrix_b
,
bool
trans_b
,
T
alpha
,
framework
::
Tensor
*
matrix_out
,
T
beta
,
bool
relu
=
false
,
S
*
bias
=
nullptr
);
template
<
typename
T
>
void
matmulWithBn
(
const
framework
::
Tensor
&
matrix_a
,
bool
trans_a
,
...
...
src/operators/math/math_function_int8.cpp
浏览文件 @
bf078a01
...
...
@@ -20,7 +20,9 @@ limitations under the License. */
namespace
paddle_mobile
{
namespace
operators
{
namespace
math
{
void
matmul_int8
(
const
framework
::
Tensor
&
matrix_a
,
bool
trans_a
,
template
<
>
void
matmul
(
const
framework
::
Tensor
&
matrix_a
,
bool
trans_a
,
const
framework
::
Tensor
&
matrix_b
,
bool
trans_b
,
float
alpha
,
framework
::
Tensor
*
matrix_out
,
float
beta
,
bool
relu
,
int32_t
*
bias
)
{
...
...
test/common/test_gemm_perf.cpp
浏览文件 @
bf078a01
...
...
@@ -85,16 +85,16 @@ int main() {
// int8_t without bias
// warm-up 10 times
for
(
int
j
=
0
;
j
<
10
;
++
j
)
{
paddle_mobile
::
operators
::
math
::
matmul
_int8
(
paddle_mobile
::
operators
::
math
::
matmul
(
aa_int8
,
false
,
bb_int8
,
false
,
static_cast
<
float
>
(
1
),
&
cc_int32
,
static_cast
<
float
>
(
0
),
false
,
nullptr
);
static_cast
<
float
>
(
0
),
false
,
static_cast
<
int32_t
*>
(
nullptr
)
);
}
auto
time3
=
time
();
for
(
int
j
=
0
;
j
<
10
;
++
j
)
{
paddle_mobile
::
operators
::
math
::
matmul
_int8
(
paddle_mobile
::
operators
::
math
::
matmul
(
aa_int8
,
false
,
bb_int8
,
false
,
static_cast
<
float
>
(
1
),
&
cc_int32
,
static_cast
<
float
>
(
0
),
false
,
nullptr
);
static_cast
<
float
>
(
0
),
false
,
static_cast
<
int32_t
*>
(
nullptr
)
);
}
auto
time4
=
time
();
std
::
cout
<<
"int8_t gemm cost :"
<<
time_diff
(
time3
,
time4
)
/
10
<<
"ms
\n
"
;
...
...
@@ -102,15 +102,15 @@ int main() {
// int8_t with bias&relu
// warm-up 10 times
for
(
int
j
=
0
;
j
<
10
;
++
j
)
{
paddle_mobile
::
operators
::
math
::
matmul
_int8
(
paddle_mobile
::
operators
::
math
::
matmul
(
aa_int8
,
false
,
bb_int8
,
false
,
static_cast
<
float
>
(
0.618
),
&
cc_int8
,
static_cast
<
float
>
(
0
),
true
,
&
bias_data
[
0
]
);
static_cast
<
float
>
(
0
),
true
,
bias_data
);
}
auto
time5
=
time
();
for
(
int
j
=
0
;
j
<
10
;
++
j
)
{
paddle_mobile
::
operators
::
math
::
matmul
_int8
(
paddle_mobile
::
operators
::
math
::
matmul
(
aa_int8
,
false
,
bb_int8
,
false
,
static_cast
<
float
>
(
0.618
),
&
cc_int8
,
static_cast
<
float
>
(
0
),
true
,
&
bias_data
[
0
]
);
static_cast
<
float
>
(
0
),
true
,
bias_data
);
}
auto
time6
=
time
();
std
::
cout
<<
"int8_t gemm_with_bias_relu cost :"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录