Browse Source

bugfix:fix print shape abnormal question

tags/v1.2.0
wxl 4 years ago
parent
commit
6eb421f890
2 changed files with 13 additions and 0 deletions
  1. +2
    -0
      ge/graph/manager/graph_caching_allocator.cc
  2. +11
    -0
      tests/ut/ge/graph/manager/graph_caching_allocator_unittest.cc

+ 2
- 0
ge/graph/manager/graph_caching_allocator.cc View File

@@ -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);


+ 11
- 0
tests/ut/ge/graph/manager/graph_caching_allocator_unittest.cc View File

@@ -61,6 +61,17 @@ TEST_F(UtestGraphCachingAllocatorTest, malloc_success) {
MemManager::Instance().Finalize();
}
TEST_F(UtestGraphCachingAllocatorTest, extend_malloc_success) {
std::vector<rtMemType_t> 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<rtMemType_t> mem_type;
mem_type.push_back(RT_MEMORY_HBM);


Loading…
Cancel
Save