Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
e5066279
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看板
提交
e5066279
编写于
5月 07, 2020
作者:
C
chenjiaoAngel
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix format. test=develop
上级
3aec2316
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
94 addition
and
33 deletion
+94
-33
lite/backends/arm/math/gemm_prepacked_int8.cc
lite/backends/arm/math/gemm_prepacked_int8.cc
+65
-10
lite/backends/arm/math/gemv_arm_int8.cc
lite/backends/arm/math/gemv_arm_int8.cc
+12
-6
lite/tests/math/conv_compute_test.cc
lite/tests/math/conv_compute_test.cc
+5
-5
lite/tests/math/conv_int8_compute_test.cc
lite/tests/math/conv_int8_compute_test.cc
+6
-4
lite/tests/math/gemm_int8_compute_test.cc
lite/tests/math/gemm_int8_compute_test.cc
+2
-2
lite/tests/math/gemv_int8_compute_test.cc
lite/tests/math/gemv_int8_compute_test.cc
+2
-4
lite/tests/math/sgemv_compute_test.cc
lite/tests/math/sgemv_compute_test.cc
+1
-1
lite/tests/utils/naive_math_impl.h
lite/tests/utils/naive_math_impl.h
+1
-1
未找到文件。
lite/backends/arm/math/gemm_prepacked_int8.cc
浏览文件 @
e5066279
...
...
@@ -4222,15 +4222,48 @@ void gemm_prepack_int8(const int8_t* A_packed,
}
#if defined(__aarch64__) && defined(WITH_ARM_DOTPROD)
if
(
ctx
->
has_dot
())
{
gemm_prepack_sdot_int8
<
float32_t
>
(
A_packed
,
B
,
bias
,
C
,
M
,
N
,
K
,
is_bias
,
flag_act
,
is_transB
,
scale
,
alpha
,
ctx
);
gemm_prepack_sdot_int8
<
float32_t
>
(
A_packed
,
B
,
bias
,
C
,
M
,
N
,
K
,
is_bias
,
flag_act
,
is_transB
,
scale
,
alpha
,
ctx
);
}
else
{
gemm_prepack_oth_int8
<
float32_t
>
(
A_packed
,
B
,
bias
,
C
,
M
,
N
,
K
,
is_bias
,
flag_act
,
is_transB
,
scale
,
alpha
,
ctx
);
gemm_prepack_oth_int8
<
float32_t
>
(
A_packed
,
B
,
bias
,
C
,
M
,
N
,
K
,
is_bias
,
flag_act
,
is_transB
,
scale
,
alpha
,
ctx
);
}
#else
gemm_prepack_oth_int8
<
float32_t
>
(
A_packed
,
B
,
bias
,
C
,
M
,
N
,
K
,
is_bias
,
flag_act
,
is_transB
,
scale
,
alpha
,
ctx
);
gemm_prepack_oth_int8
<
float32_t
>
(
A_packed
,
B
,
bias
,
C
,
M
,
N
,
K
,
is_bias
,
flag_act
,
is_transB
,
scale
,
alpha
,
ctx
);
#endif
}
...
...
@@ -4271,11 +4304,33 @@ void gemm_prepack_int8(const int8_t* A_packed,
}
#if defined(__aarch64__) && defined(WITH_ARM_DOTPROD)
if
(
ctx
->
has_dot
())
{
gemm_prepack_sdot_int8
<
int8_t
>
(
A_packed
,
B
,
bias
,
C
,
M
,
N
,
K
,
is_bias
,
flag_act
,
is_transB
,
scale
,
alpha
,
ctx
);
gemm_prepack_sdot_int8
<
int8_t
>
(
A_packed
,
B
,
bias
,
C
,
M
,
N
,
K
,
is_bias
,
flag_act
,
is_transB
,
scale
,
alpha
,
ctx
);
}
else
{
gemm_prepack_oth_int8
<
int8_t
>
(
A_packed
,
B
,
bias
,
C
,
M
,
N
,
K
,
is_bias
,
flag_act
,
is_transB
,
scale
,
alpha
,
ctx
);
gemm_prepack_oth_int8
<
int8_t
>
(
A_packed
,
B
,
bias
,
C
,
M
,
N
,
K
,
is_bias
,
flag_act
,
is_transB
,
scale
,
alpha
,
ctx
);
}
#else
gemm_prepack_oth_int8
<
int8_t
>
(
...
...
lite/backends/arm/math/gemv_arm_int8.cc
浏览文件 @
e5066279
...
...
@@ -311,7 +311,8 @@ bool gemv_int8_oth(const int8_t* A,
ptr_out
[
7
]
+=
ptr_in
[
i
]
*
ptr_w7
[
i
];
}
write_gemv_out
(
ptr_out
,
out_ptr
,
scale_ptr
,
bias_ptr
,
8
,
flag_act
,
act
,
six
,
alpha
);
write_gemv_out
(
ptr_out
,
out_ptr
,
scale_ptr
,
bias_ptr
,
8
,
flag_act
,
act
,
six
,
alpha
);
}
//! deal with remains
...
...
@@ -355,7 +356,8 @@ bool gemv_int8_oth(const int8_t* A,
for
(
int
i
=
0
;
i
<
tail
;
++
i
)
{
ptr_out
[
0
]
+=
ptr_in
[
i
]
*
ptr_w0
[
i
];
}
write_gemv_out
(
ptr_out
,
out_ptr
,
scale_ptr
,
bias_ptr
,
1
,
flag_act
,
act
,
six
,
alpha
);
write_gemv_out
(
ptr_out
,
out_ptr
,
scale_ptr
,
bias_ptr
,
1
,
flag_act
,
act
,
six
,
alpha
);
}
#else // __aarch64__
int
out_cnt
=
M
>>
2
;
...
...
@@ -449,7 +451,8 @@ bool gemv_int8_oth(const int8_t* A,
ptr_out
[
2
]
+=
ptr_in
[
i
]
*
ptr_w2
[
i
];
ptr_out
[
3
]
+=
ptr_in
[
i
]
*
ptr_w3
[
i
];
}
write_gemv_out
(
ptr_out
,
out_ptr
,
scale_ptr
,
bias_ptr
,
4
,
flag_act
,
act
,
six
,
alpha
);
write_gemv_out
(
ptr_out
,
out_ptr
,
scale_ptr
,
bias_ptr
,
4
,
flag_act
,
act
,
six
,
alpha
);
}
//! deal with remains
#pragma omp parallel for
...
...
@@ -490,7 +493,8 @@ bool gemv_int8_oth(const int8_t* A,
for
(
int
i
=
0
;
i
<
tail
;
++
i
)
{
ptr_out
[
0
]
+=
ptr_in
[
i
]
*
ptr_w0
[
i
];
}
write_gemv_out
(
ptr_out
,
out_ptr
,
scale_ptr
,
bias_ptr
,
1
,
flag_act
,
act
,
six
,
alpha
);
write_gemv_out
(
ptr_out
,
out_ptr
,
scale_ptr
,
bias_ptr
,
1
,
flag_act
,
act
,
six
,
alpha
);
}
#endif // __aarch64__
return
true
;
...
...
@@ -648,7 +652,8 @@ bool gemv_int8_sdot(const int8_t* A,
ptr_out
[
6
]
+=
ptr_in
[
i
]
*
ptr_w6
[
i
];
ptr_out
[
7
]
+=
ptr_in
[
i
]
*
ptr_w7
[
i
];
}
write_gemv_out
(
ptr_out
,
out_ptr
,
scale_ptr
,
bias_ptr
,
8
,
flag_act
,
act
,
six
,
alpha
);
write_gemv_out
(
ptr_out
,
out_ptr
,
scale_ptr
,
bias_ptr
,
8
,
flag_act
,
act
,
six
,
alpha
);
}
//! deal with remains
#pragma omp parallel for
...
...
@@ -688,7 +693,8 @@ bool gemv_int8_sdot(const int8_t* A,
for
(
int
i
=
0
;
i
<
tail
;
++
i
)
{
ptr_out
[
0
]
+=
ptr_in
[
i
]
*
ptr_w0
[
i
];
}
write_gemv_out
(
ptr_out
,
out_ptr
,
scale_ptr
,
bias_ptr
,
1
,
flag_act
,
act
,
six
,
alpha
);
write_gemv_out
(
ptr_out
,
out_ptr
,
scale_ptr
,
bias_ptr
,
1
,
flag_act
,
act
,
six
,
alpha
);
}
return
true
;
}
...
...
lite/tests/math/conv_compute_test.cc
浏览文件 @
e5066279
...
...
@@ -221,11 +221,11 @@ void test_conv_fp32(const std::vector<DDim>& input_dims,
flag_act
,
six
,
leakey_relu_scale
);
if
(
flag_act
==
2
)
{
// relu6
for
(
int
i
=
0
;
i
<
dim_out
.
production
();
i
++
)
{
dout_basic
[
i
]
=
dout_basic
[
i
]
>
six
?
six
:
dout_basic
[
i
];
}
}
if
(
flag_act
==
2
)
{
// relu6
for
(
int
i
=
0
;
i
<
dim_out
.
production
();
i
++
)
{
dout_basic
[
i
]
=
dout_basic
[
i
]
>
six
?
six
:
dout_basic
[
i
];
}
}
}
/// warm up
for
(
int
i
=
0
;
i
<
FLAGS_warmup
;
++
i
)
{
...
...
lite/tests/math/conv_int8_compute_test.cc
浏览文件 @
e5066279
...
...
@@ -321,10 +321,12 @@ void test_conv_int8(const std::vector<DDim>& input_dims,
1
,
1
,
dim_out
.
production
());
if
(
flag_act
==
2
)
{
// relu6
if
(
flag_act
==
2
)
{
// relu6
for
(
int
i
=
0
;
i
<
dim_out
.
production
();
i
++
)
{
dout_basic_int8
[
i
]
=
dout_basic_int8
[
i
]
>
six
?
six
:
dout_basic_int8
[
i
];
dout_basic_fp32
[
i
]
=
dout_basic_fp32
[
i
]
>
six
?
six
:
dout_basic_fp32
[
i
];
dout_basic_int8
[
i
]
=
dout_basic_int8
[
i
]
>
six
?
six
:
dout_basic_int8
[
i
];
dout_basic_fp32
[
i
]
=
dout_basic_fp32
[
i
]
>
six
?
six
:
dout_basic_fp32
[
i
];
}
}
}
...
...
@@ -526,7 +528,7 @@ TEST(TestConv5x5DWInt8, test_conv5x5_depthwise) {
for
(
auto
&
stride
:
{
1
,
2
})
{
for
(
auto
&
pad
:
{
0
,
1
,
2
,
3
,
4
})
{
for
(
auto
&
flag_bias
:
{
false
,
true
})
{
for
(
auto
&
flag_act
:
{
0
,
1
})
{
for
(
auto
&
flag_act
:
{
0
,
1
})
{
for
(
auto
&
c
:
{
1
,
5
,
15
,
33
})
{
std
::
vector
<
DDim
>
dims
;
DDim
weights_dim
({
c
,
1
,
5
,
5
});
...
...
lite/tests/math/gemm_int8_compute_test.cc
浏览文件 @
e5066279
...
...
@@ -95,8 +95,8 @@ bool test_gemm_int8(bool tra,
std
::
vector
<
float
>
scale_merge_int8
(
static_cast
<
size_t
>
(
m
));
ActivationParam
act_param
;
act_param
.
has_active
=
has_relu
;
if
(
has_relu
){
act_param
.
active_type
=
(
paddle
::
lite_api
::
ActivationType
)
1
;
if
(
has_relu
)
{
act_param
.
active_type
=
(
paddle
::
lite_api
::
ActivationType
)
1
;
}
for
(
int
j
=
0
;
j
<
m
;
++
j
)
{
scale_merge_fp32
[
j
]
=
scale_a
[
j
]
*
scale_b
[
0
];
...
...
lite/tests/math/gemv_int8_compute_test.cc
浏览文件 @
e5066279
...
...
@@ -23,7 +23,6 @@
#include "lite/core/profile/timer.h"
#include "lite/core/tensor.h"
#include "lite/tests/utils/tensor_utils.h"
#include "lite/backends/arm/math/saturate.h"
typedef
paddle
::
lite
::
Tensor
Tensor
;
using
paddle
::
lite
::
profile
::
Timer
;
...
...
@@ -99,8 +98,7 @@ bool test_gemv_int8(bool tra,
}
LOG
(
INFO
)
<<
"gemv_int8 M: "
<<
m
<<
", N: "
<<
n
<<
", transA: "
<<
(
tra
?
"true"
:
"false"
)
<<
", act: "
<<
flag_act
<<
", transA: "
<<
(
tra
?
"true"
:
"false"
)
<<
", act: "
<<
flag_act
<<
", bias: "
<<
(
has_bias
?
"true"
:
"false"
);
#ifdef LITE_WITH_ARM
auto
da
=
ta
.
mutable_data
<
int8_t
>
();
...
...
@@ -155,7 +153,7 @@ bool test_gemv_int8(bool tra,
1
,
1
,
tc_basic_fp32
.
numel
());
if
(
flag_act
==
2
)
{
// relu6
if
(
flag_act
==
2
)
{
// relu6
for
(
int
i
=
0
;
i
<
tc_basic_int8
.
numel
();
i
++
)
{
dc_basic_fp32
[
i
]
=
dc_basic_fp32
[
i
]
>
six
?
six
:
dc_basic_fp32
[
i
];
dc_basic_int8
[
i
]
=
dc_basic_int8
[
i
]
>
six
?
six
:
dc_basic_int8
[
i
];
...
...
lite/tests/math/sgemv_compute_test.cc
浏览文件 @
e5066279
...
...
@@ -108,7 +108,7 @@ bool test_sgemv(bool tra,
flag_act
,
six
,
alpha
);
if
(
flag_act
==
2
)
{
// relu6
if
(
flag_act
==
2
)
{
// relu6
for
(
int
i
=
0
;
i
<
tc_basic
.
numel
();
i
++
)
{
dc_basic
[
i
]
=
dc_basic
[
i
]
>
six
?
six
:
dc_basic
[
i
];
}
...
...
lite/tests/utils/naive_math_impl.h
浏览文件 @
e5066279
...
...
@@ -301,7 +301,7 @@ static void conv_basic(const Dtype1* din,
dst_data_ref
[
out_idx
]
=
dst_data_ref
[
out_idx
]
>
(
Dtype2
)
0
?
dst_data_ref
[
out_idx
]
:
(
Dtype2
)
0
;
//dst_data_ref[out_idx] = dst_data_ref[out_idx] < (Dtype2)six
//
dst_data_ref[out_idx] = dst_data_ref[out_idx] < (Dtype2)six
// ? dst_data_ref[out_idx]
// : (Dtype2)six;
}
else
if
(
act_type
==
4
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录