mehrdadh commented on a change in pull request #8487:
URL: https://github.com/apache/tvm/pull/8487#discussion_r672450406
##########
File path: tests/crt/aot_memory_test.cc
##########
@@ -24,33 +24,48 @@
// Check with LIFO checks enabled for stack allocator
#define TVM_CRT_STACK_ALLOCATOR_ENABLE_LIFO_CHECK
+
+/*
+ * Align memory pointer
+ */
+uint32_t align_memory_ptr(uint8_t* memory_ptr) {
+ uint32_t extra = (uintptr_t)memory_ptr % TVM_RUNTIME_ALLOC_ALIGNMENT_BYTES;
+ uint32_t offset =
+ (TVM_RUNTIME_ALLOC_ALIGNMENT_BYTES - extra) &
(TVM_RUNTIME_ALLOC_ALIGNMENT_BYTES - 1);
+ memory_ptr += offset;
+ return offset;
+}
+
/*
* Tests allocations are properly aligned when allocated
*/
TEST(AOTMemory, Allocate) {
static uint8_t model_memory[96];
tvm_workspace_t tvm_runtime_workspace;
+ uint8_t* model_memory_ptr = model_memory;
Review comment:
`memory_add_misalignment` and `memory_align` functions required to
return the offset size so we can adjust the size.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]