From 1d31764e72ee41cf710ce08d57051ccae85350cb Mon Sep 17 00:00:00 2001 From: jakpiase Date: Fri, 31 Dec 2021 10:14:34 +0100 Subject: [PATCH] Fix for MKLDNNDeviceContext error in matmul_v2_transpose_reshape fuse pass when GLOG_v set (#38554) * glog fix * changed approach --- paddle/fluid/inference/api/analysis_predictor.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/inference/api/analysis_predictor.cc b/paddle/fluid/inference/api/analysis_predictor.cc index 36ef2ca754..929984f50a 100644 --- a/paddle/fluid/inference/api/analysis_predictor.cc +++ b/paddle/fluid/inference/api/analysis_predictor.cc @@ -409,7 +409,10 @@ void AnalysisPredictor::MkldnnPreSet( void AnalysisPredictor::MkldnnPostReset() { #ifdef PADDLE_WITH_MKLDNN // In cache clearing mode. - if (config_.mkldnn_cache_capacity_ > 0) { + if (config_.mkldnn_cache_capacity_ > 0 && + static_cast( + (&platform::DeviceContextPool::Instance())->Get(platform::CPUPlace())) + ->GetCachedObjectsNumber() > 0) { if (VLOG_IS_ON(2)) { auto shape_blob_size = static_cast( (&platform::DeviceContextPool::Instance()) -- GitLab