From 11e6278db7aedd1289a1a803506ac84f86ce8c05 Mon Sep 17 00:00:00 2001 From: daquexian Date: Wed, 6 Jul 2022 09:47:09 +0800 Subject: [PATCH] fix cpu aligned_alloc size (#8569) Signed-off-by: daquexian Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- oneflow/core/ep/cpu/cpu_device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oneflow/core/ep/cpu/cpu_device.cpp b/oneflow/core/ep/cpu/cpu_device.cpp index 14c0415b6ec..c9132bb4b93 100644 --- a/oneflow/core/ep/cpu/cpu_device.cpp +++ b/oneflow/core/ep/cpu/cpu_device.cpp @@ -44,7 +44,7 @@ Maybe CpuDevice::Alloc(const AllocationOptions& options, void** ptr, size_ CHECK_OR_RETURN(device); return device->AllocPinned(options, ptr, size); } else { - *ptr = aligned_alloc(kMaxAlignmentRequirement, size); + *ptr = aligned_alloc(kMaxAlignmentRequirement, RoundUp(size, kMaxAlignmentRequirement)); if (*ptr == nullptr) { return Error::RuntimeError() << "allocate failed"; } else {