Skip to content

Commit 638973a

Browse files
committed
changed approach
1 parent 4ba4e4b commit 638973a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

paddle/fluid/inference/api/analysis_predictor.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,13 +409,15 @@ void AnalysisPredictor::MkldnnPreSet(
409409
void AnalysisPredictor::MkldnnPostReset() {
410410
#ifdef PADDLE_WITH_MKLDNN
411411
// In cache clearing mode.
412-
auto dev_ctx = static_cast<platform::MKLDNNDeviceContext *>(
413-
(&platform::DeviceContextPool::Instance())->Get(platform::CPUPlace()));
414-
415412
if (config_.mkldnn_cache_capacity_ > 0 &&
416-
dev_ctx->GetCachedObjectsNumber() > 0) {
413+
static_cast<platform::MKLDNNDeviceContext *>(
414+
(&platform::DeviceContextPool::Instance())->Get(platform::CPUPlace()))
415+
->GetCachedObjectsNumber() > 0) {
417416
if (VLOG_IS_ON(2)) {
418-
auto shape_blob_size = dev_ctx->GetShapeBlobSize();
417+
auto shape_blob_size = static_cast<platform::MKLDNNDeviceContext *>(
418+
(&platform::DeviceContextPool::Instance())
419+
->Get(platform::CPUPlace()))
420+
->GetShapeBlobSize();
419421
CHECK_LE(shape_blob_size,
420422
static_cast<size_t>(config_.mkldnn_cache_capacity_));
421423
}

0 commit comments

Comments
 (0)