Fix cpp_infer "--enable_mkldnn=false" not effective #13539
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using the --enable_mkldnn command line option, MKLDNN should be enabled when set to true and disabled when set to false. But, using the PaddlePaddle v3.0.0-beta1 inference library, the --enable_mkldnn=false option did not work as expected, causing MKLDNN to remain enabled regardless of the setting.
This commit adds a call to
config.DisableMKLDNN()
in the else branch to explicitly disable MKLDNN when--enable_mkldnn=false
is set.正常情况下,命令行指令
--enable_mkldnn=false
会关闭mkl加速。使用旧版推理库(PaddlePaddle v2.3.2)时,如果不执行
config.EnableMKLDNN();
,那么mkl默认是关闭的,指令没问题。但是,使用新版推理库(PaddlePaddle v3.0.0-beta1)时,就算不执行
config.EnableMKLDNN();
,mkl也是默认开启的。这就导致
--enable_mkldnn=false
指令失效了。无论设置什么,mkl都是开启状态。此PR增加了显式调用
config.DisableMKLDNN()
的代码,使得--enable_mkldnn=false
时,可以正确地关闭mkl加速。测试环境: