From c51722c82060a56c1791301892bcb91209fddde7 Mon Sep 17 00:00:00 2001 From: Zeng Jinle <32832641+sneaxiy@users.noreply.github.com> Date: Wed, 30 Oct 2019 10:10:24 +0800 Subject: [PATCH] refine err msg of allocator, test=develop (#20879) --- paddle/fluid/memory/detail/meta_cache.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/paddle/fluid/memory/detail/meta_cache.cc b/paddle/fluid/memory/detail/meta_cache.cc index 8fb2e333ba..26667e3abf 100644 --- a/paddle/fluid/memory/detail/meta_cache.cc +++ b/paddle/fluid/memory/detail/meta_cache.cc @@ -24,13 +24,15 @@ MetadataCache::MetadataCache(bool uses_gpu) : uses_gpu_(uses_gpu) {} MemoryBlock::Desc* MetadataCache::LoadDesc(MemoryBlock* block) { if (uses_gpu_) { - auto existing_desc = cache_.find(block); - PADDLE_ENFORCE_EQ(existing_desc->second.CheckGuards(), true); - return &(existing_desc->second); + auto iter = cache_.find(block); + PADDLE_ENFORCE_NE(iter, cache_.end()); + auto* desc = &(iter->second); + PADDLE_ENFORCE_EQ(desc->CheckGuards(), true, "Invalid CPU memory access"); + return desc; } else { auto* desc = reinterpret_cast(block); VLOG(10) << "Load MemoryBlock::Desc type=" << desc->type; - PADDLE_ENFORCE_EQ(desc->CheckGuards(), true); + PADDLE_ENFORCE_EQ(desc->CheckGuards(), true, "Invalid CPU memory access"); return reinterpret_cast(block); } } -- GitLab