tests/pkg_utensor: fix alignment bug
This commit is contained in:
parent
1193785a11
commit
3a07baf8e6
@ -18,9 +18,11 @@
|
|||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdalign.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
alignas(float)
|
||||||
#include "blob/digit.h" //contains a sample taken from the MNIST test set
|
#include "blob/digit.h" //contains a sample taken from the MNIST test set
|
||||||
|
|
||||||
#include "deep_mlp.hpp" //generated model file
|
#include "deep_mlp.hpp" //generated model file
|
||||||
@ -33,8 +35,12 @@ int main()
|
|||||||
// create the context class, the stage where inferences take place
|
// create the context class, the stage where inferences take place
|
||||||
Context ctx;
|
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
|
// 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
|
// pass ownership of the tensor to the context
|
||||||
get_deep_mlp_ctx(ctx, input_x);
|
get_deep_mlp_ctx(ctx, input_x);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user