未验证 提交 04dd2861 编写于 作者: W Wilber 提交者: GitHub

[Inference] memory_optimize and mkdlnn problem (#49054)

* memory_optimize and mkdlnn problem

* update

* update

* update
上级 68629ba5
...@@ -948,8 +948,22 @@ void AnalysisConfig::Update() { ...@@ -948,8 +948,22 @@ void AnalysisConfig::Update() {
#endif #endif
} }
// TODO(inference): When we enable memory_optimize and mkldnn, PaddleSeg model
// fail.
if (enable_memory_optim_) { 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"); pass_builder()->AppendAnalysisPass("memory_optimize_pass");
#endif
} }
if (use_lite_) { if (use_lite_) {
......
...@@ -55,6 +55,10 @@ TEST(PD_Config, interface) { ...@@ -55,6 +55,10 @@ TEST(PD_Config, interface) {
bool ir_optim = PD_ConfigIrOptim(config); bool ir_optim = PD_ConfigIrOptim(config);
EXPECT_TRUE(ir_optim); EXPECT_TRUE(ir_optim);
PD_ConfigEnableMemoryOptim(config, true);
bool memory_enabled = PD_ConfigMemoryOptimEnabled(config);
EXPECT_TRUE(memory_enabled);
#ifndef PADDLE_WITH_LITE #ifndef PADDLE_WITH_LITE
PD_ConfigEnableLiteEngine( PD_ConfigEnableLiteEngine(
config, PD_PRECISION_FLOAT32, TRUE, 0, nullptr, 0, nullptr); config, PD_PRECISION_FLOAT32, TRUE, 0, nullptr, 0, nullptr);
...@@ -95,10 +99,6 @@ TEST(PD_Config, interface) { ...@@ -95,10 +99,6 @@ TEST(PD_Config, interface) {
EXPECT_FALSE(onnxruntime_disabled); EXPECT_FALSE(onnxruntime_disabled);
PD_ConfigEnableORTOptimization(config); PD_ConfigEnableORTOptimization(config);
PD_ConfigEnableMemoryOptim(config, true);
bool memory_enabled = PD_ConfigMemoryOptimEnabled(config);
EXPECT_TRUE(memory_enabled);
PD_ConfigEnableProfile(config); PD_ConfigEnableProfile(config);
bool profile_enabled = PD_ConfigProfileEnabled(config); bool profile_enabled = PD_ConfigProfileEnabled(config);
EXPECT_TRUE(profile_enabled); EXPECT_TRUE(profile_enabled);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册