From 6eb421f8904a2237ffc3609a44681f2d60810ea0 Mon Sep 17 00:00:00 2001 From: wxl Date: Tue, 23 Feb 2021 21:00:30 +0800 Subject: [PATCH] bugfix:fix print shape abnormal question --- ge/graph/manager/graph_caching_allocator.cc | 2 ++ .../graph/manager/graph_caching_allocator_unittest.cc | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/ge/graph/manager/graph_caching_allocator.cc b/ge/graph/manager/graph_caching_allocator.cc index dd46e670..ca5a6c7d 100644 --- a/ge/graph/manager/graph_caching_allocator.cc +++ b/ge/graph/manager/graph_caching_allocator.cc @@ -121,6 +121,7 @@ void CachingAllocator::Finalize(uint32_t device_id) { } uint8_t *CachingAllocator::Malloc(size_t size, uint8_t *org_ptr, uint32_t device_id) { + GELOGI("Start malloc pool memory, size = %zu, device id = %u", size, device_id); uint8_t *ptr = nullptr; size = GetBlockSize(size); Block *block = FindFreeBlock(size, org_ptr, device_id); @@ -255,6 +256,7 @@ Block *CachingAllocator::SplitBlock(Block *block, size_t size, BlockBin &bin, ui } Status CachingAllocator::TryExtendCache(size_t size, uint32_t device_id) { + GELOGI("Try to extend cache. size = %zu, device id = %u", size, device_id); auto memory_size = GetAllocationSize(size); const std::string purpose = "Memory for caching."; auto memory_addr = memory_allocator_->MallocMemory(purpose, memory_size, device_id); diff --git a/tests/ut/ge/graph/manager/graph_caching_allocator_unittest.cc b/tests/ut/ge/graph/manager/graph_caching_allocator_unittest.cc index efadcdf6..f76a4d4e 100644 --- a/tests/ut/ge/graph/manager/graph_caching_allocator_unittest.cc +++ b/tests/ut/ge/graph/manager/graph_caching_allocator_unittest.cc @@ -61,6 +61,17 @@ TEST_F(UtestGraphCachingAllocatorTest, malloc_success) { MemManager::Instance().Finalize(); } +TEST_F(UtestGraphCachingAllocatorTest, extend_malloc_success) { + std::vector mem_type; + mem_type.push_back(RT_MEMORY_HBM); + EXPECT_EQ(MemManager::Instance().Initialize(mem_type), SUCCESS); + uint8_t *ptr = MemManager::Instance().CachingInstance(RT_MEMORY_HBM).Malloc(kMByteSize); + EXPECT_NE(nullptr, ptr); + ptr = MemManager::Instance().CachingInstance(RT_MEMORY_HBM).Malloc(kBinSizeUnit32*kMByteSize); + EXPECT_NE(nullptr, ptr); + MemManager::Instance().Finalize(); +} + TEST_F(UtestGraphCachingAllocatorTest, malloc_statics) { std::vector mem_type; mem_type.push_back(RT_MEMORY_HBM);