Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
15d4872b
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看板
提交
15d4872b
编写于
9月 03, 2018
作者:
Z
zhangyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
format code
上级
97b7c913
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
85 addition
and
102 deletion
+85
-102
src/fpga/bias_scale.cpp
src/fpga/bias_scale.cpp
+47
-42
src/fpga/bias_scale.h
src/fpga/bias_scale.h
+4
-6
src/fpga/filter.cpp
src/fpga/filter.cpp
+15
-36
src/fpga/filter.h
src/fpga/filter.h
+17
-16
src/fpga/image.cpp
src/fpga/image.cpp
+1
-1
src/fpga/image.h
src/fpga/image.h
+1
-1
未找到文件。
src/fpga/bias_scale.cpp
浏览文件 @
15d4872b
...
...
@@ -12,49 +12,54 @@ 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. */
#include <memory.h>
#include "bias_scale.h"
#include <memory.h>
#include "api.h"
namespace
paddle_mobile
{
namespace
fpga
{
namespace
bias_scale
{
void
align_element
(
float
**
data_in
,
int
num_per_div_before_alignment
,
int
num
){
float
*
ptr_unaligned
=
*
data_in
;
int
div_num
=
(
num
+
num_per_div_before_alignment
-
1
)
/
num_per_div_before_alignment
;
int
num_per_div_after_alignment
=
align_to_x
(
num_per_div_before_alignment
,
BS_NUM_ALIGNMENT
);
int
num_element
=
2
*
div_num
*
num_per_div_after_alignment
;
//including bias & scale
float
*
ptr_aligned
=
(
float
*
)
fpga_malloc
(
num_element
*
sizeof
(
float
));
memset
(
ptr_aligned
,
0
,
num_element
*
sizeof
(
float
));
for
(
int
i
=
0
;
i
<
div_num
;
i
++
){
memcpy
(
ptr_aligned
+
i
*
num_per_div_after_alignment
,
ptr_unaligned
,
num_per_div_before_alignment
);
}
fpga_free
(
ptr_unaligned
);
*
data_in
=
ptr_aligned
;
}
void
interleave
(
float
**
data_in
,
int
num_after_alignment
){
//num_after_alignment: number of bias after alignment
float
*
ptr_uninterleaved
=
*
data_in
;
float
*
ptr_interleaved
=
(
float
*
)
fpga_malloc
(
2
*
num_after_alignment
*
sizeof
(
float
));
int
num
=
num_after_alignment
/
4
;
for
(
int
i
=
0
;
i
<
num
;
i
++
){
memcpy
(
ptr_interleaved
+
8
*
i
,
ptr_uninterleaved
+
4
*
i
,
4
*
sizeof
(
float
));
memcpy
(
ptr_interleaved
+
8
*
i
+
4
,
ptr_uninterleaved
+
num_after_alignment
*
sizeof
(
float
)
+
4
*
i
,
4
*
sizeof
(
float
));
}
fpga_free
(
ptr_uninterleaved
);
*
data_in
=
ptr_interleaved
;
}
}
// namespace bias_scale
}
// namespace fpga
}
// namespace paddle_mobile
\ No newline at end of file
namespace
fpga
{
namespace
bias_scale
{
void
align_element
(
float
**
data_in
,
int
num_per_div_before_alignment
,
int
num
)
{
float
*
ptr_unaligned
=
*
data_in
;
int
div_num
=
(
num
+
num_per_div_before_alignment
-
1
)
/
num_per_div_before_alignment
;
int
num_per_div_after_alignment
=
align_to_x
(
num_per_div_before_alignment
,
BS_NUM_ALIGNMENT
);
int
num_element
=
2
*
div_num
*
num_per_div_after_alignment
;
// including bias & scale
float
*
ptr_aligned
=
(
float
*
)
fpga_malloc
(
num_element
*
sizeof
(
float
));
memset
(
ptr_aligned
,
0
,
num_element
*
sizeof
(
float
));
for
(
int
i
=
0
;
i
<
div_num
;
i
++
)
{
memcpy
(
ptr_aligned
+
i
*
num_per_div_after_alignment
,
ptr_unaligned
,
num_per_div_before_alignment
*
sizeof
(
float
));
}
fpga_free
(
ptr_unaligned
);
*
data_in
=
ptr_aligned
;
}
void
interleave
(
float
**
data_in
,
int
num_after_alignment
)
{
// num_after_alignment: number of bias after alignment
float
*
ptr_uninterleaved
=
*
data_in
;
float
*
ptr_interleaved
=
(
float
*
)
fpga_malloc
(
2
*
num_after_alignment
*
sizeof
(
float
));
int
num
=
num_after_alignment
/
4
;
for
(
int
i
=
0
;
i
<
num
;
i
++
)
{
memcpy
(
ptr_interleaved
+
8
*
i
,
ptr_uninterleaved
+
4
*
i
,
4
*
sizeof
(
float
));
memcpy
(
ptr_interleaved
+
8
*
i
+
4
,
ptr_uninterleaved
+
num_after_alignment
*
sizeof
(
float
)
+
4
*
i
,
4
*
sizeof
(
float
));
}
fpga_free
(
ptr_uninterleaved
);
*
data_in
=
ptr_interleaved
;
}
}
// namespace bias_scale
}
// namespace fpga
}
// namespace paddle_mobile
src/fpga/bias_scale.h
浏览文件 @
15d4872b
...
...
@@ -14,17 +14,15 @@ limitations under the License. */
#pragma once
#define BS_NUM_ALIGNMENT 8
namespace
paddle_mobile
{
namespace
fpga
{
namespace
bias_scale
{
void
align_element
(
float
**
data_in
,
int
num_per_div_before_alignment
,
int
num
);
void
interleave
(
float
**
data_in
,
int
num_after_alignment
);
namespace
bias_scale
{
void
align_element
(
float
**
data_in
,
int
num_per_div_before_alignment
,
int
num
);
void
interleave
(
float
**
data_in
,
int
num_after_alignment
);
}
// namespace bias_scale
}
// namespace fpga
}
// namespace paddle_mobile
\ No newline at end of file
}
// namespace paddle_mobile
src/fpga/filter.cpp
浏览文件 @
15d4872b
...
...
@@ -11,51 +11,30 @@ 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. */
#include <memory.h>
#include "filter.h"
#include <memory.h>
#include "api.h"
namespace
paddle_mobile
{
namespace
fpga
{
namespace
filter
{
void
convert_to_hwc
(
float
**
data_in
,
int
num
,
int
channel
,
int
height
,
int
width
){
}
float
find_max
(
float
*
data_in
,
int
num
){
return
0
;
}
void
quantize
(
float
*
data_in
,
int
num
){
}
void
align_element
(
float
**
data_in
,
int
num
,
int
chw
){
}
void
align_num
(
float
**
data_in
,
int
num_per_div_before_alignment
,
int
num
,
int
chw
){
namespace
fpga
{
namespace
filter
{
}
void
convert_to_hwc
(
float
**
data_in
,
int
num
,
int
channel
,
int
height
,
int
width
)
{}
float
find_max
(
float
*
data_in
,
int
num
)
{
return
0
;
}
void
reorder
(
float
**
data_in
,
int
num_after_alignment
,
int
chw
){
void
quantize
(
float
*
data_in
,
int
num
)
{}
}
void
align_element
(
float
**
data_in
,
int
num
,
int
chw
)
{
}
void
align_num
(
float
**
data_in
,
int
num_per_div_before_alignment
,
int
num
,
int
chw
)
{}
void
interleave
(
float
**
data_in
,
int
num_after_alignment
,
int
chw
){
void
reorder
(
float
**
data_in
,
int
num_after_alignment
,
int
chw
)
{}
}
void
interleave
(
float
**
data_in
,
int
num_after_alignment
,
int
chw
)
{
}
}
// namespace filter
}
// namespace fpga
}
// namespace paddle_mobile
\ No newline at end of file
}
// namespace filter
}
// namespace fpga
}
// namespace paddle_mobile
src/fpga/filter.h
浏览文件 @
15d4872b
...
...
@@ -14,21 +14,22 @@ limitations under the License. */
#pragma once
#define FILTER_NUM_ALIGNMENT 32 //Filter number aligned to 32
#define FILTER_ELEMENT_ALIGNMENT 16 //Filter element number aligned to 16
#define FILTER_NUM_ALIGNMENT 32 // Filter number aligned to 32
#define FILTER_ELEMENT_ALIGNMENT 16 // Filter element number aligned to 16
namespace
paddle_mobile
{
namespace
fpga
{
namespace
filter
{
void
convert_to_hwc
(
float
**
data_in
,
int
num
,
int
channel
,
int
height
,
int
width
);
float
find_max
(
float
*
data_in
,
int
num
);
void
quantize
(
float
*
data_in
,
int
num
);
void
align_element
(
float
**
data_in
,
int
num
,
int
chw
);
void
align_num
(
float
**
data_in
,
int
num_per_div_before_alignment
,
int
num
,
int
chw
);
void
reorder
(
float
**
data_in
,
int
num_after_alignment
,
int
chw
);
void
interleave
(
float
**
data_in
,
int
num_after_alignment
,
int
chw
);
}
// namespace filter
}
// namespace fpga
}
// namespace paddle_mobile
\ No newline at end of file
namespace
fpga
{
namespace
filter
{
void
convert_to_hwc
(
float
**
data_in
,
int
num
,
int
channel
,
int
height
,
int
width
);
float
find_max
(
float
*
data_in
,
int
num
);
void
quantize
(
float
*
data_in
,
int
num
);
void
align_element
(
float
**
data_in
,
int
num
,
int
chw
);
void
align_num
(
float
**
data_in
,
int
num_per_div_before_alignment
,
int
num
,
int
chw
);
void
reorder
(
float
**
data_in
,
int
num_after_alignment
,
int
chw
);
void
interleave
(
float
**
data_in
,
int
num_after_alignment
,
int
chw
);
}
// namespace filter
}
// namespace fpga
}
// namespace paddle_mobile
src/fpga/image.cpp
浏览文件 @
15d4872b
...
...
@@ -10,4 +10,4 @@ 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. */
\ No newline at end of file
limitations under the License. */
src/fpga/image.h
浏览文件 @
15d4872b
...
...
@@ -10,4 +10,4 @@ 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. */
\ No newline at end of file
limitations under the License. */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录