Browse Source

fix padding

tags/v1.1.0
chuxing 4 years ago
parent
commit
f75074db90
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