From ccd83ef6b9347c72d26c818477785dab067dc370 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Sat, 7 Apr 2018 19:26:30 -0700 Subject: [PATCH] Update --- .../fluid/memory/detail/memory_block_desc.cc | 6 ++--- paddle/fluid/memory/detail/meta_cache.cc | 27 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/paddle/fluid/memory/detail/memory_block_desc.cc b/paddle/fluid/memory/detail/memory_block_desc.cc index 0ad2ef4d7c..393dd9209c 100644 --- a/paddle/fluid/memory/detail/memory_block_desc.cc +++ b/paddle/fluid/memory/detail/memory_block_desc.cc @@ -61,12 +61,12 @@ inline size_t hash(const MemoryBlock::Desc& metadata, size_t initial_seed) { } // namespace void MemoryBlock::Desc::update_guards() { - guard_begin = hash(this, 1); - guard_end = hash(this, 2); + guard_begin = hash(*this, 1); + guard_end = hash(*this, 2); } bool MemoryBlock::Desc::check_guards() const { - return guard_begin == hash(this, 1) && guard_end == hash(this, 2); + return guard_begin == hash(*this, 1) && guard_end == hash(*this, 2); } } // namespace detail diff --git a/paddle/fluid/memory/detail/meta_cache.cc b/paddle/fluid/memory/detail/meta_cache.cc index 6bcb3a659e..b86e4f38c4 100644 --- a/paddle/fluid/memory/detail/meta_cache.cc +++ b/paddle/fluid/memory/detail/meta_cache.cc @@ -22,29 +22,28 @@ namespace detail { MetadataCache::MetadataCache(bool uses_gpu) : uses_gpu_(uses_gpu) {} -Metadata MetadataCache::load(const MemoryBlock* block) const { +MemoryBlock::Desc MetadataCache::load(const MemoryBlock* block) const { if (uses_gpu_) { - auto existing_metadata = cache_.find(block); - PADDLE_ASSERT(existing_metadata->second.check_guards()); - return existing_metadata->second; + auto existing_desc = cache_.find(block); + PADDLE_ASSERT(existing_desc->second.check_guards()); + return existing_desc->second; } else { - auto* meta = reinterpret_cast(block); - VLOG(10) << "Load MetaData type=" << meta->type; - PADDLE_ASSERT(meta->check_guards()); - return *reinterpret_cast(block); + auto* desc = reinterpret_cast(block); + VLOG(10) << "Load MemoryBlock::Desc type=" << desc->type; + PADDLE_ASSERT(desc->check_guards()); + return *reinterpret_cast(block); } } void MetadataCache::save(MemoryBlock* block, - const Metadata& original_metadata) { - auto metadata = original_metadata; - - metadata.update_guards(); + const MemoryBlock::Desc& original_desc) { + auto desc = original_desc; + desc.update_guards(); if (uses_gpu_) { - cache_[block] = metadata; + cache_[block] = desc; } else { - *reinterpret_cast(block) = metadata; + *reinterpret_cast(block) = desc; } } -- GitLab