Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
c52e6647
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看板
未验证
提交
c52e6647
编写于
8月 27, 2019
作者:
Y
Yanzhan Yang
提交者:
GitHub
8月 27, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix yolov3 test=develop (#1875)
上级
ebcefbba
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
107 addition
and
87 deletion
+107
-87
mobile/src/operators/kernel/cl/gen_code.py
mobile/src/operators/kernel/cl/gen_code.py
+96
-72
mobile/src/operators/slice_op.cpp
mobile/src/operators/slice_op.cpp
+7
-9
mobile/tools/build.sh
mobile/tools/build.sh
+4
-6
未找到文件。
mobile/src/operators/kernel/cl/gen_code.py
浏览文件 @
c52e6647
...
...
@@ -16,37 +16,38 @@ import re
import
os
import
sys
source
=
"""
#pragma
#ifdef PADDLE_MOBILE_CL
#include <map>
#include <string>
#include <vector>
namespace paddle_mobile {
def
gen_opencl_kernels
():
source
=
"""
#pragma
#ifdef PADDLE_MOBILE_CL
#include <map>
#include <string>
#include <vector>
namespace paddle_mobile {
extern const std::map<std::string, std::vector<unsigned char>> opencl_kernels = {
%s
%s
};
extern const std::vector<std::string> need_conv_header_kernels = {
%s
};
}
#endif
"""
}
#endif
"""
def
string_to_hex
(
str
):
def
string_to_hex
(
str
):
hex_list
=
[]
for
i
in
range
(
len
(
code_str
)):
hex_
=
hex
(
ord
(
code_str
[
i
]))
hex_list
.
append
(
hex_
)
return
hex_list
infile
=
open
(
"cl_kernel/cl_common.h"
,
"r"
)
common_content
=
infile
.
read
()
infile
.
close
()
common_content
=
re
.
sub
(
r
"/\*[^*]*\*/"
,
""
,
common_content
,
flags
=
re
.
DOTALL
)
lines
=
common_content
.
split
(
"
\n
"
)
new_lines
=
[]
for
i
in
range
(
len
(
lines
)):
infile
=
open
(
"cl_kernel/cl_common.h"
,
"r"
)
common_content
=
infile
.
read
()
infile
.
close
()
common_content
=
re
.
sub
(
r
"/\*[^*]*\*/"
,
""
,
common_content
,
flags
=
re
.
DOTALL
)
lines
=
common_content
.
split
(
"
\n
"
)
new_lines
=
[]
for
i
in
range
(
len
(
lines
)):
line
=
lines
[
i
]
line
=
line
.
strip
()
if
line
==
""
:
...
...
@@ -55,14 +56,14 @@ for i in range(len(lines)):
continue
line
=
re
.
sub
(
r
"//.*$"
,
""
,
line
)
new_lines
.
append
(
line
)
common_content
=
"
\n
"
.
join
(
new_lines
)
common_content
=
"
\n
"
.
join
(
new_lines
)
need_conv_header_kernels
=
[]
need_conv_header_kernels
=
[]
cores
=
""
filenames
=
os
.
listdir
(
"cl_kernel"
)
file_count
=
len
(
filenames
)
for
i
in
range
(
file_count
):
cores
=
""
filenames
=
os
.
listdir
(
"cl_kernel"
)
file_count
=
len
(
filenames
)
for
i
in
range
(
file_count
):
filename
=
filenames
[
i
]
infile
=
open
(
"cl_kernel/"
+
filename
,
"r"
)
new_lines
=
[]
...
...
@@ -99,5 +100,28 @@ for i in range(file_count):
core
+=
",
\n
"
cores
+=
core
source
=
source
%
(
cores
,
","
.
join
(
need_conv_header_kernels
))
print
(
source
)
source
=
source
%
(
cores
,
","
.
join
(
need_conv_header_kernels
))
print
(
source
)
def
gen_empty_opencl_kernels
():
source
=
"""
#pragma
#ifdef PADDLE_MOBILE_CL
#include <map>
#include <string>
#include <vector>
namespace paddle_mobile {
extern const std::map<std::string, std::vector<unsigned char>> opencl_kernels = {
};
extern const std::vector<std::string> need_conv_header_kernels = {
};
}
#endif
"""
print
(
source
)
if
__name__
==
"__main__"
:
if
sys
.
argv
[
1
]
==
"0"
:
gen_empty_opencl_kernels
()
elif
sys
.
argv
[
1
]
==
"1"
:
gen_opencl_kernels
()
mobile/src/operators/slice_op.cpp
浏览文件 @
c52e6647
...
...
@@ -15,7 +15,9 @@ limitations under the License. */
#ifdef SLICE_OP
#include "operators/slice_op.h"
#include <algorithm>
#include <vector>
namespace
paddle_mobile
{
namespace
operators
{
...
...
@@ -49,18 +51,12 @@ void SliceOp<Dtype, T>::InferShape() const {
PADDLE_MOBILE_ENFORCE
(
axes
.
size
()
==
1
,
"axes size should equals 1"
);
PADDLE_MOBILE_ENFORCE
(
input
->
dims
().
size
()
==
output
->
dims
().
size
(),
"input dim size should equals output dim size"
);
#ifdef PADDLE_MOBILE_CL
PADDLE_MOBILE_ENFORCE
(
in
put
->
dims
().
size
()
-
out
put
->
dims
().
size
()
-
(
axes
[
0
]
-
(
this
->
param_
.
original_output_dims_size_
-
this
->
param_
.
output_
->
dims
().
size
()))
==
3
,
"op only support slice channel now"
);
#endif
if
(
input
->
dims
().
size
()
>=
4
)
{
PADDLE_MOBILE_ENFORCE
(
input
->
dims
().
size
()
-
axes
[
0
]
==
3
,
"op only support slice channel now"
);
}
auto
starts
=
this
->
param_
.
starts_
;
auto
ends
=
this
->
param_
.
ends_
;
framework
::
DDim
out_dims
(
input
->
dims
());
...
...
@@ -70,7 +66,9 @@ void SliceOp<Dtype, T>::InferShape() const {
"axes.size should equal starts.size"
);
int
dim_value
,
start
,
end
;
for
(
size_t
i
=
0
;
i
<
axes
.
size
();
++
i
)
{
dim_value
=
out_dims
[
axes
[
i
]];
int
axis
=
axes
[
i
]
-
(
this
->
param_
.
original_output_dims_size_
-
this
->
param_
.
output_
->
dims
().
size
());
dim_value
=
out_dims
[
axis
];
if
(
dim_value
>
0
)
{
start
=
starts
[
i
]
<
0
?
(
starts
[
i
]
+
dim_value
)
:
starts
[
i
];
end
=
ends
[
i
]
<
0
?
(
ends
[
i
]
+
dim_value
)
:
ends
[
i
];
...
...
@@ -80,7 +78,7 @@ void SliceOp<Dtype, T>::InferShape() const {
end
=
std
::
min
(
end
,
dim_value
);
// start = std::min(start, end);
PADDLE_MOBILE_ENFORCE
(
end
>
start
,
"end should greater than start"
);
out_dims
[
ax
es
[
i
]
]
=
end
-
start
;
out_dims
[
ax
is
]
=
end
-
start
;
}
}
output
->
Resize
(
out_dims
);
...
...
mobile/tools/build.sh
浏览文件 @
c52e6647
...
...
@@ -3,13 +3,11 @@ NETS=""
declare
-a
supportedNets
=(
"googlenet"
"mobilenet"
"yolo"
"squeezenet"
"resnet"
"mobilenetssd"
"nlp"
"mobilenetfssd"
"genet"
"super"
"op"
)
# merge cl to so
merge_cl_to_so
=
1
merge_cl_to_so
=
0
rm
../src/operators/kernel/cl/opencl_kernels.cpp
if
[
$merge_cl_to_so
==
1
]
;
then
cd
../src/operators/kernel/cl
python gen_code.py
>
opencl_kernels.cpp
cd
-
fi
cd
../src/operators/kernel/cl
python gen_code.py
$merge_cl_to_so
>
opencl_kernels.cpp
cd
-
build_for_mac
()
{
if
[
!
`
which brew
`
]
;
then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录