Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
d934df97
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
332
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看板
提交
d934df97
编写于
1月 27, 2019
作者:
qnqinan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add sigmoid kernel in fpga track and fix a bug in pe cpp
上级
69475342
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
103 addition
and
1 deletion
+103
-1
src/fpga/V1/api.cpp
src/fpga/V1/api.cpp
+1
-0
src/fpga/V1/pe.cpp
src/fpga/V1/pe.cpp
+0
-1
src/operators/kernel/fpga/V1/sigmoid_kernel.cpp
src/operators/kernel/fpga/V1/sigmoid_kernel.cpp
+88
-0
src/operators/op_param.h
src/operators/op_param.h
+14
-0
未找到文件。
src/fpga/V1/api.cpp
浏览文件 @
d934df97
...
...
@@ -805,6 +805,7 @@ void fill_dwconv_arg(struct DWconvArgs *arg, framework::Tensor *input,
auto
filter_ptr
=
filter
->
data
<
float
>
();
auto
input_ptr
=
input
->
data
<
float
>
();
auto
output_ptr
=
out
->
mutable_data
<
float
>
();
arg
->
sub_conv_num
=
1
;
arg
->
relu_enabled
=
relu_enabled
;
arg
->
bias_address
=
bias_ptr
;
arg
->
filter_address
=
filter_ptr
;
...
...
src/fpga/V1/pe.cpp
浏览文件 @
d934df97
...
...
@@ -1043,7 +1043,6 @@ int ComputeDWDeconv(const struct DWDeconvArgs &args) {
std
::
cout
<<
"deconv_post_process "
<<
" cost time: "
<<
(
dif_sec
*
1000000
+
dif_usec
)
<<
"us"
<<
std
::
endl
;
#endif
#endif
return
0
;
}
// ComputeFpgaDeconv
...
...
src/operators/kernel/fpga/V1/sigmoid_kernel.cpp
0 → 100644
浏览文件 @
d934df97
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#ifdef SIGMOID_OP
#include "operators/kernel/activation_kernel.h"
namespace
paddle_mobile
{
namespace
operators
{
using
framework
::
DDim
;
using
framework
::
Tensor
;
template
<
>
bool
SigmoidKernel
<
FPGA
,
float
>::
Init
(
SigmoidParam
<
FPGA
>
*
param
)
{
auto
input
=
const_cast
<
Tensor
*>
(
param
->
InputX
());
auto
input_ptr
=
input
->
data
<
float
>
();
auto
out
=
param
->
Out
();
fpga
::
format_fp32_ofm
(
out
);
auto
float_input
=
new
Tensor
;
if
(
input
->
dims
().
size
()
==
2
)
{
float_input
->
mutable_data
<
float
>
({
1
,
input
->
dims
()[
1
]});
}
else
if
(
input
->
dims
().
size
()
==
4
)
{
float_input
->
mutable_data
<
float
>
(
{
1
,
input
->
dims
()[
2
],
input
->
dims
()[
3
],
input
->
dims
()[
1
]});
}
else
{
DLOG
<<
"wrong dimension of softmax input"
;
}
fpga
::
format_fp32_ofm
(
float_input
);
fpga
::
BypassArgs
args
=
{
fpga
::
DATA_TYPE_FP16
};
args
.
input_layout_type
=
fpga
::
LAYOUT_HWC
;
args
.
output_layout_type
=
fpga
::
LAYOUT_CHW
;
args
.
input_data_type
=
fpga
::
DATA_TYPE_FP16
;
args
.
output_data_type
=
fpga
::
DATA_TYPE_FP32
;
args
.
image
.
address
=
input_ptr
;
args
.
image
.
height
=
(
input
->
dims
().
size
()
==
4
)
?
(
uint32_t
)
input
->
dims
()[
2
]
:
1
;
args
.
image
.
width
=
(
input
->
dims
().
size
()
==
4
)
?
(
uint32_t
)
input
->
dims
()[
3
]
:
1
;
args
.
image
.
channels
=
(
uint32_t
)
input
->
dims
()[
1
];
args
.
output
.
address
=
float_input
->
data
<
float
>
();
args
.
output
.
scale_address
=
float_input
->
scale
;
param
->
SetFloatInput
(
float_input
);
param
->
SetFpgaArgs
(
args
);
return
true
;
}
template
<
typename
T
>
T
Sigmoid
(
const
T
a
)
{
T
tmp
=
-
1.0
f
*
a
;
return
(
1.0
/
(
1.0
+
exp
(
tmp
)));
}
template
<
typename
T
>
void
sigmoidFuntor
(
Tensor
*
input
,
Tensor
*
output
)
{
auto
*
input_ptr
=
input
->
data
<
T
>
();
auto
*
output_ptr
=
output
->
mutable_data
<
T
>
();
for
(
int
i
=
0
;
i
<
input
->
numel
();
i
++
)
{
*
(
output_ptr
+
i
)
=
Sigmoid
<
T
>
(
*
(
input_ptr
+
i
));
}
}
template
<
>
void
SigmoidKernel
<
FPGA
,
float
>::
Compute
(
const
SigmoidParam
<
FPGA
>
&
param
)
{
Tensor
*
in_x
=
param
.
FloatInput
();
Tensor
*
out
=
param
.
Out
();
fpga
::
PerformBypass
(
param
.
FpgaArgs
());
fpga
::
fpga_invalidate
((
void
*
)
in_x
->
data
<
float
>
(),
// NOLINT
in_x
->
numel
()
*
sizeof
(
float
));
// TODO: In general case, 0 should be squeezed before softmax input // NOLINT
sigmoidFuntor
<
float
>
(
in_x
,
out
);
fpga
::
fpga_flush
(
out
->
data
<
float
>
(),
out
->
memory_size
());
}
}
// namespace operators
}
// namespace paddle_mobile
#endif
src/operators/op_param.h
浏览文件 @
d934df97
...
...
@@ -1078,6 +1078,20 @@ class SigmoidParam : public OpParam {
private:
RType
*
input_x_
;
RType
*
out_
;
#ifdef PADDLE_MOBILE_FPGA
private:
std
::
shared_ptr
<
RType
>
float_input_x_
;
fpga
::
BypassArgs
fpga_bypass_args
;
public:
RType
*
FloatInput
()
const
{
return
float_input_x_
==
nullptr
?
input_x_
:
float_input_x_
.
get
();
}
void
SetFloatInput
(
Tensor
*
input
)
{
float_input_x_
.
reset
(
input
);
}
const
fpga
::
BypassArgs
&
FpgaArgs
()
const
{
return
fpga_bypass_args
;
}
void
SetFpgaArgs
(
const
fpga
::
BypassArgs
&
args
)
{
fpga_bypass_args
=
args
;
}
#endif
};
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录