Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
a8f851af
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看板
提交
a8f851af
编写于
10月 26, 2018
作者:
R
Ray Liu
提交者:
GitHub
10月 26, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1195 from Eclipsess/develop
fix
#1194
add test-eng(not all) and fix some op
上级
9e72b6e7
ddbcabed
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
70 addition
and
10 deletion
+70
-10
src/operators/kernel/arm/im2sequence_kernel.cpp
src/operators/kernel/arm/im2sequence_kernel.cpp
+13
-4
src/operators/kernel/central-arm-func/pool_arm_func.h
src/operators/kernel/central-arm-func/pool_arm_func.h
+1
-1
src/operators/math/im2col.cpp
src/operators/math/im2col.cpp
+2
-5
test/CMakeLists.txt
test/CMakeLists.txt
+4
-0
test/net/test_eng.cpp
test/net/test_eng.cpp
+50
-0
未找到文件。
src/operators/kernel/arm/im2sequence_kernel.cpp
浏览文件 @
a8f851af
...
...
@@ -35,7 +35,7 @@ template <>
void
Im2SequenceKernel
<
CPU
,
float
>::
Compute
(
const
Im2SequenceParam
<
CPU
>
&
param
)
const
{
const
Tensor
*
in_x
=
param
.
Input
();
Tensor
*
out
=
param
.
Output
();
framework
::
LoD
Tensor
*
out
=
param
.
Output
();
out
->
mutable_data
<
float
>
();
std
::
vector
<
int
>
kernels
=
param
.
Kernels
();
...
...
@@ -52,22 +52,31 @@ void Im2SequenceKernel<CPU, float>::Compute(
paddings
[
2
],
strides
[
0
]);
int
output_width
=
Im2SeqOutputSize
(
img_width
,
kernels
[
1
],
paddings
[
1
],
paddings
[
3
],
strides
[
1
]);
const
std
::
vector
<
int
>
dilations
({
1
,
1
});
out
->
mutable_data
<
float
>
({
batch_size
*
output_height
*
output_width
,
img_channels
*
kernels
[
0
]
*
kernels
[
1
]});
const
std
::
vector
<
int
>
dilations
({
1
,
1
});
// TODO: verify
auto
out_dims
=
out
->
dims
();
out
->
Resize
({
batch_size
,
out
->
numel
()
/
batch_size
});
for
(
int
i
=
0
;
i
<
batch_size
;
i
++
)
{
const
Tensor
src
=
in_x
->
Slice
(
i
,
i
+
1
).
Resize
({
img_channels
,
img_height
,
img_width
});
Tensor
dst
=
out
->
Slice
(
i
,
i
+
1
).
Resize
(
{
output_height
,
output_width
,
img_channels
,
kernels
[
0
],
kernels
[
1
]});
math
::
Im2ColFunctor
<
math
::
ColFormat
::
kOCF
,
CPU
,
float
>
f
;
f
(
src
,
dilations
,
strides
,
paddings
,
&
dst
);
}
out
->
Resize
(
out_dims
);
framework
::
LoD
lod
(
1
);
lod
[
0
].
reserve
(
batch_size
+
1
);
int
offset
=
0
;
lod
[
0
].
push_back
(
offset
);
for
(
int
i
=
0
;
i
<
batch_size
;
++
i
)
{
offset
+=
output_height
*
output_width
;
lod
[
0
].
push_back
(
offset
);
}
out
->
set_lod
(
lod
);
}
template
class
Im2SequenceKernel
<
CPU
,
float
>;
...
...
src/operators/kernel/central-arm-func/pool_arm_func.h
浏览文件 @
a8f851af
...
...
@@ -76,7 +76,7 @@ void PoolCompute(const PoolParam<CPU> ¶m) {
}
}
}
else
if
(
ksize
[
0
]
==
2
&&
ksize
[
0
]
==
ksize
[
1
]
&&
strides
[
0
]
==
2
&&
}
else
if
(
0
&&
ksize
[
0
]
==
2
&&
ksize
[
0
]
==
ksize
[
1
]
&&
strides
[
0
]
==
2
&&
strides
[
0
]
==
strides
[
1
]
&&
paddings
[
0
]
==
paddings
[
1
]
&&
paddings
[
1
]
==
0
)
{
#if __ARM_NEON
...
...
src/operators/math/im2col.cpp
浏览文件 @
a8f851af
...
...
@@ -53,7 +53,7 @@ void Im2ColFunctor<ColFormat::kCFO, CPU, float>::operator()(
(((
isize
-
2
*
padding
[
0
]
+
filter_height
)
%
stride
[
0
]
==
0
)
?
1
:
0
));
int
fill
=
isize
%
2
;
if
(
stride
[
0
]
==
1
&&
filter_height
==
3
&&
pad1
&&
pad2
&&
dilation
[
0
]
==
1
&&
im_height
>
2
)
{
dilation
[
0
]
==
1
&&
im_height
>
2
&&
im_height
==
im_width
)
{
for
(
int
c
=
0
;
c
<
im_channels
;
++
c
)
{
int
oosize
=
osize
*
osize
;
int
nk4
=
osize
/
4
;
...
...
@@ -225,7 +225,7 @@ void Im2ColFunctor<ColFormat::kCFO, CPU, float>::operator()(
im_data
+=
isize
*
isize
;
}
}
else
if
(
stride
[
0
]
==
2
&&
filter_height
==
3
&&
pad1
&&
dilation
[
0
]
==
1
&&
im_height
>
2
)
{
im_height
>
2
&&
im_height
==
im_width
)
{
for
(
int
c
=
0
;
c
<
im_channels
;
++
c
)
{
int
oosize
=
osize
*
osize
;
int
nk4
=
osize
/
4
;
...
...
@@ -605,7 +605,6 @@ class Im2ColFunctor<ColFormat::kOCF, CPU, T> {
const
T
*
im_data
=
im
.
data
<
T
>
();
T
*
col_data
=
col
->
data
<
T
>
();
for
(
int
col_row_idx
=
0
;
col_row_idx
<
col_height
;
++
col_row_idx
)
{
for
(
int
col_col_idx
=
0
;
col_col_idx
<
col_width
;
++
col_col_idx
)
{
for
(
int
channel
=
0
;
channel
<
im_channels
;
++
channel
)
{
...
...
@@ -617,7 +616,6 @@ class Im2ColFunctor<ColFormat::kOCF, CPU, T> {
++
filter_col_idx
)
{
int
im_col_offset
=
col_col_idx
*
stride
[
1
]
+
filter_col_idx
-
padding
[
1
];
int
col_offset
=
((((
col_row_idx
)
*
col_width
+
col_col_idx
)
*
im_channels
+
channel
)
*
...
...
@@ -625,7 +623,6 @@ class Im2ColFunctor<ColFormat::kOCF, CPU, T> {
filter_row_idx
)
*
filter_width
+
filter_col_idx
;
int
im_offset
=
(
channel
*
im_height
+
im_row_offset
)
*
im_width
+
im_col_offset
;
col_data
[
col_offset
]
=
...
...
test/CMakeLists.txt
浏览文件 @
a8f851af
...
...
@@ -347,6 +347,10 @@ if (NOT FOUND_MATCH)
ADD_EXECUTABLE
(
test-multi-process net/test_multi_inference_predict.cpp test_helper.h test_include.h
)
target_link_libraries
(
test-multi-process paddle-mobile
)
# gen test
ADD_EXECUTABLE
(
test-eng net/test_eng.cpp test_helper.h test_include.h
)
target_link_libraries
(
test-eng paddle-mobile
)
#add_library(test-lib-size SHARED common/test_lib_size.h common/test_lib_size.cpp)
endif
()
test/net/test_eng.cpp
0 → 100644
浏览文件 @
a8f851af
/* 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. */
#include <iostream>
#include "../test_helper.h"
#include "../test_include.h"
int
main
()
{
#ifdef PADDLE_MOBILE_CPU
paddle_mobile
::
PaddleMobile
<
paddle_mobile
::
CPU
>
paddle_mobile
;
#endif
// paddle_mobile.SetThreadNum(4);
auto
time1
=
time
();
if
(
paddle_mobile
.
Load
(
std
::
string
(
g_eng
)
+
"/model"
,
std
::
string
(
g_eng
)
+
"/params"
,
false
,
false
,
1
,
true
))
{
auto
time2
=
time
();
std
::
cout
<<
"load cost :"
<<
time_diff
(
time1
,
time1
)
<<
"ms"
<<
std
::
endl
;
std
::
vector
<
int64_t
>
dims
{
1
,
1
,
48
,
512
};
LoDTensor
input_tensor
;
SetupTensor
<
float
>
(
&
input_tensor
,
{
1
,
1
,
48
,
512
},
static_cast
<
float
>
(
0
),
static_cast
<
float
>
(
1
));
std
::
vector
<
float
>
input
(
input_tensor
.
data
<
float
>
(),
input_tensor
.
data
<
float
>
()
+
input_tensor
.
numel
());
// 预热十次
for
(
int
i
=
0
;
i
<
1
;
++
i
)
{
paddle_mobile
.
PredictLod
(
input_tensor
);
}
auto
time3
=
time
();
for
(
int
i
=
0
;
i
<
1
;
++
i
)
{
paddle_mobile
.
PredictLod
(
input_tensor
);
}
auto
time4
=
time
();
std
::
cout
<<
"predict cost :"
<<
time_diff
(
time3
,
time4
)
<<
"ms"
<<
std
::
endl
;
}
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录