Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
45fa14f5
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2305
Star
20932
Fork
5423
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
45fa14f5
编写于
8月 03, 2021
作者:
P
Peihan
提交者:
GitHub
8月 03, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add trt fp32 multi-thread tests (#34575)
上级
d7493df2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
45 addition
and
1 deletion
+45
-1
paddle/fluid/inference/tests/infer_ut/test_resnet50.cc
paddle/fluid/inference/tests/infer_ut/test_resnet50.cc
+43
-0
paddle/fluid/inference/tests/infer_ut/test_suite.h
paddle/fluid/inference/tests/infer_ut/test_suite.h
+2
-1
未找到文件。
paddle/fluid/inference/tests/infer_ut/test_resnet50.cc
浏览文件 @
45fa14f5
...
...
@@ -127,6 +127,49 @@ TEST(test_resnet50, serial_diff_batch_trt_fp32) {
std
::
cout
<<
"finish test"
<<
std
::
endl
;
}
TEST
(
test_resnet50
,
multi_thread4_trt_fp32_bz2
)
{
int
thread_num
=
4
;
// init input data
std
::
map
<
std
::
string
,
paddle
::
test
::
Record
>
my_input_data_map
;
my_input_data_map
[
"inputs"
]
=
PrepareInput
(
2
);
// init output data
std
::
map
<
std
::
string
,
paddle
::
test
::
Record
>
infer_output_data
,
truth_output_data
;
// prepare groudtruth config
paddle_infer
::
Config
config
,
config_no_ir
;
config_no_ir
.
SetModel
(
FLAGS_modeldir
+
"/inference.pdmodel"
,
FLAGS_modeldir
+
"/inference.pdiparams"
);
config_no_ir
.
SwitchIrOptim
(
false
);
// prepare inference config
config
.
SetModel
(
FLAGS_modeldir
+
"/inference.pdmodel"
,
FLAGS_modeldir
+
"/inference.pdiparams"
);
config
.
EnableUseGpu
(
100
,
0
);
config
.
EnableTensorRtEngine
(
1
<<
20
,
2
,
3
,
paddle_infer
::
PrecisionType
::
kFloat32
,
false
,
false
);
// get groudtruth by disbale ir
paddle_infer
::
services
::
PredictorPool
pred_pool_no_ir
(
config_no_ir
,
1
);
SingleThreadPrediction
(
pred_pool_no_ir
.
Retrive
(
0
),
&
my_input_data_map
,
&
truth_output_data
,
1
);
// get infer results from multi threads
std
::
vector
<
std
::
thread
>
threads
;
services
::
PredictorPool
pred_pool
(
config
,
thread_num
);
for
(
int
i
=
0
;
i
<
thread_num
;
++
i
)
{
threads
.
emplace_back
(
paddle
::
test
::
SingleThreadPrediction
,
pred_pool
.
Retrive
(
i
),
&
my_input_data_map
,
&
infer_output_data
,
2
);
}
// thread join & check outputs
for
(
int
i
=
0
;
i
<
thread_num
;
++
i
)
{
LOG
(
INFO
)
<<
"join tid : "
<<
i
;
threads
[
i
].
join
();
CompareRecord
(
&
truth_output_data
,
&
infer_output_data
);
}
std
::
cout
<<
"finish multi-thread test"
<<
std
::
endl
;
}
}
// namespace paddle_infer
int
main
(
int
argc
,
char
**
argv
)
{
...
...
paddle/fluid/inference/tests/infer_ut/test_suite.h
浏览文件 @
45fa14f5
...
...
@@ -18,6 +18,7 @@
#include <iostream>
#include <numeric>
#include <string>
#include <thread>
#include <vector>
#include "gflags/gflags.h"
...
...
@@ -117,5 +118,5 @@ void CompareRecord(std::map<std::string, Record> *truth_output_data,
}
}
}
// namespace
demo
}
// namespace
test
}
// namespace paddle
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录