Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
5957f2f2
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看板
提交
5957f2f2
编写于
8月 07, 2018
作者:
Z
zhangyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add PerformBypass inside FeedOp
上级
a9537ca4
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
47 addition
and
10 deletion
+47
-10
src/operators/feed_op.h
src/operators/feed_op.h
+31
-4
src/operators/kernel/fpga/conv_add_bn_kernel.cpp
src/operators/kernel/fpga/conv_add_bn_kernel.cpp
+2
-2
src/operators/kernel/fpga/conv_add_bn_relu_kernel.cpp
src/operators/kernel/fpga/conv_add_bn_relu_kernel.cpp
+2
-2
src/operators/kernel/fpga/conv_add_relu_kernel.cpp
src/operators/kernel/fpga/conv_add_relu_kernel.cpp
+2
-2
src/operators/op_param.h
src/operators/op_param.h
+10
-0
未找到文件。
src/operators/feed_op.h
浏览文件 @
5957f2f2
...
@@ -30,18 +30,45 @@ class FeedOp : public framework::OperatorBase<DeviceType> {
...
@@ -30,18 +30,45 @@ class FeedOp : public framework::OperatorBase<DeviceType> {
:
framework
::
OperatorBase
<
DeviceType
>
(
type
,
inputs
,
outputs
,
attrs
,
:
framework
::
OperatorBase
<
DeviceType
>
(
type
,
inputs
,
outputs
,
attrs
,
scope
),
scope
),
param_
(
inputs
,
outputs
,
attrs
,
scope
.
get
())
{}
param_
(
inputs
,
outputs
,
attrs
,
scope
.
get
())
{}
void
RunImpl
()
const
{
param_
.
Out
()
->
ShareDataWith
(
*
param_
.
InputX
());
}
void
Init
()
{}
protected:
FeedParam
param_
;
#ifdef PADDLE_MOBILE_FPGA
void
RunImpl
()
const
{
fpga
::
PerformBypass
(
param_
.
FpgaArgs
());
}
void
Init
()
{
const
Tensor
*
input
=
param_
.
InputX
();
auto
input_ptr
=
input
->
data
<
float
>
();
Tensor
*
output
=
param_
.
Out
();
auto
output_ptr
=
output
->
mutable_data
<
half
>
();
fpga
::
BypassArgs
args
;
args
.
convert_type
=
fpga
::
DATA_FP32_TO_FP16
;
args
.
layout_type
=
fpga
::
LAYOUT_CHW_TO_HWC
;
args
.
image
.
address
=
(
void
*
)
input_ptr
;
args
.
image
.
channels
=
input
->
dims
()[
1
];
args
.
image
.
height
=
input
->
dims
()[
2
];
args
.
image
.
width
=
input
->
dims
()[
3
];
args
.
output
.
address
=
output_ptr
;
param_
.
SetFpgaArgs
(
args
);
}
void
InferShape
()
const
{
void
InferShape
()
const
{
auto
out_dims
=
param_
.
Out
()
->
dims
();
auto
out_dims
=
param_
.
Out
()
->
dims
();
out_dims
[
0
]
=
param_
.
BatchSize
();
out_dims
[
0
]
=
param_
.
BatchSize
();
param_
.
Out
()
->
Resize
(
out_dims
);
param_
.
Out
()
->
Resize
(
out_dims
);
param_
.
Out
()
->
ShareDataWith
(
*
param_
.
InputX
());
// TODO How to handle fp16
}
}
#else
void
RunImpl
()
const
{
param_
.
Out
()
->
ShareDataWith
(
*
param_
.
InputX
());
}
protected:
void
Init
()
{}
FeedParam
param_
;
void
InferShape
()
const
{
auto
out_dims
=
param_
.
Out
()
->
dims
();
out_dims
[
0
]
=
param_
.
BatchSize
();
param_
.
Out
()
->
Resize
(
out_dims
);
#endif
};
};
}
// namespace operators
}
// namespace operators
...
...
src/operators/kernel/fpga/conv_add_bn_kernel.cpp
浏览文件 @
5957f2f2
...
@@ -24,13 +24,13 @@ template <>
...
@@ -24,13 +24,13 @@ template <>
bool
ConvAddBNKernel
<
FPGA
,
float
>::
Init
(
FusionConvAddBNParam
*
param
)
{
bool
ConvAddBNKernel
<
FPGA
,
float
>::
Init
(
FusionConvAddBNParam
*
param
)
{
bool
relu_enabled
=
false
;
bool
relu_enabled
=
false
;
const
Tensor
*
input
=
param
->
Input
();
const
Tensor
*
input
=
param
->
Input
();
auto
input_ptr
=
input
->
data
<
float
>
();
auto
input_ptr
=
input
->
data
<
half
>
();
const
Tensor
*
bias
=
param
->
Bias
();
const
Tensor
*
bias
=
param
->
Bias
();
auto
bias_ptr
=
bias
->
data
<
float
>
();
auto
bias_ptr
=
bias
->
data
<
float
>
();
const
Tensor
*
filter
=
param
->
Filter
();
const
Tensor
*
filter
=
param
->
Filter
();
auto
filter_ptr
=
filter
->
data
<
float
>
();
auto
filter_ptr
=
filter
->
data
<
float
>
();
Tensor
*
out
=
param
->
Output
();
Tensor
*
out
=
param
->
Output
();
auto
out_ptr
=
out
->
mutable_data
<
float
>
();
auto
out_ptr
=
out
->
mutable_data
<
half
>
();
auto
bn_mean_ptr
=
param
->
InputMean
()
->
data
<
float
>
();
auto
bn_mean_ptr
=
param
->
InputMean
()
->
data
<
float
>
();
auto
bn_var_ptr
=
param
->
InputVariance
()
->
data
<
float
>
();
auto
bn_var_ptr
=
param
->
InputVariance
()
->
data
<
float
>
();
auto
bn_scale_ptr
=
param
->
InputScale
()
->
data
<
float
>
();
auto
bn_scale_ptr
=
param
->
InputScale
()
->
data
<
float
>
();
...
...
src/operators/kernel/fpga/conv_add_bn_relu_kernel.cpp
浏览文件 @
5957f2f2
...
@@ -24,13 +24,13 @@ template <>
...
@@ -24,13 +24,13 @@ template <>
bool
ConvAddBNReluKernel
<
FPGA
,
float
>::
Init
(
FusionConvAddBNReluParam
*
param
)
{
bool
ConvAddBNReluKernel
<
FPGA
,
float
>::
Init
(
FusionConvAddBNReluParam
*
param
)
{
bool
relu_enabled
=
true
;
bool
relu_enabled
=
true
;
const
Tensor
*
input
=
param
->
Input
();
const
Tensor
*
input
=
param
->
Input
();
auto
input_ptr
=
input
->
data
<
float
>
();
auto
input_ptr
=
input
->
data
<
half
>
();
const
Tensor
*
bias
=
param
->
Bias
();
const
Tensor
*
bias
=
param
->
Bias
();
auto
bias_ptr
=
bias
->
data
<
float
>
();
auto
bias_ptr
=
bias
->
data
<
float
>
();
const
Tensor
*
filter
=
param
->
Filter
();
const
Tensor
*
filter
=
param
->
Filter
();
auto
filter_ptr
=
filter
->
data
<
float
>
();
auto
filter_ptr
=
filter
->
data
<
float
>
();
Tensor
*
out
=
param
->
Output
();
Tensor
*
out
=
param
->
Output
();
auto
out_ptr
=
out
->
mutable_data
<
float
>
();
auto
out_ptr
=
out
->
mutable_data
<
half
>
();
auto
bn_mean_ptr
=
param
->
InputMean
()
->
data
<
float
>
();
auto
bn_mean_ptr
=
param
->
InputMean
()
->
data
<
float
>
();
auto
bn_var_ptr
=
param
->
InputVariance
()
->
data
<
float
>
();
auto
bn_var_ptr
=
param
->
InputVariance
()
->
data
<
float
>
();
auto
bn_scale_ptr
=
param
->
InputScale
()
->
data
<
float
>
();
auto
bn_scale_ptr
=
param
->
InputScale
()
->
data
<
float
>
();
...
...
src/operators/kernel/fpga/conv_add_relu_kernel.cpp
浏览文件 @
5957f2f2
...
@@ -24,13 +24,13 @@ template <>
...
@@ -24,13 +24,13 @@ template <>
bool
ConvAddReluKernel
<
FPGA
,
float
>::
Init
(
FusionConvAddReluParam
*
param
)
{
bool
ConvAddReluKernel
<
FPGA
,
float
>::
Init
(
FusionConvAddReluParam
*
param
)
{
bool
relu_enabled
=
true
;
bool
relu_enabled
=
true
;
const
Tensor
*
input
=
param
->
Input
();
const
Tensor
*
input
=
param
->
Input
();
auto
input_ptr
=
input
->
data
<
float
>
();
auto
input_ptr
=
input
->
data
<
half
>
();
const
Tensor
*
bias
=
param
->
Bias
();
const
Tensor
*
bias
=
param
->
Bias
();
auto
bias_ptr
=
bias
->
data
<
float
>
();
auto
bias_ptr
=
bias
->
data
<
float
>
();
const
Tensor
*
filter
=
param
->
Filter
();
const
Tensor
*
filter
=
param
->
Filter
();
auto
filter_ptr
=
filter
->
data
<
float
>
();
auto
filter_ptr
=
filter
->
data
<
float
>
();
Tensor
*
out
=
param
->
Output
();
Tensor
*
out
=
param
->
Output
();
auto
out_ptr
=
out
->
mutable_data
<
float
>
();
auto
out_ptr
=
out
->
mutable_data
<
half
>
();
PADDLE_MOBILE_ENFORCE
(
input
->
dims
()[
1
]
==
bias
->
dims
()[
0
],
PADDLE_MOBILE_ENFORCE
(
input
->
dims
()[
1
]
==
bias
->
dims
()[
0
],
"Image channel should be equal to bias number"
);
"Image channel should be equal to bias number"
);
...
...
src/operators/op_param.h
浏览文件 @
5957f2f2
...
@@ -665,6 +665,16 @@ class FeedParam : public OpParam {
...
@@ -665,6 +665,16 @@ class FeedParam : public OpParam {
Tensor
*
input_x_
;
Tensor
*
input_x_
;
Tensor
*
out_
;
Tensor
*
out_
;
int
batch_size
;
int
batch_size
;
#ifdef PADDLE_MOBILE_FPGA
private:
fpga
::
BypassArgs
fpga_bypass_args
;
public:
const
fpga
::
BypassArgs
&
FpgaArgs
()
const
{
return
fpga_bypass_args
;
}
void
SetFpgaArgs
(
const
fpga
::
BypassArgs
&
args
)
{
fpga_bypass_args
=
args
;
}
#endif
};
};
class
FetchParam
:
public
OpParam
{
class
FetchParam
:
public
OpParam
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录