Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
fd91b828
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看板
提交
fd91b828
编写于
12月 20, 2018
作者:
H
hjchen2
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refine: pass input's lod info to output for quantize and dequantize op
上级
7db044ac
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
12 addition
and
10 deletion
+12
-10
src/operators/kernel/arm/dequantize_kernel.cpp
src/operators/kernel/arm/dequantize_kernel.cpp
+3
-2
src/operators/kernel/arm/quantize_kernel.cpp
src/operators/kernel/arm/quantize_kernel.cpp
+3
-2
src/operators/math/sequence2batch.h
src/operators/math/sequence2batch.h
+2
-2
src/operators/op_param.h
src/operators/op_param.h
+4
-4
未找到文件。
src/operators/kernel/arm/dequantize_kernel.cpp
浏览文件 @
fd91b828
...
@@ -30,8 +30,8 @@ bool DequantizeKernel<CPU, float>::Init(DequantizeParam<CPU> *param) {
...
@@ -30,8 +30,8 @@ bool DequantizeKernel<CPU, float>::Init(DequantizeParam<CPU> *param) {
template
<
>
template
<
>
void
DequantizeKernel
<
CPU
,
float
>::
Compute
(
const
DequantizeParam
<
CPU
>
&
param
)
{
void
DequantizeKernel
<
CPU
,
float
>::
Compute
(
const
DequantizeParam
<
CPU
>
&
param
)
{
const
Tensor
*
input
=
param
.
input_
;
const
LoD
Tensor
*
input
=
param
.
input_
;
Tensor
*
output
=
param
.
output_
;
LoD
Tensor
*
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
<
const
int32_t
>
();
...
@@ -72,6 +72,7 @@ void DequantizeKernel<CPU, float>::Compute(const DequantizeParam<CPU> ¶m) {
...
@@ -72,6 +72,7 @@ void DequantizeKernel<CPU, float>::Compute(const DequantizeParam<CPU> ¶m) {
for
(
size_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
size
;
++
i
)
{
y
[
i
]
=
x
[
i
]
*
scale
;
y
[
i
]
=
x
[
i
]
*
scale
;
}
}
output
->
set_lod
(
input
->
lod
());
}
}
}
// namespace operators
}
// namespace operators
...
...
src/operators/kernel/arm/quantize_kernel.cpp
浏览文件 @
fd91b828
...
@@ -186,8 +186,8 @@ bool QuantizeKernel<CPU, float>::Init(QuantizeParam<CPU> *param) {
...
@@ -186,8 +186,8 @@ bool QuantizeKernel<CPU, float>::Init(QuantizeParam<CPU> *param) {
template
<
>
template
<
>
void
QuantizeKernel
<
CPU
,
float
>::
Compute
(
const
QuantizeParam
<
CPU
>
&
param
)
{
void
QuantizeKernel
<
CPU
,
float
>::
Compute
(
const
QuantizeParam
<
CPU
>
&
param
)
{
const
Tensor
*
input
=
param
.
input_
;
const
LoD
Tensor
*
input
=
param
.
input_
;
Tensor
*
output
=
param
.
output_
;
LoD
Tensor
*
output
=
param
.
output_
;
Tensor
*
output_scale
=
param
.
online_scale_
;
Tensor
*
output_scale
=
param
.
online_scale_
;
float
max_abs
=
0.
f
;
float
max_abs
=
0.
f
;
if
(
param
.
offline_
)
{
if
(
param
.
offline_
)
{
...
@@ -212,6 +212,7 @@ void QuantizeKernel<CPU, float>::Compute(const QuantizeParam<CPU> ¶m) {
...
@@ -212,6 +212,7 @@ void QuantizeKernel<CPU, float>::Compute(const QuantizeParam<CPU> ¶m) {
LOG
(
kLOG_ERROR
)
<<
"round type is not supported."
;
LOG
(
kLOG_ERROR
)
<<
"round type is not supported."
;
break
;
break
;
}
}
output
->
set_lod
(
input
->
lod
());
}
}
}
// namespace operators
}
// namespace operators
...
...
src/operators/math/sequence2batch.h
浏览文件 @
fd91b828
...
@@ -69,10 +69,10 @@ class LoDTensor2BatchFunctor {
...
@@ -69,10 +69,10 @@ class LoDTensor2BatchFunctor {
auto
lods
=
lod_tensor
.
lod
();
auto
lods
=
lod_tensor
.
lod
();
PADDLE_MOBILE_ENFORCE
((
lods
.
size
()
==
1UL
),
PADDLE_MOBILE_ENFORCE
((
lods
.
size
()
==
1UL
),
"Only support one level sequence now."
);
"Only support 1 level sequence, but %d is given"
,
lods
.
size
());
const
auto
&
lod
=
lods
[
0
];
const
auto
&
lod
=
lods
[
0
];
std
::
vector
<
SeqInfo
>
seq_info
;
std
::
vector
<
SeqInfo
>
seq_info
;
for
(
size_t
seq_id
=
0
;
seq_id
<
lod
.
size
()
-
1
;
++
seq_id
)
{
for
(
size_t
seq_id
=
0
;
seq_id
<
lod
.
size
()
-
1
;
++
seq_id
)
{
int
length
=
lod
[
seq_id
+
1
]
-
lod
[
seq_id
];
int
length
=
lod
[
seq_id
+
1
]
-
lod
[
seq_id
];
...
...
src/operators/op_param.h
浏览文件 @
fd91b828
...
@@ -2589,9 +2589,9 @@ class QuantizeParam : public OpParam {
...
@@ -2589,9 +2589,9 @@ class QuantizeParam : public OpParam {
public:
public:
// op input
// op input
R
Type
*
input_
;
G
Type
*
input_
;
// op output
// op output
R
Type
*
output_
;
G
Type
*
output_
;
RType
*
online_scale_
;
RType
*
online_scale_
;
// quantize offline scale
// quantize offline scale
RType
*
offline_scale_
;
RType
*
offline_scale_
;
...
@@ -2625,9 +2625,9 @@ class DequantizeParam : public OpParam {
...
@@ -2625,9 +2625,9 @@ class DequantizeParam : public OpParam {
public:
public:
// op input
// op input
R
Type
*
input_
;
G
Type
*
input_
;
// op output
// op output
R
Type
*
output_
;
G
Type
*
output_
;
RType
*
activation_scale_
;
RType
*
activation_scale_
;
float
weight_scale_
;
float
weight_scale_
;
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录