From 3a07baf8e6f399b4fe5bee789ff09df216d6f57b Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Fri, 12 Nov 2021 12:07:20 +0100 Subject: [PATCH] tests/pkg_utensor: fix alignment bug --- tests/pkg_utensor/main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/pkg_utensor/main.cpp b/tests/pkg_utensor/main.cpp index d85f4cea57..5703400973 100644 --- a/tests/pkg_utensor/main.cpp +++ b/tests/pkg_utensor/main.cpp @@ -18,9 +18,11 @@ * @} */ +#include #include #include +alignas(float) #include "blob/digit.h" //contains a sample taken from the MNIST test set #include "deep_mlp.hpp" //generated model file @@ -33,8 +35,12 @@ int main() // create the context class, the stage where inferences take place Context ctx; + // because we used alignas(float), we can rest assured that silencing + // -Wcast-align with an intermediate cast to uintptr_t is fine + float *digit_as_float = (float *)(uintptr_t)digit; + // wrap the input digit in a tensor class - auto input_x = new WrappedRamTensor({1, digit_len >> 2}, (float *)digit); + auto input_x = new WrappedRamTensor({1, digit_len >> 2}, digit_as_float); // pass ownership of the tensor to the context get_deep_mlp_ctx(ctx, input_x);