Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
3a0d7f1a
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
3a0d7f1a
编写于
4月 09, 2021
作者:
W
Wilber
提交者:
GitHub
4月 09, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[release/1.8] Upgrade lite subgraph api. (#32015)
上级
c36c22fe
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
70 addition
and
3 deletion
+70
-3
paddle/fluid/inference/analysis/argument.h
paddle/fluid/inference/analysis/argument.h
+5
-0
paddle/fluid/inference/analysis/ir_pass_manager.cc
paddle/fluid/inference/analysis/ir_pass_manager.cc
+6
-0
paddle/fluid/inference/analysis/ir_passes/lite_subgraph_pass.cc
.../fluid/inference/analysis/ir_passes/lite_subgraph_pass.cc
+10
-0
paddle/fluid/inference/api/analysis_config.cc
paddle/fluid/inference/api/analysis_config.cc
+19
-1
paddle/fluid/inference/api/analysis_predictor.cc
paddle/fluid/inference/api/analysis_predictor.cc
+5
-0
paddle/fluid/inference/api/paddle_analysis_config.h
paddle/fluid/inference/api/paddle_analysis_config.h
+9
-1
paddle/fluid/inference/lite/engine.cc
paddle/fluid/inference/lite/engine.cc
+7
-0
paddle/fluid/inference/lite/engine.h
paddle/fluid/inference/lite/engine.h
+5
-0
paddle/fluid/pybind/inference_api.cc
paddle/fluid/pybind/inference_api.cc
+4
-1
未找到文件。
paddle/fluid/inference/analysis/argument.h
浏览文件 @
3a0d7f1a
...
...
@@ -205,6 +205,11 @@ struct Argument {
DECL_ARGUMENT_FIELD
(
use_xpu
,
UseXpu
,
bool
);
DECL_ARGUMENT_FIELD
(
xpu_l3_workspace_size
,
XpuL3WorkspaceSize
,
int
);
DECL_ARGUMENT_FIELD
(
xpu_locked
,
XpuLocked
,
bool
);
DECL_ARGUMENT_FIELD
(
xpu_autotune
,
XpuAutotune
,
bool
);
DECL_ARGUMENT_FIELD
(
xpu_autotune_file
,
XpuAutotuneFile
,
std
::
string
);
DECL_ARGUMENT_FIELD
(
xpu_precision
,
XpuPrecision
,
std
::
string
);
DECL_ARGUMENT_FIELD
(
xpu_adaptive_seqlen
,
XpuAdaptiveSeqlen
,
bool
);
// Memory optimized related.
DECL_ARGUMENT_FIELD
(
enable_memory_optim
,
EnableMemoryOptim
,
bool
);
...
...
paddle/fluid/inference/analysis/ir_pass_manager.cc
浏览文件 @
3a0d7f1a
...
...
@@ -153,6 +153,12 @@ void IRPassManager::CreatePasses(Argument *argument,
new
int
(
argument
->
xpu_l3_workspace_size
()));
pass
->
Set
(
"cpu_math_library_num_threads"
,
new
int
(
argument
->
cpu_math_library_num_threads
()));
pass
->
Set
(
"locked"
,
new
bool
(
argument
->
xpu_locked
()));
pass
->
Set
(
"autotune"
,
new
bool
(
argument
->
xpu_autotune
()));
pass
->
Set
(
"autotune_file"
,
new
std
::
string
(
argument
->
xpu_autotune_file
()));
pass
->
Set
(
"precision"
,
new
std
::
string
(
argument
->
xpu_precision
()));
pass
->
Set
(
"adaptive_seqlen"
,
new
bool
(
argument
->
xpu_adaptive_seqlen
()));
}
disable_logs_
=
argument
->
disable_logs
();
if
(
pass_name
==
"fc_fuse_pass"
)
{
...
...
paddle/fluid/inference/analysis/ir_passes/lite_subgraph_pass.cc
浏览文件 @
3a0d7f1a
...
...
@@ -245,6 +245,11 @@ void LiteSubgraphPass::SetUpEngine(
bool
use_xpu
=
Get
<
bool
>
(
"use_xpu"
);
int
xpu_l3_workspace_size
=
Get
<
int
>
(
"xpu_l3_workspace_size"
);
int
cpu_math_library_num_threads
=
Get
<
int
>
(
"cpu_math_library_num_threads"
);
bool
locked
=
Get
<
bool
>
(
"locked"
);
bool
autotune
=
Get
<
bool
>
(
"autotune"
);
std
::
string
autotune_file
=
Get
<
std
::
string
>
(
"autotune_file"
);
std
::
string
precision
=
Get
<
std
::
string
>
(
"precision"
);
bool
adaptive_seqlen
=
Get
<
bool
>
(
"adaptive_seqlen"
);
lite_api
::
TargetType
target_type
;
if
(
use_gpu
)
{
...
...
@@ -277,6 +282,11 @@ void LiteSubgraphPass::SetUpEngine(
};
config
.
cpu_math_library_num_threads
=
cpu_math_library_num_threads
;
config
.
xpu_l3_workspace_size
=
xpu_l3_workspace_size
;
config
.
locked
=
locked
;
config
.
autotune
=
autotune
;
config
.
autotune_file
=
autotune_file
;
config
.
precision
=
precision
;
config
.
adaptive_seqlen
=
adaptive_seqlen
;
if
(
dump_model
)
{
lite
::
StrToBinaryFile
(
"./model.bin"
,
config
.
model
);
lite
::
StrToBinaryFile
(
"./param.bin"
,
config
.
param
);
...
...
paddle/fluid/inference/api/analysis_config.cc
浏览文件 @
3a0d7f1a
...
...
@@ -88,9 +88,17 @@ void AnalysisConfig::DisableFCPadding() {
Update
();
}
void
AnalysisConfig
::
EnableXpu
(
int
l3_workspace_size
)
{
void
AnalysisConfig
::
EnableXpu
(
int
l3_workspace_size
,
bool
locked
,
bool
autotune
,
const
std
::
string
&
autotune_file
,
const
std
::
string
&
precision
,
bool
adaptive_seqlen
)
{
use_xpu_
=
true
;
xpu_l3_workspace_size_
=
l3_workspace_size
;
xpu_locked_
=
locked
;
xpu_autotune_
=
autotune
;
xpu_autotune_file_
=
autotune_file
;
xpu_precision_
=
precision
;
xpu_adaptive_seqlen_
=
adaptive_seqlen
;
Update
();
}
...
...
@@ -143,6 +151,11 @@ AnalysisConfig::AnalysisConfig(const AnalysisConfig &other) {
CP_MEMBER
(
use_xpu_
);
CP_MEMBER
(
xpu_l3_workspace_size_
);
CP_MEMBER
(
xpu_locked_
);
CP_MEMBER
(
xpu_autotune_
);
CP_MEMBER
(
xpu_autotune_file_
);
CP_MEMBER
(
xpu_precision_
);
CP_MEMBER
(
xpu_adaptive_seqlen_
);
// profile related.
CP_MEMBER
(
with_profile_
);
...
...
@@ -434,6 +447,11 @@ std::string AnalysisConfig::SerializeInfoCache() {
ss
<<
use_lite_
;
ss
<<
use_xpu_
;
ss
<<
xpu_l3_workspace_size_
;
ss
<<
xpu_locked_
;
ss
<<
xpu_autotune_
;
ss
<<
xpu_autotune_file_
;
ss
<<
xpu_precision_
;
ss
<<
xpu_adaptive_seqlen_
;
return
ss
.
str
();
}
...
...
paddle/fluid/inference/api/analysis_predictor.cc
浏览文件 @
3a0d7f1a
...
...
@@ -462,6 +462,11 @@ void AnalysisPredictor::PrepareArgument() {
argument_
.
SetLiteZeroCopy
(
config_
.
lite_zero_copy_
);
argument_
.
SetUseXpu
(
config_
.
use_xpu_
);
argument_
.
SetXpuL3WorkspaceSize
(
config_
.
xpu_l3_workspace_size_
);
argument_
.
SetXpuLocked
(
config_
.
xpu_locked_
);
argument_
.
SetXpuAutotune
(
config_
.
xpu_autotune_
);
argument_
.
SetXpuAutotuneFile
(
config_
.
xpu_autotune_file_
);
argument_
.
SetXpuPrecision
(
config_
.
xpu_precision_
);
argument_
.
SetXpuAdaptiveSeqlen
(
config_
.
xpu_adaptive_seqlen_
);
LOG
(
INFO
)
<<
"Lite subgraph engine is enabled"
;
}
...
...
paddle/fluid/inference/api/paddle_analysis_config.h
浏览文件 @
3a0d7f1a
...
...
@@ -177,7 +177,10 @@ struct AnalysisConfig {
///
void
DisableGpu
();
void
EnableXpu
(
int
l3_workspace_size
=
0xfffc00
);
void
EnableXpu
(
int
l3_workspace_size
=
0xfffc00
,
bool
locked
=
false
,
bool
autotune
=
true
,
const
std
::
string
&
autotune_file
=
""
,
const
std
::
string
&
precision
=
"int16"
,
bool
adaptive_seqlen
=
false
);
///
/// \brief A boolean state telling whether the GPU is turned on.
///
...
...
@@ -587,6 +590,11 @@ struct AnalysisConfig {
bool
thread_local_stream_
{
false
};
bool
use_xpu_
{
false
};
int
xpu_l3_workspace_size_
;
bool
xpu_locked_
;
bool
xpu_autotune_
;
std
::
string
xpu_autotune_file_
;
std
::
string
xpu_precision_
;
bool
xpu_adaptive_seqlen_
;
// mkldnn related.
int
mkldnn_cache_capacity_
{
0
};
...
...
paddle/fluid/inference/lite/engine.cc
浏览文件 @
3a0d7f1a
...
...
@@ -59,8 +59,15 @@ paddle::lite_api::PaddlePredictor* EngineManager::Create(
#endif
#ifdef LITE_SUBGRAPH_WITH_XPU
// Deprecated in Paddle-Lite release/v2.8
lite_cxx_config
.
set_xpu_workspace_l3_size_per_thread
(
cfg
.
xpu_l3_workspace_size
);
lite_cxx_config
.
set_xpu_l3_cache_method
(
cfg
.
xpu_l3_workspace_size
,
cfg
.
locked
);
lite_cxx_config
.
set_xpu_conv_autotune
(
cfg
.
autotune
,
cfg
.
autotune_file
);
lite_cxx_config
.
set_xpu_multi_encoder_method
(
cfg
.
precision
,
cfg
.
adaptive_seqlen
);
#endif
// create predictor
...
...
paddle/fluid/inference/lite/engine.h
浏览文件 @
3a0d7f1a
...
...
@@ -42,6 +42,11 @@ struct EngineConfig {
// for xpu
size_t
xpu_l3_workspace_size
;
bool
locked
=
false
;
bool
autotune
=
true
;
std
::
string
autotune_file
=
""
;
std
::
string
precision
=
"int16"
;
bool
adaptive_seqlen
=
false
;
// for x86 or arm
int
cpu_math_library_num_threads
{
1
};
...
...
paddle/fluid/pybind/inference_api.cc
浏览文件 @
3a0d7f1a
...
...
@@ -388,7 +388,10 @@ void BindAnalysisConfig(py::module *m) {
.
def
(
"enable_use_gpu"
,
&
AnalysisConfig
::
EnableUseGpu
,
py
::
arg
(
"memory_pool_init_size_mb"
),
py
::
arg
(
"device_id"
)
=
0
)
.
def
(
"enable_xpu"
,
&
AnalysisConfig
::
EnableXpu
,
py
::
arg
(
"l3_workspace_size"
))
py
::
arg
(
"l3_workspace_size"
)
=
16
*
1024
*
1024
,
py
::
arg
(
"locked"
)
=
false
,
py
::
arg
(
"autotune"
)
=
true
,
py
::
arg
(
"autotune_file"
)
=
""
,
py
::
arg
(
"precision"
)
=
"int16"
,
py
::
arg
(
"adaptive_seqlen"
)
=
false
)
.
def
(
"disable_gpu"
,
&
AnalysisConfig
::
DisableGpu
)
.
def
(
"use_gpu"
,
&
AnalysisConfig
::
use_gpu
)
.
def
(
"gpu_device_id"
,
&
AnalysisConfig
::
gpu_device_id
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录