Browse Source

!281 fixing logic error for hbm allocation padding

From: @xchu42
Reviewed-by: @ji_chen,@wqtshg
Signed-off-by: @ji_chen
tags/v1.1.0
mindspore-ci-bot Gitee 3 years ago
parent
commit
6e913a5391
1 changed files with 3 additions and 4 deletions
  1. +3
    -4
      ge/hybrid/common/npu_memory_allocator.cc

+ 3
- 4
ge/hybrid/common/npu_memory_allocator.cc View File

@@ -69,11 +69,10 @@ void *NpuMemoryAllocator::Allocate(std::size_t size, AllocationAttr *attr) {
if (attr->padding_ > 0) { if (attr->padding_ > 0) {
padding = attr->padding_; padding = attr->padding_;
} }

// padding up to multiple of padding, and add extra padding
allocate_size = (size + 2 * padding - 1) / padding * padding;
GELOGD("Padding size %ld by %d. final size = %zu.", size, padding, allocate_size);
} }
// padding up to multiple of padding, and add extra padding
allocate_size = (size + 2 * padding - 1) / padding * padding;
GELOGD("Padding size %ld by %d. final size = %zu.", size, padding, allocate_size);
buffer = MemManager::Instance() buffer = MemManager::Instance()
.CachingInstance(RT_MEMORY_HBM) .CachingInstance(RT_MEMORY_HBM)
.Malloc(allocate_size, reinterpret_cast<uint8_t *>(try_reuse_addr), device_id_); .Malloc(allocate_size, reinterpret_cast<uint8_t *>(try_reuse_addr), device_id_);


Loading…
Cancel
Save