#include "core/common/safeint.h" #include "core/framework/func_kernel.h" #include "core/framework/allocator.h" namespace onnxruntime { void* allocate_helper_func(void* allocator, size_t alignment, size_t size) { // Here we only align the size, we expect the underline device allocator will // guarantee the address alignment. // We may update lotus' IAllocator interface to support alignment. SafeInt rounded_bytes = (alignment * ((SafeInt(size) + alignment - 1) / alignment)); auto* alloc = static_cast(allocator); return alloc->Alloc(rounded_bytes); } void release_helper_func(void* allocator, void* p) { auto* alloc = static_cast(allocator); return alloc->Free(p); } } // namespace onnxruntime