未验证 提交 c51722c8 编写于 作者: Z Zeng Jinle 提交者: GitHub

refine err msg of allocator, test=develop (#20879)

上级 ff0886a9
......@@ -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<MemoryBlock::Desc*>(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<MemoryBlock::Desc*>(block);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册