Skip to content

Commit

Permalink
[Inference] memory_optimize and mkdlnn problem (PaddlePaddle#49054)
Browse files Browse the repository at this point in the history
* memory_optimize and mkdlnn problem

* update

* update

* update
  • Loading branch information
jiweibo committed Dec 15, 2022
1 parent 2a170ff commit 0c4c757
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
14 changes: 14 additions & 0 deletions paddle/fluid/inference/api/analysis_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -948,8 +948,22 @@ void AnalysisConfig::Update() {
#endif
}

// TODO(inference): When we enable memory_optimize and mkldnn, PaddleSeg model
// fail.
if (enable_memory_optim_) {
#ifdef PADDLE_WITH_MKLDNN
if (use_mkldnn_) {
enable_memory_optim_ = false;
LOG_FIRST_N(WARNING, 1)
<< "It is detected that mkldnn and memory_optimize_pass are enabled "
"at the same time, but they are not supported yet. Currently, "
"memory_optimize_pass is explicitly disabled";
} else {
pass_builder()->AppendAnalysisPass("memory_optimize_pass");
}
#else
pass_builder()->AppendAnalysisPass("memory_optimize_pass");
#endif
}

if (use_lite_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ TEST(PD_Config, interface) {
bool ir_optim = PD_ConfigIrOptim(config);
EXPECT_TRUE(ir_optim);

PD_ConfigEnableMemoryOptim(config, true);
bool memory_enabled = PD_ConfigMemoryOptimEnabled(config);
EXPECT_TRUE(memory_enabled);

#ifndef PADDLE_WITH_LITE
PD_ConfigEnableLiteEngine(
config, PD_PRECISION_FLOAT32, TRUE, 0, nullptr, 0, nullptr);
Expand Down Expand Up @@ -95,10 +99,6 @@ TEST(PD_Config, interface) {
EXPECT_FALSE(onnxruntime_disabled);
PD_ConfigEnableORTOptimization(config);

PD_ConfigEnableMemoryOptim(config, true);
bool memory_enabled = PD_ConfigMemoryOptimEnabled(config);
EXPECT_TRUE(memory_enabled);

PD_ConfigEnableProfile(config);
bool profile_enabled = PD_ConfigProfileEnabled(config);
EXPECT_TRUE(profile_enabled);
Expand Down

0 comments on commit 0c4c757

Please sign in to comment.