提交 5632019f 编写于 作者: W Wojciech Uss 提交者: Michal Gallus

add MKL-DNN placement pass

This patch also refactors conv+bn (includes changes from PR
https://github.com/PaddlePaddle/Paddle/pull/13926)
updated to use the mkldnn-placement-pass.

test=develop
上级 0a9f5f17
...@@ -226,18 +226,21 @@ void AnalysisPredictor::OptimizeInferenceProgram() { ...@@ -226,18 +226,21 @@ void AnalysisPredictor::OptimizeInferenceProgram() {
argument_.origin_program_desc.reset( argument_.origin_program_desc.reset(
new ProgramDesc(*inference_program_->Proto())); new ProgramDesc(*inference_program_->Proto()));
bool use_mkldnn = config_._use_mkldnn;
switch (config_.ir_mode) { switch (config_.ir_mode) {
case contrib::AnalysisConfig::IrPassMode::kExclude: case contrib::AnalysisConfig::IrPassMode::kExclude:
Analyzer() Analyzer()
.IncludeAllIrPasses() .IncludeAllIrPasses()
.SetUseMkldnn(config_._use_mkldnn) .SetUseMkldnn(use_mkldnn)
.DisableIrPasses(config_.ir_passes) .DisableIrPasses(use_mkldnn ? config_.ir_mkldnn_passes
: config_.ir_passes)
.Run(&argument_); .Run(&argument_);
break; break;
case contrib::AnalysisConfig::IrPassMode::kInclude: case contrib::AnalysisConfig::IrPassMode::kInclude:
Analyzer() Analyzer()
.SetUseMkldnn(config_._use_mkldnn) .SetUseMkldnn(use_mkldnn)
.IncludeIrPasses(config_.ir_passes) .IncludeIrPasses(use_mkldnn ? config_.ir_mkldnn_passes
: config_.ir_passes)
.Run(&argument_); .Run(&argument_);
break; break;
default: default:
......
...@@ -261,8 +261,8 @@ struct AnalysisConfig : public NativeConfig { ...@@ -261,8 +261,8 @@ struct AnalysisConfig : public NativeConfig {
void SetIncludeMode() { void SetIncludeMode() {
ir_mode = IrPassMode::kInclude; ir_mode = IrPassMode::kInclude;
// this pass has to be run at the beginning of all fuse passes
ir_passes = {"infer_clean_graph_pass"}; ir_passes = {"infer_clean_graph_pass"};
ir_mkldnn_passes = {"infer_clean_graph_pass"};
} }
// Determine whether to perform graph optimization. // Determine whether to perform graph optimization.
...@@ -271,6 +271,8 @@ struct AnalysisConfig : public NativeConfig { ...@@ -271,6 +271,8 @@ struct AnalysisConfig : public NativeConfig {
IrPassMode ir_mode{IrPassMode::kExclude}; IrPassMode ir_mode{IrPassMode::kExclude};
// passes to be excluded/included // passes to be excluded/included
std::vector<std::string> ir_passes{"embedding_fc_lstm_fuse_pass"}; std::vector<std::string> ir_passes{"embedding_fc_lstm_fuse_pass"};
// passes to be excluded/included when MKL-DNN is enabled
std::vector<std::string> ir_mkldnn_passes{"embedding_fc_lstm_fuse_pass"};
// NOT stable yet. // NOT stable yet.
bool use_feed_fetch_ops{true}; bool use_feed_fetch_ops{true};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册