Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
e22f59d7
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看板
提交
e22f59d7
编写于
11月 27, 2018
作者:
H
hjchen2
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of
https://github.com/PaddlePaddle/paddle-mobile
into dev-latest
上级
405630c7
3c642e35
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
22 deletion
+25
-22
src/operators/kernel/fpga/V1/feed_kernel.cpp
src/operators/kernel/fpga/V1/feed_kernel.cpp
+1
-1
src/operators/kernel/fpga/V2/feed_kernel.cpp
src/operators/kernel/fpga/V2/feed_kernel.cpp
+1
-1
test/operators/test_quantize_op.cpp
test/operators/test_quantize_op.cpp
+23
-20
未找到文件。
src/operators/kernel/fpga/V1/feed_kernel.cpp
浏览文件 @
e22f59d7
...
@@ -28,8 +28,8 @@ template <>
...
@@ -28,8 +28,8 @@ template <>
void
FeedKernel
<
FPGA
,
float
>::
Compute
(
const
FeedParam
<
FPGA
>
&
param
)
{
void
FeedKernel
<
FPGA
,
float
>::
Compute
(
const
FeedParam
<
FPGA
>
&
param
)
{
auto
input
=
auto
input
=
reinterpret_cast
<
Tensor
*>
(
const_cast
<
LoDTensor
*>
(
param
.
InputX
()));
reinterpret_cast
<
Tensor
*>
(
const_cast
<
LoDTensor
*>
(
param
.
InputX
()));
auto
input_ptr
=
input
->
data
<
float
>
();
fpga
::
format_image
(
input
);
fpga
::
format_image
(
input
);
auto
input_ptr
=
input
->
data
<
float
>
();
Tensor
*
output
=
param
.
Out
();
Tensor
*
output
=
param
.
Out
();
auto
output_ptr
=
output
->
data
<
float
>
();
auto
output_ptr
=
output
->
data
<
float
>
();
...
...
src/operators/kernel/fpga/V2/feed_kernel.cpp
浏览文件 @
e22f59d7
...
@@ -29,8 +29,8 @@ template <>
...
@@ -29,8 +29,8 @@ template <>
void
FeedKernel
<
FPGA
,
float
>::
Compute
(
const
FeedParam
<
FPGA
>
&
param
)
{
void
FeedKernel
<
FPGA
,
float
>::
Compute
(
const
FeedParam
<
FPGA
>
&
param
)
{
auto
input
=
auto
input
=
reinterpret_cast
<
Tensor
*>
(
const_cast
<
LoDTensor
*>
(
param
.
InputX
()));
reinterpret_cast
<
Tensor
*>
(
const_cast
<
LoDTensor
*>
(
param
.
InputX
()));
auto
input_ptr
=
input
->
data
<
float
>
();
fpga
::
format_image
(
input
);
fpga
::
format_image
(
input
);
auto
input_ptr
=
input
->
data
<
float
>
();
Tensor
*
output
=
param
.
Out
();
Tensor
*
output
=
param
.
Out
();
auto
output_ptr
=
output
->
data
<
float
>
();
auto
output_ptr
=
output
->
data
<
float
>
();
...
...
test/operators/test_quantize_op.cpp
浏览文件 @
e22f59d7
...
@@ -27,34 +27,38 @@ enum RoundType {
...
@@ -27,34 +27,38 @@ enum RoundType {
}
}
template
<
round
::
RoundType
T
>
template
<
round
::
RoundType
T
>
static
int8_t
Round
(
float
x
);
struct
Round
{
int8_t
operator
()(
float
x
);
};
template
<
>
template
<
>
st
atic
int8_t
Round
<
round
::
RoundAwayZero
>
(
float
x
)
{
st
ruct
Round
<
round
::
RoundAwayZero
>
{
return
std
::
round
(
x
);
int8_t
operator
()(
float
x
)
{
return
std
::
round
(
x
);
}
}
}
;
template
<
>
template
<
>
st
atic
int8_t
Round
<
round
::
RoundTowardsZero
>
(
float
x
)
{
st
ruct
Round
<
round
::
RoundTowardsZero
>
{
return
int8_t
(
x
);
int8_t
operator
()(
float
x
)
{
return
int8_t
(
x
);
}
}
}
;
template
<
>
template
<
>
static
int8_t
Round
<
round
::
RoundToEven
>
(
float
x
)
{
struct
Round
<
round
::
RoundToEven
>
{
int8_t
ret
=
0
;
int8_t
operator
()(
float
x
)
{
float
v
=
std
::
round
(
x
);
int8_t
ret
=
0
;
int32_t
q
=
(
int32_t
)
v
;
float
v
=
std
::
round
(
x
);
if
(
abs
(
abs
(
q
-
x
)
-
0.5
)
>
0
)
{
int32_t
q
=
(
int32_t
)
v
;
ret
=
q
;
if
(
abs
(
abs
(
q
-
x
)
-
0.5
)
>
0
)
{
}
else
{
if
(
abs
(
q
)
%
2
==
0
)
{
ret
=
q
;
ret
=
q
;
}
else
{
}
else
{
ret
=
q
+
((
q
>
0
)
?
-
1
:
1
);
if
(
abs
(
q
)
%
2
==
0
)
{
ret
=
q
;
}
else
{
ret
=
q
+
((
q
>
0
)
?
-
1
:
1
);
}
}
}
return
ret
;
}
}
return
ret
;
};
}
template
<
round
::
RoundType
T
>
template
<
round
::
RoundType
T
>
static
void
quantize
(
const
Tensor
*
input
,
const
float
scale
,
const
int
pad
,
static
void
quantize
(
const
Tensor
*
input
,
const
float
scale
,
const
int
pad
,
...
@@ -70,7 +74,6 @@ static void quantize(const Tensor *input, const float scale, const int pad,
...
@@ -70,7 +74,6 @@ static void quantize(const Tensor *input, const float scale, const int pad,
const
float
*
x
=
input
->
data
<
const
float
>
();
const
float
*
x
=
input
->
data
<
const
float
>
();
int8_t
*
y
=
output
->
mutable_data
<
int8_t
>
();
int8_t
*
y
=
output
->
mutable_data
<
int8_t
>
();
std
::
cout
<<
"pad: "
<<
pad
<<
", pad_val: "
<<
int
(
pad_val
)
<<
std
::
endl
;
for
(
int
nc
=
0
;
nc
<
batch_size
*
channels
;
++
nc
)
{
for
(
int
nc
=
0
;
nc
<
batch_size
*
channels
;
++
nc
)
{
const
float
*
xh
=
x
+
nc
*
input_spatial
;
const
float
*
xh
=
x
+
nc
*
input_spatial
;
int8_t
*
yh
=
y
+
nc
*
output_spatial
;
int8_t
*
yh
=
y
+
nc
*
output_spatial
;
...
@@ -86,7 +89,7 @@ static void quantize(const Tensor *input, const float scale, const int pad,
...
@@ -86,7 +89,7 @@ static void quantize(const Tensor *input, const float scale, const int pad,
yh
[
w
]
=
pad_val
;
yh
[
w
]
=
pad_val
;
}
}
for
(
int
w
=
0
;
w
<
input_w
;
++
w
)
{
for
(
int
w
=
0
;
w
<
input_w
;
++
w
)
{
yh
[
w
+
pad
]
=
Round
<
T
>
(
xh
[
w
]
*
scale
);
yh
[
w
+
pad
]
=
Round
<
T
>
(
)(
xh
[
w
]
*
scale
);
}
}
// pad right
// pad right
for
(
int
w
=
0
;
w
<
pad
;
++
w
)
{
for
(
int
w
=
0
;
w
<
pad
;
++
w
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录