Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
9ffafc4a
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看板
提交
9ffafc4a
编写于
8月 01, 2018
作者:
H
hanbuhe
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tensor added scale member
上级
ef62c1cc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
89 addition
and
54 deletion
+89
-54
src/fpga/api/fpga_api.h
src/fpga/api/fpga_api.h
+72
-53
src/framework/tensor.h
src/framework/tensor.h
+16
-0
src/operators/kernel/fpga/concat_kernel.cpp
src/operators/kernel/fpga/concat_kernel.cpp
+1
-1
未找到文件。
src/fpga/api/fpga_api.h
浏览文件 @
9ffafc4a
...
...
@@ -31,90 +31,109 @@ void* fpga_malloc(size_t size);
void
fpga_free
(
void
*
ptr
);
void
fpga_copy
(
void
*
dst
,
const
void
*
src
,
size_t
num
);
struct
FpgaVersionArgs
{
void
*
buf
;
};
struct
MemoryToPhysicalArgs
{
const
void
*
src
;
uint64_t
physical
;
struct
VersionArgs
{
void
*
buffer
;
};
struct
MemoryCopyArgs
{
void
*
src
;
void
*
dst
;
void
*
d
e
st
;
size_t
size
;
};
struct
FpgaQuantArgs
{
float
scale
;
};
struct
FpgaBNArgs
{
bool
enabled
=
false
;
void
*
bias_addr
;
void
*
scale_addr
;
struct
BNArgs
{
bool
enabled
;
void
*
bias_address
;
void
*
scale_address
;
};
struct
FpgaKernelArgs
{
/**
Conv and Pooling kernel
*/
struct
KernelArgs
{
uint32_t
width
;
uint32_t
height
;
uint32_t
stride_h
;
uint32_t
stride_w
;
uint32_t
stride_h
;
};
struct
FpgaImageArgs
{
uint32_t
width
;
uint32_t
height
;
struct
ImageInputArgs
{
void
*
address
;
// input featuremap virtual address
uint32_t
channels
;
uint32_t
pad_h
;
uint32_t
pad_w
;
uint32_t
width
;
// featuremap width
uint32_t
height
;
uint32_t
pad_width
;
// padding width;
uint32_t
pad_height
;
};
struct
ImageOutputArgs
{
void
*
address
;
// output result address;
float
*
scale_address
;
// output scale address;
};
struct
Fpga
ConvArgs
{
struct
ConvArgs
{
bool
relu_enabled
;
struct
FpgaBNArgs
BNargs
;
void
*
image_addr
;
void
*
filter_addr
;
void
*
bias_addr
;
void
*
output_addr
;
float
quant_scale
;
struct
FpgaImageArgs
image
;
float
scale
;
// input scale;
void
*
bias_address
;
void
*
filter_address
;
uint32_t
filter_num
;
uint32_t
group_num
;
struct
FpgaKernelArgs
kernel
;
struct
BNArgs
bn
;
struct
ImageInputArgs
image
;
// input image;
struct
KernelArgs
kernel
;
};
struct
FpgaPool
Args
{
void
*
image_addr
;
void
*
output_addr
;
struct
FpgaImageArgs
image
;
struct
Fpga
KernelArgs
kernel
;
struct
Pooling
Args
{
float
scale
;
struct
ImageInputArgs
image
;
// input image
;
struct
ImageOutputArgs
output
;
struct
KernelArgs
kernel
;
};
struct
FpgaEWAddArgs
{
// elementwise add arguments
struct
EWAddArgs
{
bool
relu_enabled
;
void
*
image0_addr
;
void
*
image1_addr
;
void
*
result_addr
;
uint32_t
const0
;
uint32_t
const1
;
uint32_t
data_len
;
// aligned element count
float
scale
;
float
const0
;
// output0 = const0 x input0 + const1 x input1;
float
const1
;
struct
ImageInputArgs
image0
;
struct
ImageInputArgs
image1
;
struct
ImageOutputArgs
output
;
};
struct
FpgaRegWriteArgs
{
uint64_t
address
;
//
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)
#define IOCTL_FPGA_REG_READ _IOW(IOCTL_FPGA_MAGIC, 02, struct FpgaRegReadArgs)
#define IOCTL_FPGA_REG_WRITE _IOW(IOCTL_FPGA_MAGIC, 03, struct FpgaRegWriteArgs)
#define IOCTL_SEPARATOR_0 10
#define IOCTL_MEM_COPY _IOW(IOCTL_FPGA_MAGIC, 11, struct MemoryCopyArgs)
#define IOCTL_SEPARATOR_1 20
#define IOCTL_CONFIG_CONV _IOW(IOCTL_FPGA_MAGIC, 21, struct ConvArgs)
#define IOCTL_CONFIG_POOLING _IOW(IOCTL_FPGA_MAGIC, 22, struct PoolingArgs)
#define IOCTL_CONFIG_EW _IOW(IOCTL_FPGA_MAGIC, 23, struct EWAddArgs)
//============================== API =============================
int
ComputeFpgaConv
(
struct
FpgaConvArgs
args
);
int
ComputeFpgaPool
(
struct
FpgaPoolArgs
args
);
int
ComputeFpgaEWAdd
(
struct
FpgaEWAddArgs
args
);
#define IOCTL_FPGA_MAGIC 'CNN'
#define IOCTL_VERSION _IOW(IOCTL_FPGA_MAGIC, 1, struct FpgaVersionArgs)
#define IOCTL_GET_QUANT _IOW(IOCTL_FPGA_MAGIC, 2, struct FpgaQuantArgs)
#define IOCTL_SET_QUANT _IOW(IOCTL_FPGA_MAGIC, 3, struct FpgaQuantArgs)
#define IOCTL_MEM_COPY _IOW(IOCTL_FPGA_MAGIC, 11, struct MemoryCopyArgs)
#define IOCTL_CONFIG_CONV _IOW(IOCTL_FPGA_MAGIC, 21, struct FpgaConvArgs)
#define IOCTL_CONFIG_POOLING _IOW(IOCTL_FPGA_MAGIC, 22, struct FpgaPoolArgs)
#define IOCTL_CONFIG_EW _IOW(IOCTL_FPGA_MAGIC, 23, struct FpgaEWAddArgs)
}
// namespace fpga
}
// namespace paddle_mobile
src/framework/tensor.h
浏览文件 @
9ffafc4a
...
...
@@ -253,6 +253,18 @@ class Tensor {
"Tensor's dims_ is out of bound. "
);
}
#ifdef PADDLE_MOBILE_FPGA
struct
FPGAArgs
{
float
scale
;
inline
float
*
scale_pointer
()
{
return
&
scale
;
}
};
struct
&
fpga_args
()
const
{
return
fpgaArgs_
;
}
#endif
private:
/**
* @note Placeholder hides type T, so it doesn't appear as a
...
...
@@ -319,6 +331,10 @@ class Tensor {
* begins.
*/
size_t
offset_
;
#ifdef PADDLE_MOBILE_FPGA
FPGAArgs
fpgaArgs_
;
#endif
};
#ifdef PADDLE_MOBILE_DEBUG
...
...
src/operators/kernel/fpga/concat_kernel.cpp
浏览文件 @
9ffafc4a
...
...
@@ -39,7 +39,7 @@ void ConcatKernel<FPGA, half>::Compute(const ConcatParam ¶m) const {
for
(
int
i
=
0
;
i
<
inputs
.
size
();
++
i
)
{
auto
input
=
inputs
[
i
];
auto
channels
=
input
[
3
];
auto
channels
=
input
->
dims
()
[
3
];
out_offset
+=
channels
;
auto
src
=
input
->
data
<
half
>
();
for
(
int
j
=
0
;
j
<
pixels
;
++
j
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录