Created
December 5, 2025 17:42
-
-
Save bjacob/629c50f66701d388375400fa58e3f0a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/runtime/src/iree/vm/native_module_packing.h b/runtime/src/iree/vm/native_module_packing.h | |
| index 705b68528a..be0ee5047e 100644 | |
| --- a/runtime/src/iree/vm/native_module_packing.h | |
| +++ b/runtime/src/iree/vm/native_module_packing.h | |
| @@ -8,6 +8,7 @@ | |
| #define IREE_VM_MODULE_ABI_PACKING_H_ | |
| #include <memory> | |
| +#include <numeric> | |
| #include <tuple> | |
| #include <utility> | |
| #include <vector> | |
| @@ -374,7 +375,7 @@ struct ParamUnpack<T, enable_if_primitive<T>> { | |
| using storage_type = T; | |
| static void Load(Status& status, params_ptr_t& ptr, storage_type& out_param) { | |
| out_param = *reinterpret_cast<const T*>(ptr); | |
| - ptr += sizeof(T); | |
| + ptr += std::lcm(sizeof(T), alignof(iree_vm_ref_t)); | |
| } | |
| }; | |
| @@ -540,7 +541,7 @@ struct ParamUnpack<iree::span<U>, enable_if_not_primitive<U>> { | |
| using storage_type = std::vector<element_type>; | |
| static void Load(Status& status, params_ptr_t& ptr, storage_type& out_param) { | |
| iree_host_size_t count = *reinterpret_cast<const int32_t*>(ptr); | |
| - ptr += sizeof(int32_t); | |
| + ptr += std::lcm(sizeof(int32_t), alignof(iree_vm_ref_t)); | |
| out_param.resize(count); | |
| for (iree_host_size_t i = 0; i < count; ++i) { | |
| ParamUnpack<element_type>::Load(status, ptr, out_param[i]); | |
| @@ -556,10 +557,10 @@ struct ParamUnpack<iree::span<U>, enable_if_primitive<U>> { | |
| using storage_type = iree::span<const element_type>; | |
| static void Load(Status& status, params_ptr_t& ptr, storage_type& out_param) { | |
| iree_host_size_t count = *reinterpret_cast<const int32_t*>(ptr); | |
| - ptr += sizeof(int32_t); | |
| + ptr += std::lcm(sizeof(int32_t), alignof(iree_vm_ref_t)); | |
| out_param = | |
| iree::span<U>(reinterpret_cast<const element_type*>(ptr), count); | |
| - ptr += sizeof(element_type) * count; | |
| + ptr += std::lcm(sizeof(element_type) * count, alignof(iree_vm_ref_t)); | |
| } | |
| }; | |
| @@ -577,7 +578,7 @@ template <typename T> | |
| struct ResultPack { | |
| static void Store(result_ptr_t& ptr, T value) { | |
| *reinterpret_cast<T*>(ptr) = value; | |
| - ptr += sizeof(T); | |
| + ptr += std::lcm(sizeof(T), alignof(iree_vm_ref_t)); | |
| } | |
| }; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment