Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
0720653b
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看板
提交
0720653b
编写于
9月 10, 2019
作者:
T
TianXiaogang
提交者:
Yan Chunwei
9月 10, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix fpga compile problem and kernels (#1989)
上级
019f5b8e
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
59 addition
and
25 deletion
+59
-25
.gitignore
.gitignore
+1
-0
lite/backends/fpga/KD/fpga_cv.cpp
lite/backends/fpga/KD/fpga_cv.cpp
+1
-3
lite/backends/fpga/KD/llapi/zynqmp_api.cpp
lite/backends/fpga/KD/llapi/zynqmp_api.cpp
+6
-2
lite/backends/fpga/KD/llapi/zynqmp_api.h
lite/backends/fpga/KD/llapi/zynqmp_api.h
+10
-0
lite/backends/fpga/lite_tensor.h
lite/backends/fpga/lite_tensor.h
+29
-2
lite/kernels/fpga/conv_compute.cc
lite/kernels/fpga/conv_compute.cc
+8
-3
lite/kernels/fpga/conv_compute.h
lite/kernels/fpga/conv_compute.h
+0
-3
lite/kernels/fpga/elementwise_compute.h
lite/kernels/fpga/elementwise_compute.h
+0
-6
lite/kernels/fpga/pooling_compute.cc
lite/kernels/fpga/pooling_compute.cc
+0
-3
lite/kernels/fpga/pooling_compute.h
lite/kernels/fpga/pooling_compute.h
+0
-2
lite/kernels/fpga/softmax_compute.cc
lite/kernels/fpga/softmax_compute.cc
+3
-1
lite/kernels/fpga/softmax_compute.h
lite/kernels/fpga/softmax_compute.h
+1
-0
未找到文件。
.gitignore
浏览文件 @
0720653b
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
.DS_Store
.DS_Store
build/
build/
build_fpga/
.idea/
.idea/
...
...
lite/backends/fpga/KD/fpga_cv.cpp
浏览文件 @
0720653b
...
@@ -23,9 +23,7 @@ void fpga_resize(float* input,
...
@@ -23,9 +23,7 @@ void fpga_resize(float* input,
uint8_t
*
output
,
uint8_t
*
output
,
int
output_width
,
int
output_width
,
int
output_height
)
{
int
output_height
)
{
paddle
::
zynqmp
::
InplaceArgs
inplace_args
=
{
paddle
::
zynqmp
::
InplaceArgs
inplace_args
=
{
0
,
0
,
0
};
.
relu_enable
=
0
,
.
power_enable
=
0
,
};
paddle
::
zynqmp
::
config_inplace
(
inplace_args
);
paddle
::
zynqmp
::
config_inplace
(
inplace_args
);
paddle
::
zynqmp
::
ImageInputArgs
input_args
=
{
nullptr
};
paddle
::
zynqmp
::
ImageInputArgs
input_args
=
{
nullptr
};
...
...
lite/backends/fpga/KD/llapi/zynqmp_api.cpp
浏览文件 @
0720653b
...
@@ -39,10 +39,14 @@ static size_t memory_size_max = 0;
...
@@ -39,10 +39,14 @@ static size_t memory_size_max = 0;
static
size_t
memory_size
=
0
;
static
size_t
memory_size
=
0
;
static
inline
int
do_ioctl
(
uint64_t
req
,
const
void
*
arg
)
{
static
inline
int
do_ioctl
(
uint64_t
req
,
const
void
*
arg
)
{
int
ret
=
-
1
;
#ifdef PADDLE_LITE_OS_LINUX
#ifdef PADDLE_LITE_OS_LINUX
return
ioctl
(
fd
,
req
,
arg
);
ret
=
ioctl
(
fd
,
req
,
arg
);
if
(
ret
!=
0
)
{
throw
-
1
;
}
#else
#else
return
-
1
;
return
ret
;
#endif
#endif
}
}
...
...
lite/backends/fpga/KD/llapi/zynqmp_api.h
浏览文件 @
0720653b
...
@@ -46,6 +46,15 @@ struct VersionArgs {
...
@@ -46,6 +46,15 @@ struct VersionArgs {
struct
DeviceInfo
{
struct
DeviceInfo
{
uint32_t
filter_cap
;
uint32_t
filter_cap
;
uint32_t
version
;
uint16_t
device_type
;
uint32_t
reserved0
;
uint32_t
reserved1
;
uint32_t
reserved2
;
uint32_t
reserved3
;
uint32_t
reserved4
;
uint32_t
reserved5
;
uint32_t
reserved6
;
};
};
struct
MemoryCopyArgs
{
struct
MemoryCopyArgs
{
...
@@ -191,6 +200,7 @@ struct NormalizeParameterArgs {
...
@@ -191,6 +200,7 @@ struct NormalizeParameterArgs {
};
};
struct
InplaceArgs
{
struct
InplaceArgs
{
bool
leaky_relu_enable
;
bool
relu_enable
;
bool
relu_enable
;
bool
power_enable
;
bool
power_enable
;
bool
normalize_enable
;
bool
normalize_enable
;
...
...
lite/backends/fpga/lite_tensor.h
浏览文件 @
0720653b
...
@@ -57,7 +57,7 @@ class DDimLite {
...
@@ -57,7 +57,7 @@ class DDimLite {
DDimLite
Slice
(
int
start
,
int
end
)
const
;
DDimLite
Slice
(
int
start
,
int
end
)
const
;
DDimLite
Flatte
r
n2D
(
int
col
)
const
{
DDimLite
Flatten2D
(
int
col
)
const
{
return
DDimLite
(
std
::
vector
<
value_type
>
(
return
DDimLite
(
std
::
vector
<
value_type
>
(
{
Slice
(
0
,
col
).
production
(),
Slice
(
col
,
size
()).
production
()}));
{
Slice
(
0
,
col
).
production
(),
Slice
(
col
,
size
()).
production
()}));
}
}
...
@@ -118,6 +118,13 @@ class TensorLite {
...
@@ -118,6 +118,13 @@ class TensorLite {
const
LoD
&
lod
()
const
{
return
lod_
;
}
const
LoD
&
lod
()
const
{
return
lod_
;
}
LoD
*
mutable_lod
()
{
return
&
lod_
;
}
LoD
*
mutable_lod
()
{
return
&
lod_
;
}
void
set_lod
(
const
LoD
&
lod
)
{
lod_
=
lod
;
}
PrecisionType
precision
()
const
{
return
precision_
;
}
void
set_precision
(
PrecisionType
precision
)
{
precision_
=
precision
;
}
bool
persistable
()
const
{
return
persistable_
;
}
void
set_persistable
(
bool
persistable
)
{
persistable_
=
persistable
;
}
// T is the data type and R is the return type
// T is the data type and R is the return type
// For OpenCL, the return type can be cl::Buffer
// For OpenCL, the return type can be cl::Buffer
// and the data type can be float/int8_t.
// and the data type can be float/int8_t.
...
@@ -147,6 +154,9 @@ class TensorLite {
...
@@ -147,6 +154,9 @@ class TensorLite {
void
CopyDataFrom
(
const
TensorLite
&
other
);
void
CopyDataFrom
(
const
TensorLite
&
other
);
template
<
typename
T
>
TensorLite
Slice
(
int64_t
begin
,
int64_t
end
)
const
;
TargetType
target
()
const
{
return
target_
;
}
TargetType
target
()
const
{
return
target_
;
}
zynqmp
::
Tensor
*
ZynqTensor
()
const
{
return
zynq_tensor_
;
}
zynqmp
::
Tensor
*
ZynqTensor
()
const
{
return
zynq_tensor_
;
}
...
@@ -168,6 +178,11 @@ class TensorLite {
...
@@ -168,6 +178,11 @@ class TensorLite {
LoD
lod_
;
LoD
lod_
;
size_t
memory_size_
{};
size_t
memory_size_
{};
size_t
offset_
{
0
};
PrecisionType
precision_
{
PrecisionType
::
kUnk
};
bool
persistable_
{
false
};
zynqmp
::
Tensor
*
zynq_tensor_
=
new
zynqmp
::
Tensor
();
zynqmp
::
Tensor
*
zynq_tensor_
=
new
zynqmp
::
Tensor
();
template
<
typename
T
>
template
<
typename
T
>
...
@@ -219,6 +234,18 @@ bool TensorCompareWith(const TensorT &a, const TensorT &b) {
...
@@ -219,6 +234,18 @@ bool TensorCompareWith(const TensorT &a, const TensorT &b) {
if
(
memcmp
(
a
.
raw_data
(),
b
.
raw_data
(),
a
.
data_size
())
!=
0
)
return
false
;
if
(
memcmp
(
a
.
raw_data
(),
b
.
raw_data
(),
a
.
data_size
())
!=
0
)
return
false
;
return
true
;
return
true
;
}
}
template
<
typename
T
>
TensorLite
TensorLite
::
Slice
(
int64_t
begin
,
int64_t
end
)
const
{
int64_t
base
=
numel
()
/
dims_
[
0
];
TensorLite
dst
;
dst
.
buffer_
=
buffer_
;
dst
.
target_
=
target_
;
auto
dst_dims
=
dims_
;
dst_dims
[
0
]
=
end
-
begin
;
dst
.
Resize
(
dst_dims
);
dst
.
offset_
=
offset_
+
static_cast
<
size_t
>
(
begin
*
base
)
*
sizeof
(
T
);
return
dst
;
}
}
// namespace lite
}
// namespace lite
}
// namespace paddle
}
// namespace paddle
lite/kernels/fpga/conv_compute.cc
浏览文件 @
0720653b
...
@@ -28,10 +28,9 @@ void ConvCompute::PrepareForRun() {
...
@@ -28,10 +28,9 @@ void ConvCompute::PrepareForRun() {
// ====================================================
// ====================================================
zynqmp
::
ConvParam
&
conv_param
=
pe_
.
param
();
zynqmp
::
ConvParam
&
conv_param
=
pe_
.
param
();
param
.
output
->
mutable_data
<
float16
>
();
param
.
output
->
mutable_data
<
float16
>
();
filter_
.
setDataType
(
zynqmp
::
FP32
);
//
filter_.setDataType(zynqmp::FP32);
conv_param
.
input
=
param
.
x
->
ZynqTensor
();
conv_param
.
input
=
param
.
x
->
ZynqTensor
();
conv_param
.
output
=
param
.
output
->
ZynqTensor
();
conv_param
.
output
=
param
.
output
->
ZynqTensor
();
conv_param
.
filter
=
param
.
filter
->
ZynqTensor
();
conv_param
.
filter
=
param
.
filter
->
ZynqTensor
();
...
@@ -40,11 +39,17 @@ void ConvCompute::PrepareForRun() {
...
@@ -40,11 +39,17 @@ void ConvCompute::PrepareForRun() {
conv_param
.
paddings
=
param
.
paddings
;
conv_param
.
paddings
=
param
.
paddings
;
conv_param
.
dilations
=
param
.
dilations
;
conv_param
.
dilations
=
param
.
dilations
;
fill_scale_bias_const
(
&
conv_param
);
fill_scale_bias_const
(
&
conv_param
);
conv_param
.
bias
()
->
copyFrom
(
param
.
bias
->
ZynqTensor
());
conv_param
.
relu
.
enabled
=
param
.
fuse_relu
;
pe_
.
init
();
pe_
.
init
();
pe_
.
apply
();
pe_
.
apply
();
}
}
void
ConvCompute
::
Run
()
{
pe_
.
dispatch
();
}
void
ConvCompute
::
Run
()
{
auto
&
param
=
this
->
Param
<
param_t
>
();
zynqmp
::
ConvParam
&
conv_param
=
pe_
.
param
();
pe_
.
dispatch
();
}
}
// namespace fpga
}
// namespace fpga
}
// namespace kernels
}
// namespace kernels
...
...
lite/kernels/fpga/conv_compute.h
浏览文件 @
0720653b
...
@@ -37,9 +37,6 @@ class ConvCompute
...
@@ -37,9 +37,6 @@ class ConvCompute
private:
private:
zynqmp
::
ConvPE
pe_
;
zynqmp
::
ConvPE
pe_
;
zynqmp
::
Tensor
input_
;
zynqmp
::
Tensor
output_
;
zynqmp
::
Tensor
filter_
;
};
};
}
// namespace fpga
}
// namespace fpga
...
...
lite/kernels/fpga/elementwise_compute.h
浏览文件 @
0720653b
...
@@ -36,9 +36,6 @@ class ElementwiseAddCompute
...
@@ -36,9 +36,6 @@ class ElementwiseAddCompute
private:
private:
zynqmp
::
ElementwiseAddPE
pe_
;
zynqmp
::
ElementwiseAddPE
pe_
;
zynqmp
::
Tensor
input_x_
;
zynqmp
::
Tensor
input_y_
;
zynqmp
::
Tensor
output_
;
};
};
class
ElementwiseAddActivationCompute
class
ElementwiseAddActivationCompute
...
@@ -51,9 +48,6 @@ class ElementwiseAddActivationCompute
...
@@ -51,9 +48,6 @@ class ElementwiseAddActivationCompute
private:
private:
zynqmp
::
ElementwiseAddPE
pe_
;
zynqmp
::
ElementwiseAddPE
pe_
;
zynqmp
::
Tensor
input_x_
;
zynqmp
::
Tensor
input_y_
;
zynqmp
::
Tensor
output_
;
};
};
}
// namespace fpga
}
// namespace fpga
...
...
lite/kernels/fpga/pooling_compute.cc
浏览文件 @
0720653b
...
@@ -35,9 +35,6 @@ void PoolCompute::PrepareForRun() {
...
@@ -35,9 +35,6 @@ void PoolCompute::PrepareForRun() {
pool_param
.
output
=
param
.
output
->
ZynqTensor
();
pool_param
.
output
=
param
.
output
->
ZynqTensor
();
pool_param
.
relu
.
enabled
=
false
;
pool_param
.
relu
.
enabled
=
false
;
auto
&
in_dims
=
param
.
x
->
dims
();
auto
&
out_dims
=
param
.
output
->
dims
();
pool_param
.
type
=
param
.
pooling_type
==
"max"
?
zynqmp
::
PoolingType
::
MAX
pool_param
.
type
=
param
.
pooling_type
==
"max"
?
zynqmp
::
PoolingType
::
MAX
:
zynqmp
::
PoolingType
::
AVERAGE
;
:
zynqmp
::
PoolingType
::
AVERAGE
;
pool_param
.
globalPooling
=
param
.
global_pooling
;
pool_param
.
globalPooling
=
param
.
global_pooling
;
...
...
lite/kernels/fpga/pooling_compute.h
浏览文件 @
0720653b
...
@@ -36,8 +36,6 @@ class PoolCompute
...
@@ -36,8 +36,6 @@ class PoolCompute
private:
private:
zynqmp
::
PoolingPE
pe_
;
zynqmp
::
PoolingPE
pe_
;
zynqmp
::
Tensor
input_
;
zynqmp
::
Tensor
output_
;
};
};
}
// namespace fpga
}
// namespace fpga
...
...
lite/kernels/fpga/softmax_compute.cc
浏览文件 @
0720653b
...
@@ -22,7 +22,7 @@ namespace fpga {
...
@@ -22,7 +22,7 @@ namespace fpga {
using
float16
=
zynqmp
::
float16
;
using
float16
=
zynqmp
::
float16
;
void
SoftmaxCompute
::
Run
()
{
void
SoftmaxCompute
::
PrepareFor
Run
()
{
zynqmp
::
SoftmaxParam
&
softmax_param
=
pe_
.
param
();
zynqmp
::
SoftmaxParam
&
softmax_param
=
pe_
.
param
();
auto
&
param
=
Param
<
operators
::
SoftmaxParam
>
();
auto
&
param
=
Param
<
operators
::
SoftmaxParam
>
();
...
@@ -33,6 +33,8 @@ void SoftmaxCompute::Run() {
...
@@ -33,6 +33,8 @@ void SoftmaxCompute::Run() {
pe_
.
apply
();
pe_
.
apply
();
}
}
void
SoftmaxCompute
::
Run
()
{
pe_
.
dispatch
();
}
}
// namespace fpga
}
// namespace fpga
}
// namespace kernels
}
// namespace kernels
}
// namespace lite
}
// namespace lite
...
...
lite/kernels/fpga/softmax_compute.h
浏览文件 @
0720653b
...
@@ -29,6 +29,7 @@ using float16 = zynqmp::float16;
...
@@ -29,6 +29,7 @@ using float16 = zynqmp::float16;
class
SoftmaxCompute
class
SoftmaxCompute
:
public
KernelLite
<
TARGET
(
kFPGA
),
PRECISION
(
kFP16
),
DATALAYOUT
(
kNHWC
)
>
{
:
public
KernelLite
<
TARGET
(
kFPGA
),
PRECISION
(
kFP16
),
DATALAYOUT
(
kNHWC
)
>
{
public:
public:
void
PrepareForRun
()
override
;
void
Run
()
override
;
void
Run
()
override
;
virtual
~
SoftmaxCompute
()
=
default
;
virtual
~
SoftmaxCompute
()
=
default
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录