Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
a5113877
S
Serving
项目概览
PaddlePaddle
/
Serving
1 年多 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a5113877
编写于
4月 14, 2021
作者:
Z
zhangjun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix
上级
c2928447
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
30 deletion
+29
-30
core/predictor/common/constant.h
core/predictor/common/constant.h
+0
-2
core/predictor/common/utils.h
core/predictor/common/utils.h
+10
-23
paddle_inference/paddle/include/paddle_engine.h
paddle_inference/paddle/include/paddle_engine.h
+19
-5
未找到文件。
core/predictor/common/constant.h
浏览文件 @
a5113877
...
...
@@ -43,8 +43,6 @@ DECLARE_bool(enable_model_toolkit);
DECLARE_string
(
enable_protocol_list
);
DECLARE_bool
(
enable_cube
);
DECLARE_bool
(
enable_general_model
);
DECLARE_string
(
precision
);
DECLARE_bool
(
use_calib
);
// STATIC Variables
extern
const
char
*
START_OP_NAME
;
...
...
core/predictor/common/utils.h
浏览文件 @
a5113877
...
...
@@ -29,21 +29,22 @@ namespace butil = base;
#endif
enum
class
Precision
{
kFloat32
=
0
,
///< fp32
kInt8
,
///< int8
kHalf
,
///< fp16
kBfloat16
,
///< bf16
kUnk
=
-
1
,
// unknown type
kFloat32
=
0
,
// fp32
kInt8
,
// int8
kHalf
,
// fp16
kBfloat16
// bf16
};
string
PrecisionTypeString
(
const
Precision
data_type
)
{
st
d
::
st
ring
PrecisionTypeString
(
const
Precision
data_type
)
{
switch
(
data_type
)
{
case
0
:
case
Precision
::
kFloat32
:
return
"kFloat32"
;
case
1
:
case
Precision
::
kInt8
:
return
"kInt8"
;
case
2
:
case
Precision
::
kHalf
:
return
"kHalf"
;
case
3
:
case
Precision
::
kBfloat16
:
return
"kBloat16"
;
default:
return
"unUnk"
;
...
...
@@ -59,20 +60,6 @@ std::string ToLower(const std::string& data) {
return
result
;
}
Precision
GetPrecision
(
const
std
::
string
&
precision_data
)
{
std
::
string
precision_type
=
ToLower
(
precision_data
);
if
(
precision_type
==
"fp32"
)
{
return
Precision
::
kFloat32
;
}
else
if
(
precision_type
==
"int8"
)
{
return
Precison
::
kInt8
;
}
else
if
(
precision_type
==
"fp16"
)
{
return
Precision
::
kHalf
;
}
else
if
(
precision_type
==
"bf16"
)
{
return
Precision
::
kBfloat16
;
}
return
"unknow type"
;
}
class
TimerFlow
{
public:
static
const
int
MAX_SIZE
=
1024
;
...
...
paddle_inference/paddle/include/paddle_engine.h
浏览文件 @
a5113877
...
...
@@ -37,10 +37,24 @@ using paddle_infer::Tensor;
using
paddle_infer
::
CreatePredictor
;
DECLARE_int32
(
gpuid
);
DECLARE_string
(
precision
);
DECLARE_bool
(
use_calib
);
static
const
int
max_batch
=
32
;
static
const
int
min_subgraph_size
=
3
;
static
predictor
::
Precision
precision_type
;
static
PrecisionType
precision_type
;
PrecisionType
GetPrecision
(
const
std
::
string
&
precision_data
)
{
std
::
string
precision_type
=
predictor
::
ToLower
(
precision_data
);
if
(
precision_type
==
"fp32"
)
{
return
PrecisionType
::
kFloat32
;
}
else
if
(
precision_type
==
"int8"
)
{
return
PrecisionType
::
kInt8
;
}
else
if
(
precision_type
==
"fp16"
)
{
return
PrecisionType
::
kHalf
;
}
return
PrecisionType
::
kFloat32
;
}
// Engine Base
class
PaddleEngineBase
{
...
...
@@ -138,7 +152,7 @@ class PaddleInferenceEngine : public PaddleEngineBase {
// 2000MB GPU memory
config
.
EnableUseGpu
(
2000
,
FLAGS_gpuid
);
}
precision_type
=
predictor
::
GetPrecision
(
FLAGS_precision
);
precision_type
=
GetPrecision
(
FLAGS_precision
);
if
(
engine_conf
.
has_use_trt
()
&&
engine_conf
.
use_trt
())
{
if
(
!
engine_conf
.
has_use_gpu
()
||
!
engine_conf
.
use_gpu
())
{
...
...
@@ -149,7 +163,7 @@ class PaddleInferenceEngine : public PaddleEngineBase {
min_subgraph_size
,
precision_type
,
false
,
use_calib
);
FLAGS_
use_calib
);
LOG
(
INFO
)
<<
"create TensorRT predictor"
;
}
...
...
@@ -160,9 +174,9 @@ class PaddleInferenceEngine : public PaddleEngineBase {
if
((
!
engine_conf
.
has_use_lite
()
&&
!
engine_conf
.
has_use_gpu
())
||
(
engine_conf
.
has_use_lite
()
&&
!
engine_conf
.
use_lite
()
&&
engine_conf
.
has_use_gpu
()
&&
!
engine_conf
.
use_gpu
()))
{
if
(
precision_type
==
Precision
::
kInt8
)
{
if
(
precision_type
==
Precision
Type
::
kInt8
)
{
config
.
EnableMkldnnQuantizer
();
}
else
if
(
precision_type
==
Precision
::
kHalf
)
{
}
else
if
(
precision_type
==
Precision
Type
::
kHalf
)
{
config
.
EnableMkldnnBfloat16
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录