Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
6859850c
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看板
未验证
提交
6859850c
编写于
9月 11, 2018
作者:
C
Chon
提交者:
GitHub
9月 11, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #947 from chonwhite/develop
fix:
#946
上级
62e08a52
ccaae49f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
53 addition
and
39 deletion
+53
-39
src/fpga/api.cpp
src/fpga/api.cpp
+2
-2
src/fpga/api.h
src/fpga/api.h
+24
-20
src/operators/feed_op.h
src/operators/feed_op.h
+5
-2
src/operators/kernel/fpga/softmax_kernel.cpp
src/operators/kernel/fpga/softmax_kernel.cpp
+22
-15
未找到文件。
src/fpga/api.cpp
浏览文件 @
6859850c
...
...
@@ -145,8 +145,8 @@ int ComputeFpgaEWAdd(const struct EWAddArgs &args) {
}
int
PerformBypass
(
const
struct
BypassArgs
&
args
)
{
#ifdef FPGA_TEST_MODE
DLOG
<<
"
layout_type:"
<<
args
.
layout
_type
<<
"
convert_type:"
<<
args
.
conver
t_type
;
DLOG
<<
"
input_type:"
<<
args
.
input_data
_type
<<
"
input_layout_type:"
<<
args
.
input_layou
t_type
;
DLOG
<<
" image_address:"
<<
args
.
image
.
address
<<
" image_scale_address:"
<<
args
.
image
.
scale_address
<<
" image_channels:"
<<
args
.
image
.
channels
...
...
src/fpga/api.h
浏览文件 @
6859850c
...
...
@@ -25,23 +25,14 @@ limitations under the License. */
namespace
paddle_mobile
{
namespace
fpga
{
int
open_device
();
int
close_device
();
void
*
fpga_malloc
(
size_t
size
);
void
fpga_free
(
void
*
ptr
);
void
fpga_copy
(
void
*
dst
,
const
void
*
src
,
size_t
num
);
enum
DataConvertType
{
DATA_NO_CONVERT
=
0
,
DATA_FP32_TO_FP16
=
1
,
DATA_FP16_TO_FP32
=
2
,
enum
DataType
{
DATA_TYPE_FP32
=
1
,
DATA_TYPE_FP16
=
0
,
};
enum
LayoutConvertType
{
LAYOUT_NO_CONVERT
=
0
,
LAYOUT_CHW_TO_HWC
=
1
,
LAYOUT_HWC_TO_CHW
=
2
,
enum
LayoutType
{
LAYOUT_CHW
=
1
,
LAYOUT_HWC
=
0
,
};
struct
VersionArgs
{
...
...
@@ -83,7 +74,6 @@ struct ConvArgs {
bool
relu_enabled
;
void
*
sb_address
;
// scale and bias are interlaced;
void
*
filter_address
;
float
*
filter_scale_address
;
uint32_t
filter_num
;
uint32_t
group_num
;
...
...
@@ -122,16 +112,18 @@ struct PoolingArgs {
struct
EWAddArgs
{
bool
relu_enabled
;
floa
t
const0
;
// output0 = const0 x input0 + const1 x input1;
floa
t
const1
;
uint32_
t
const0
;
// output0 = const0 x input0 + const1 x input1;
uint32_
t
const1
;
struct
ImageInputArgs
image0
;
struct
ImageInputArgs
image1
;
struct
ImageOutputArgs
output
;
};
struct
BypassArgs
{
enum
DataConvertType
convert_type
;
enum
LayoutConvertType
layout_type
;
enum
DataType
input_data_type
;
enum
DataType
output_data_type
;
enum
LayoutType
input_layout_type
;
enum
LayoutType
output_layout_type
;
struct
ImageInputArgs
image
;
struct
ImageOutputArgs
output
;
};
...
...
@@ -141,6 +133,11 @@ struct FpgaRegWriteArgs {
uint64_t
value
;
};
struct
FpgaRegReadArgs
{
uint64_t
address
;
uint64_t
value
;
};
#define IOCTL_FPGA_MAGIC 'FPGA'
#define IOCTL_VERSION _IOW(IOCTL_FPGA_MAGIC, 01, struct VersionArgs)
...
...
@@ -184,6 +181,13 @@ enum FPGA_ERR_TYPE {
//============================== API =============================
int
open_device
();
int
close_device
();
void
*
fpga_malloc
(
size_t
size
);
void
fpga_free
(
void
*
ptr
);
void
fpga_copy
(
void
*
dst
,
const
void
*
src
,
size_t
num
);
int
PerformBypass
(
const
struct
BypassArgs
&
args
);
int
ComputeFpgaConv
(
const
struct
WrapperConvArgs
&
args
);
int
ComputeFpgaPool
(
const
struct
PoolingArgs
&
args
);
...
...
src/operators/feed_op.h
浏览文件 @
6859850c
...
...
@@ -56,8 +56,11 @@ class FeedOp : public framework::OperatorBase<DeviceType> {
auto
output_ptr
=
output
->
mutable_data
<
half
>
();
fpga
::
BypassArgs
args
;
args
.
convert_type
=
fpga
::
DATA_FP32_TO_FP16
;
args
.
layout_type
=
fpga
::
LAYOUT_NO_CONVERT
;
args
.
input_data_type
=
fpga
::
DATA_TYPE_FP32
;
args
.
output_data_type
=
fpga
::
DATA_TYPE_FP16
;
args
.
input_layout_type
=
fpga
::
LAYOUT_CHW
;
args
.
output_layout_type
=
fpga
::
LAYOUT_HWC
;
args
.
image
.
address
=
(
void
*
)
input_ptr
;
args
.
image
.
channels
=
input
->
dims
()[
1
];
args
.
image
.
height
=
input
->
dims
()[
2
];
...
...
src/operators/kernel/fpga/softmax_kernel.cpp
浏览文件 @
6859850c
...
...
@@ -25,27 +25,34 @@ namespace operators {
template
<
>
bool
SoftmaxKernel
<
FPGA
,
float
>::
Init
(
SoftmaxParam
<
FPGA
>
*
param
)
{
const
Tensor
*
input
=
param
->
InputX
();
auto
input_ptr
=
input
->
data
<
float
>
();
auto
output
=
param
->
Out
();
auto
output_ptr
=
output
->
mutable_data
<
float
>
();
fpga
::
BypassArgs
args
;
args
.
convert_type
=
fpga
::
DATA_FP16_TO_FP32
;
args
.
layout_type
=
fpga
::
LAYOUT_NO_CONVERT
;
args
.
image
.
address
=
(
void
*
)(
input_ptr
);
args
.
image
.
height
=
(
uint32_t
)
input
->
dims
()[
0
];
args
.
image
.
width
=
(
uint32_t
)
input
->
dims
()[
1
];
args
.
image
.
channels
=
1
;
args
.
output
.
address
=
output_ptr
;
param
->
SetFpgaArgs
(
args
);
if
(
input
->
type
()
==
typeid
(
half
))
{
auto
input_ptr
=
input
->
data
<
half
>
();
auto
output_ptr
=
param
->
Out
();
fpga
::
BypassArgs
args
;
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
=
(
void
*
)(
input_ptr
);
args
.
image
.
height
=
(
uint32_t
)
input
->
dims
()[
0
];
args
.
image
.
width
=
(
uint32_t
)
input
->
dims
()[
1
];
args
.
image
.
channels
=
1
;
args
.
output
.
address
=
output_ptr
;
param
->
SetFpgaArgs
(
args
);
}
return
true
;
}
template
<
>
void
SoftmaxKernel
<
FPGA
,
float
>::
Compute
(
const
SoftmaxParam
<
FPGA
>
&
param
)
const
{
// SoftmaxCompute<float>(param);
DLOG
<<
"======================================= FPGA SoftMAX "
"==============================================="
;
const
Tensor
*
in_x
=
param
.
InputX
();
Tensor
*
out
=
param
.
Out
();
auto
x_dims
=
in_x
->
dims
();
out
->
Resize
(
x_dims
);
math
::
SoftmaxFuntor
<
CPU
,
float
>
()(
in_x
,
out
);
}
template
class
SoftmaxKernel
<
FPGA
,
float
>;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录