1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

tests/pkg_utensor: fix alignment bug

This commit is contained in:
Marian Buschsieweke 2021-11-12 12:07:20 +01:00
parent 1193785a11
commit 3a07baf8e6
No known key found for this signature in database
GPG Key ID: CB8E3238CE715A94

View File

@ -18,9 +18,11 @@
* @}
*/
#include <stdalign.h>
#include <stdio.h>
#include <inttypes.h>
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<float>({1, digit_len >> 2}, (float *)digit);
auto input_x = new WrappedRamTensor<float>({1, digit_len >> 2}, digit_as_float);
// pass ownership of the tensor to the context
get_deep_mlp_ctx(ctx, input_x);