Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
65a8b291
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看板
提交
65a8b291
编写于
3月 29, 2019
作者:
H
hjchen2
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix unit test
上级
3efc0a95
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
8 addition
and
8 deletion
+8
-8
src/operators/kernel/arm/dequantize_kernel.cpp
src/operators/kernel/arm/dequantize_kernel.cpp
+1
-1
src/operators/kernel/arm/quantize_kernel.cpp
src/operators/kernel/arm/quantize_kernel.cpp
+3
-3
test/operators/test_gru_op.cpp
test/operators/test_gru_op.cpp
+2
-2
test/operators/test_quantize_op.cpp
test/operators/test_quantize_op.cpp
+2
-2
未找到文件。
src/operators/kernel/arm/dequantize_kernel.cpp
浏览文件 @
65a8b291
...
@@ -34,7 +34,7 @@ void DequantizeKernel<CPU, float>::Compute(const DequantizeParam<CPU> ¶m) {
...
@@ -34,7 +34,7 @@ void DequantizeKernel<CPU, float>::Compute(const DequantizeParam<CPU> ¶m) {
LoDTensor
*
output
=
param
.
output_
;
LoDTensor
*
output
=
param
.
output_
;
float
activation_scale
=
param
.
activation_scale_
->
data
<
float
>
()[
0
];
float
activation_scale
=
param
.
activation_scale_
->
data
<
float
>
()[
0
];
float
weight_scale
=
param
.
weight_scale_
;
float
weight_scale
=
param
.
weight_scale_
;
const
int32_t
*
x
=
input
->
data
<
const
int32_t
>
();
const
int32_t
*
x
=
input
->
data
<
int32_t
>
();
float
*
y
=
output
->
mutable_data
<
float
>
();
float
*
y
=
output
->
mutable_data
<
float
>
();
size_t
size
=
output
->
numel
();
size_t
size
=
output
->
numel
();
// float scale = 1.f / (activation_scale * weight_scale);
// float scale = 1.f / (activation_scale * weight_scale);
...
...
src/operators/kernel/arm/quantize_kernel.cpp
浏览文件 @
65a8b291
...
@@ -36,7 +36,7 @@ inline float32_t vmaxvq_f32(float32x4_t r) {
...
@@ -36,7 +36,7 @@ inline float32_t vmaxvq_f32(float32x4_t r) {
template
<
RoundType
R
>
template
<
RoundType
R
>
inline
void
QuantizeOffline
(
const
Tensor
*
input
,
const
float
scale
,
inline
void
QuantizeOffline
(
const
Tensor
*
input
,
const
float
scale
,
const
float
max_abs
,
Tensor
*
output
)
{
const
float
max_abs
,
Tensor
*
output
)
{
const
float
*
x
=
input
->
data
<
const
float
>
();
const
float
*
x
=
input
->
data
<
float
>
();
int8_t
*
y
=
output
->
mutable_data
<
int8_t
>
();
int8_t
*
y
=
output
->
mutable_data
<
int8_t
>
();
size_t
remain
=
input
->
numel
();
size_t
remain
=
input
->
numel
();
#if defined(__ARM_NEON__) || defined(__ARM_NEON)
#if defined(__ARM_NEON__) || defined(__ARM_NEON)
...
@@ -88,7 +88,7 @@ inline void QuantizeOffline(const Tensor *input, const float scale,
...
@@ -88,7 +88,7 @@ inline void QuantizeOffline(const Tensor *input, const float scale,
template
<
RoundType
R
>
template
<
RoundType
R
>
inline
void
QuantizeOnline
(
const
Tensor
*
input
,
const
float
scale
,
inline
void
QuantizeOnline
(
const
Tensor
*
input
,
const
float
scale
,
Tensor
*
output
)
{
Tensor
*
output
)
{
const
float
*
x
=
input
->
data
<
const
float
>
();
const
float
*
x
=
input
->
data
<
float
>
();
int8_t
*
y
=
output
->
mutable_data
<
int8_t
>
();
int8_t
*
y
=
output
->
mutable_data
<
int8_t
>
();
size_t
remain
=
input
->
numel
();
size_t
remain
=
input
->
numel
();
#if defined(__ARM_NEON__) || defined(__ARM_NEON)
#if defined(__ARM_NEON__) || defined(__ARM_NEON)
...
@@ -143,7 +143,7 @@ static void Quantize(const Tensor *input, const float max_abs,
...
@@ -143,7 +143,7 @@ static void Quantize(const Tensor *input, const float max_abs,
float
find_abs_max
(
const
Tensor
*
input
)
{
float
find_abs_max
(
const
Tensor
*
input
)
{
float
max_abs
=
0.
f
;
float
max_abs
=
0.
f
;
const
float
*
x
=
input
->
data
<
const
float
>
();
const
float
*
x
=
input
->
data
<
float
>
();
size_t
remain
=
input
->
numel
();
size_t
remain
=
input
->
numel
();
#if defined(__ARM_NEON__) || defined(__ARM_NEON)
#if defined(__ARM_NEON__) || defined(__ARM_NEON)
size_t
loop
=
remain
>>
4
;
size_t
loop
=
remain
>>
4
;
...
...
test/operators/test_gru_op.cpp
浏览文件 @
65a8b291
...
@@ -20,8 +20,8 @@ namespace paddle_mobile {
...
@@ -20,8 +20,8 @@ namespace paddle_mobile {
template
<
typename
Itype
,
typename
Otype
>
template
<
typename
Itype
,
typename
Otype
>
int
TestGruOp
(
int
in_channels
,
int
out_channels
,
std
::
string
opname
)
{
int
TestGruOp
(
int
in_channels
,
int
out_channels
,
std
::
string
opname
)
{
in
t
input_c
=
in_channels
;
size_
t
input_c
=
in_channels
;
in
t
output_c
=
out_channels
;
size_
t
output_c
=
out_channels
;
paddle_mobile
::
framework
::
LoD
lod
{{
0
,
input_c
}};
paddle_mobile
::
framework
::
LoD
lod
{{
0
,
input_c
}};
int
batch_size
=
lod
.
size
();
int
batch_size
=
lod
.
size
();
framework
::
DDim
input_shape
=
framework
::
make_ddim
({
input_c
,
output_c
*
3
});
framework
::
DDim
input_shape
=
framework
::
make_ddim
({
input_c
,
output_c
*
3
});
...
...
test/operators/test_quantize_op.cpp
浏览文件 @
65a8b291
...
@@ -65,7 +65,7 @@ static void quantize(const Tensor *input, const float scale, Tensor *output) {
...
@@ -65,7 +65,7 @@ static void quantize(const Tensor *input, const float scale, Tensor *output) {
int
output_w
=
output
->
dims
()[
3
];
int
output_w
=
output
->
dims
()[
3
];
size_t
input_spatial
=
input_h
*
input_w
;
size_t
input_spatial
=
input_h
*
input_w
;
size_t
output_spatial
=
output_h
*
output_w
;
size_t
output_spatial
=
output_h
*
output_w
;
const
float
*
x
=
input
->
data
<
const
float
>
();
const
float
*
x
=
input
->
data
<
float
>
();
int8_t
*
y
=
output
->
mutable_data
<
int8_t
>
();
int8_t
*
y
=
output
->
mutable_data
<
int8_t
>
();
for
(
int
nc
=
0
;
nc
<
batch_size
*
channels
;
++
nc
)
{
for
(
int
nc
=
0
;
nc
<
batch_size
*
channels
;
++
nc
)
{
...
@@ -81,7 +81,7 @@ static void quantize(const Tensor *input, const float scale, Tensor *output) {
...
@@ -81,7 +81,7 @@ static void quantize(const Tensor *input, const float scale, Tensor *output) {
static
float
find_abs_max
(
const
Tensor
*
input
)
{
static
float
find_abs_max
(
const
Tensor
*
input
)
{
float
max_abs
=
0.
f
;
float
max_abs
=
0.
f
;
const
float
*
x
=
input
->
data
<
const
float
>
();
const
float
*
x
=
input
->
data
<
float
>
();
size_t
size
=
input
->
numel
();
size_t
size
=
input
->
numel
();
for
(
size_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
size
;
++
i
)
{
float
value
=
std
::
abs
(
x
[
i
]);
float
value
=
std
::
abs
(
x
[
i
]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录