Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
f59e1b60
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看板
未验证
提交
f59e1b60
编写于
12月 20, 2019
作者:
X
xiebaiyuan
提交者:
GitHub
12月 20, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add multi-feeds ,test = develop (#2641)
上级
c1372bf9
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
919 addition
and
0 deletion
+919
-0
mobile/test/CMakeLists.txt
mobile/test/CMakeLists.txt
+4
-0
mobile/test/net/test_net_multi_feed.cpp
mobile/test/net/test_net_multi_feed.cpp
+219
-0
mobile/tools/python/fluidtools/.gitignore
mobile/tools/python/fluidtools/.gitignore
+1
-0
mobile/tools/python/fluidtools/run_multi_feed.py
mobile/tools/python/fluidtools/run_multi_feed.py
+695
-0
未找到文件。
mobile/test/CMakeLists.txt
浏览文件 @
f59e1b60
...
...
@@ -539,6 +539,10 @@ if (ENABLE_ALL_TEST)
ADD_EXECUTABLE
(
test-net net/test_net.cpp test_helper.h test_include.h executor_for_test.h
)
target_link_libraries
(
test-net paddle-mobile
)
# gen test
ADD_EXECUTABLE
(
test-net-feeds net/test_net_multi_feed.cpp test_helper.h test_include.h executor_for_test.h
)
target_link_libraries
(
test-net-feeds paddle-mobile
)
# gen test
ADD_EXECUTABLE
(
test-net-performance net/test_net_performance.cpp test_helper.h test_include.h executor_for_test.h
)
target_link_libraries
(
test-net-performance paddle-mobile
)
...
...
mobile/test/net/test_net_multi_feed.cpp
0 → 100644
浏览文件 @
f59e1b60
/* 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. */
#ifdef PADDLE_MOBILE_CL
#include <fstream>
#include <iostream>
#include <string>
#include "../test_helper.h"
#include "../test_include.h"
void
test
(
int
argc
,
char
*
argv
[]);
void
feed
(
PaddleMobile
<
paddle_mobile
::
GPU_CL
>
*
paddle_mobile
,
const
DDim
&
dims
,
std
::
string
feed_name
)
{
float
*
input_data_array
=
new
float
[
product
(
dims
)];
std
::
ifstream
in
(
feed_name
,
std
::
ios
::
in
);
for
(
int
i
=
0
;
i
<
product
(
dims
);
i
++
)
{
float
num
;
in
>>
num
;
input_data_array
[
i
]
=
num
;
}
in
.
close
();
framework
::
Tensor
input_tensor
(
input_data_array
,
dims
);
DLOG
<<
feed_name
<<
" : "
<<
input_tensor
;
paddle_mobile
->
Feed
(
feed_name
,
input_tensor
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
test
(
argc
,
argv
);
return
0
;
}
void
test
(
int
argc
,
char
*
argv
[])
{
int
arg_index
=
1
;
bool
fuse
=
std
::
stoi
(
argv
[
arg_index
])
==
1
;
arg_index
++
;
bool
enable_memory_optimization
=
std
::
stoi
(
argv
[
arg_index
])
==
1
;
arg_index
++
;
bool
quantification
=
std
::
stoi
(
argv
[
arg_index
])
==
1
;
arg_index
++
;
int
quantification_fold
=
std
::
stoi
(
argv
[
arg_index
]);
arg_index
++
;
paddle_mobile
::
PaddleMobileConfigInternal
config
;
config
.
memory_optimization_level
=
enable_memory_optimization
?
MemoryOptimizationWithoutFeeds
:
NoMemoryOptimization
;
#ifdef PADDLE_MOBILE_CL
// config.load_when_predict = true;
paddle_mobile
::
PaddleMobile
<
paddle_mobile
::
GPU_CL
>
paddle_mobile
(
config
);
paddle_mobile
.
SetCLPath
(
"/data/local/tmp/bin"
);
std
::
cout
<<
"testing opencl yyz "
<<
std
::
endl
;
#else
paddle_mobile
::
PaddleMobile
<
paddle_mobile
::
CPU
>
paddle_mobile
(
config
);
paddle_mobile
.
SetThreadNum
(
1
);
std
::
cout
<<
"testing cpu yyz "
<<
std
::
endl
;
#endif
int
dim_count
=
std
::
stoi
(
argv
[
arg_index
]);
arg_index
++
;
int
size
=
1
;
arg_index
+=
dim_count
;
bool
is_lod
=
std
::
stoi
(
argv
[
arg_index
])
==
1
;
arg_index
++
;
paddle_mobile
::
framework
::
LoD
lod
{{}};
if
(
is_lod
)
{
int
lod_count
=
std
::
stoi
(
argv
[
arg_index
]);
arg_index
++
;
for
(
int
i
=
0
;
i
<
lod_count
;
i
++
)
{
int
dim
=
std
::
stoi
(
argv
[
arg_index
+
i
]);
lod
[
0
].
push_back
(
dim
);
}
arg_index
+=
lod_count
;
}
int
var_count
=
std
::
stoi
(
argv
[
arg_index
]);
arg_index
++
;
bool
is_sample_step
=
std
::
stoi
(
argv
[
arg_index
])
==
1
;
arg_index
++
;
int
sample_arg
=
std
::
stoi
(
argv
[
arg_index
]);
int
sample_step
=
sample_arg
;
int
sample_num
=
sample_arg
;
arg_index
++
;
std
::
vector
<
std
::
string
>
var_names
;
for
(
int
i
=
0
;
i
<
var_count
;
i
++
)
{
std
::
string
var_name
=
argv
[
arg_index
+
i
];
var_names
.
push_back
(
var_name
);
}
arg_index
+=
var_count
;
bool
check_shape
=
std
::
stoi
(
argv
[
arg_index
])
==
1
;
arg_index
++
;
auto
time1
=
time
();
if
(
paddle_mobile
.
Load
(
"./checked_model/model"
,
"./checked_model/params"
,
fuse
,
quantification
,
1
,
is_lod
,
quantification_fold
))
{
auto
time2
=
time
();
std
::
cout
<<
"auto-test"
<<
" load-time-cost :"
<<
time_diff
(
time1
,
time2
)
<<
"ms"
<<
std
::
endl
;
feed
(
&
paddle_mobile
,
{
1
,
4
,
256
,
288
},
"input_rgb"
);
feed
(
&
paddle_mobile
,
{
1
,
128
,
64
,
72
},
"last_input"
);
feed
(
&
paddle_mobile
,
{
1
,
64
,
72
,
2
},
"grid"
);
feed
(
&
paddle_mobile
,
{
1
,
1
,
64
,
72
},
"reliable"
);
paddle_mobile
.
Predict
();
#ifdef PADDLE_MOBILE_CL
for
(
auto
var_name
:
var_names
)
{
auto
cl_image
=
paddle_mobile
.
FetchImage
(
var_name
);
if
(
cl_image
==
nullptr
||
cl_image
->
GetCLImage
()
==
nullptr
)
{
continue
;
}
auto
len
=
cl_image
->
numel
();
if
(
len
==
0
)
{
continue
;
}
size_t
width
=
cl_image
->
ImageDims
()[
0
];
size_t
height
=
cl_image
->
ImageDims
()[
1
];
paddle_mobile
::
framework
::
half_t
*
image_data
=
new
paddle_mobile
::
framework
::
half_t
[
height
*
width
*
4
];
cl_int
err
;
cl_mem
image
=
cl_image
->
GetCLImage
();
size_t
origin
[
3
]
=
{
0
,
0
,
0
};
size_t
region
[
3
]
=
{
width
,
height
,
1
};
err
=
clEnqueueReadImage
(
cl_image
->
CommandQueue
(),
image
,
CL_TRUE
,
origin
,
region
,
0
,
0
,
image_data
,
0
,
NULL
,
NULL
);
CL_CHECK_ERRORS
(
err
);
float
*
tensor_data
=
new
float
[
cl_image
->
numel
()];
auto
converter
=
cl_image
->
Converter
();
converter
->
ImageToNCHW
(
image_data
,
tensor_data
,
cl_image
->
ImageDims
(),
cl_image
->
dims
());
auto
data
=
tensor_data
;
std
::
string
sample
=
""
;
if
(
check_shape
)
{
for
(
int
i
=
0
;
i
<
cl_image
->
dims
().
size
();
i
++
)
{
sample
+=
" "
+
std
::
to_string
(
cl_image
->
dims
()[
i
]);
}
}
if
(
!
is_sample_step
)
{
sample_step
=
len
/
sample_num
;
}
if
(
sample_step
<=
0
)
{
sample_step
=
1
;
}
for
(
int
i
=
0
;
i
<
len
;
i
+=
sample_step
)
{
sample
+=
" "
+
std
::
to_string
(
data
[
i
]);
}
std
::
cout
<<
"auto-test"
<<
" var "
<<
var_name
<<
sample
<<
std
::
endl
;
}
#else
for
(
auto
var_name
:
var_names
)
{
auto
out
=
paddle_mobile
.
Fetch
(
var_name
);
auto
len
=
out
->
numel
();
if
(
len
==
0
)
{
continue
;
}
if
(
out
->
memory_size
()
==
0
)
{
continue
;
}
if
(
out
->
type
()
==
type_id
<
int
>
())
{
auto
data
=
out
->
data
<
int
>
();
std
::
string
sample
=
""
;
if
(
check_shape
)
{
for
(
int
i
=
0
;
i
<
out
->
dims
().
size
();
i
++
)
{
sample
+=
" "
+
std
::
to_string
(
out
->
dims
()[
i
]);
}
}
if
(
!
is_sample_step
)
{
sample_step
=
len
/
sample_num
;
}
if
(
sample_step
<=
0
)
{
sample_step
=
1
;
}
for
(
int
i
=
0
;
i
<
len
;
i
+=
sample_step
)
{
sample
+=
" "
+
std
::
to_string
(
data
[
i
]);
}
std
::
cout
<<
"auto-test"
<<
" var "
<<
var_name
<<
sample
<<
std
::
endl
;
}
else
if
(
out
->
type
()
==
type_id
<
float
>
())
{
auto
data
=
out
->
data
<
float
>
();
std
::
string
sample
=
""
;
if
(
check_shape
)
{
for
(
int
i
=
0
;
i
<
out
->
dims
().
size
();
i
++
)
{
sample
+=
" "
+
std
::
to_string
(
out
->
dims
()[
i
]);
}
}
if
(
!
is_sample_step
)
{
sample_step
=
len
/
sample_num
;
}
if
(
sample_step
<=
0
)
{
sample_step
=
1
;
}
for
(
int
i
=
0
;
i
<
len
;
i
+=
sample_step
)
{
sample
+=
" "
+
std
::
to_string
(
data
[
i
]);
}
std
::
cout
<<
"auto-test"
<<
" var "
<<
var_name
<<
sample
<<
std
::
endl
;
}
}
#endif
std
::
cout
<<
std
::
endl
;
}
}
#endif
mobile/tools/python/fluidtools/.gitignore
浏览文件 @
f59e1b60
...
...
@@ -3,3 +3,4 @@
!.gitignore
!/model-encrypt-tool
!test_wrap.py
!run_multi_feed.py
mobile/tools/python/fluidtools/run_multi_feed.py
0 → 100644
浏览文件 @
f59e1b60
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录