Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSeg
提交
2a2f5756
P
PaddleSeg
项目概览
PaddlePaddle
/
PaddleSeg
通知
286
Star
8
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2a2f5756
编写于
12月 20, 2019
作者:
S
sjtubinlong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
C++ infer: support tensorrt fp16/fp32/int8
上级
ca2a239a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
23 addition
and
4 deletion
+23
-4
deploy/cpp/CMakeLists.txt
deploy/cpp/CMakeLists.txt
+2
-2
deploy/cpp/predictor/seg_predictor.cpp
deploy/cpp/predictor/seg_predictor.cpp
+6
-1
deploy/cpp/predictor/seg_predictor.h
deploy/cpp/predictor/seg_predictor.h
+5
-0
deploy/cpp/utils/seg_conf_parser.h
deploy/cpp/utils/seg_conf_parser.h
+10
-1
未找到文件。
deploy/cpp/CMakeLists.txt
浏览文件 @
2a2f5756
...
...
@@ -195,8 +195,8 @@ endif(NOT WIN32)
if
(
WITH_GPU
)
if
(
NOT WIN32
)
if
(
USE_TENSORRT
)
set
(
DEPS
${
DEPS
}
${
PADDLE_DIR
}
/third_party/install/tensorrt/lib/libnvinfer
${
CMAKE_S
TATIC
_LIBRARY_SUFFIX
}
)
set
(
DEPS
${
DEPS
}
${
PADDLE_DIR
}
/third_party/install/tensorrt/lib/libnvinfer_plugin
${
CMAKE_S
TATIC
_LIBRARY_SUFFIX
}
)
set
(
DEPS
${
DEPS
}
${
PADDLE_DIR
}
/third_party/install/tensorrt/lib/libnvinfer
${
CMAKE_S
HARED
_LIBRARY_SUFFIX
}
)
set
(
DEPS
${
DEPS
}
${
PADDLE_DIR
}
/third_party/install/tensorrt/lib/libnvinfer_plugin
${
CMAKE_S
HARED
_LIBRARY_SUFFIX
}
)
endif
()
set
(
DEPS
${
DEPS
}
${
CUDA_LIB
}
/libcudart
${
CMAKE_SHARED_LIBRARY_SUFFIX
}
)
set
(
DEPS
${
DEPS
}
${
CUDNN_LIB
}
/libcudnn
${
CMAKE_SHARED_LIBRARY_SUFFIX
}
)
...
...
deploy/cpp/predictor/seg_predictor.cpp
浏览文件 @
2a2f5756
...
...
@@ -36,7 +36,6 @@ namespace PaddleSolution {
const
auto
&
model_dir
=
_model_config
.
_model_path
;
const
auto
&
model_filename
=
_model_config
.
_model_file_name
;
const
auto
&
params_filename
=
_model_config
.
_param_file_name
;
// load paddle model file
if
(
_model_config
.
_predictor_mode
==
"NATIVE"
)
{
paddle
::
NativeConfig
config
;
...
...
@@ -52,6 +51,12 @@ namespace PaddleSolution {
paddle
::
AnalysisConfig
config
;
if
(
use_gpu
)
{
config
.
EnableUseGpu
(
100
,
0
);
if
(
TRT_MAP
.
find
(
_model_config
.
_trt_mode
)
!=
TRT_MAP
.
end
())
{
auto
precision
=
TRT_MAP
[
_model_config
.
_trt_mode
];
bool
use_cab
=
(
precision
==
paddle
::
AnalysisConfig
::
Precision
::
kInt8
);
config
.
EnableTensorRtEngine
(
1
<<
30
,
_model_config
.
_batch_size
,
40
,
precision
,
false
,
use_cab
);
}
}
auto
prog_file
=
utils
::
path_join
(
model_dir
,
model_filename
);
auto
param_file
=
utils
::
path_join
(
model_dir
,
params_filename
);
...
...
deploy/cpp/predictor/seg_predictor.h
浏览文件 @
2a2f5756
...
...
@@ -55,5 +55,10 @@ class Predictor {
PaddleSolution
::
PaddleSegModelConfigPaser
_model_config
;
std
::
shared_ptr
<
PaddleSolution
::
ImagePreProcessor
>
_preprocessor
;
std
::
unique_ptr
<
paddle
::
PaddlePredictor
>
_main_predictor
;
std
::
map
<
std
::
string
,
paddle
::
AnalysisConfig
::
Precision
>
TRT_MAP
=
{
{
"FP32"
,
paddle
::
AnalysisConfig
::
Precision
::
kFloat32
},
{
"FP16"
,
paddle
::
AnalysisConfig
::
Precision
::
kHalf
},
{
"INT8"
,
paddle
::
AnalysisConfig
::
Precision
::
kInt8
}
};
};
}
// namespace PaddleSolution
deploy/cpp/utils/seg_conf_parser.h
浏览文件 @
2a2f5756
...
...
@@ -46,6 +46,7 @@ class PaddleSegModelConfigPaser {
_model_file_name
.
clear
();
_model_path
.
clear
();
_param_file_name
.
clear
();
_trt_mode
.
clear
();
}
std
::
string
process_parenthesis
(
const
std
::
string
&
str
)
{
...
...
@@ -180,6 +181,12 @@ class PaddleSegModelConfigPaser {
}
else
{
_use_pr
=
0
;
}
// 16. trt_mode
if
(
config
[
"DEPLOY"
][
"TRT_MODE"
].
IsDefined
())
{
_trt_mode
=
config
[
"DEPLOY"
][
"TRT_MODE"
].
as
<
std
::
string
>
();
}
else
{
_trt_mode
=
""
;
}
return
true
;
}
...
...
@@ -246,8 +253,10 @@ class PaddleSegModelConfigPaser {
std
::
string
_predictor_mode
;
// DEPLOY.BATCH_SIZE
int
_batch_size
;
// USE_PR: OP Optimized model
//
DEPLOY.
USE_PR: OP Optimized model
int
_use_pr
;
// DEPLOY.TRT_MODE: TRT Precesion
std
::
string
_trt_mode
;
};
}
// namespace PaddleSolution
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录