21#define INCLUDE_FILE(section, filename, symbol) asm (\
22 ".section "#section"\n"
\
24 ".global "#symbol"_start\n"
\
25 ".global "#symbol"_data\n"
\
28 ".incbin \""filename"\"\n"
\
29 ".global "#symbol"_end\n"
\
32 ".section \".text\"\n")
101static inline void nn_assert(
int condition,
char *message) {
103 printf(
"Assertion failed: ");
104 printf(
"%s\n", message);
119static inline uint8_t
float_equal(
float golden,
float actual,
float rel_err) {
120 return (fabs(actual - golden) < rel_err) || (fabs((actual - golden) / actual) < rel_err);
uint16_t float16_t
Definition: float16.h:33
Half-Precision Floating-Point (fp16) Definitions.
void nn_min2d_f16(Tensor0D_F16 *y, const Tensor2D_F16 *x)
void nn_mulscalar2d_f16(Tensor2D_F16 *y, const Tensor2D_F16 *x, float16_t scalar)
Tensor2D_F16 * nn_tensor2d_f16(size_t shape[2], const float16_t *data)
void nn_print_f32(float v, int16_t num_digits)
uint8_t nn_equals0d_f32(const Tensor0D_F32 *a, const Tensor0D_F32 *b, float rel_err)
void nn_mm_f32(Tensor2D_F32 *y, const Tensor2D_F32 *x1, const Tensor2D_F32 *x2)
void nn_min1d_f16(Tensor0D_F16 *y, const Tensor1D_F16 *x)
void nn_print_shape(size_t ndim, const size_t *shape)
void nn_print_f16(float16_t v, int16_t num_digits)
void nn_mulscalar2d_f32(Tensor2D_F32 *y, const Tensor2D_F32 *x, float scalar)
void nn_addscalar1d_f16(Tensor1D_F16 *y, const Tensor1D_F16 *x, float16_t scalar)
void nn_print_u8(uint8_t v)
void nn_mul1d_f16(Tensor1D_F16 *y, const Tensor1D_F16 *x1, const Tensor1D_F16 *x2)
static void nn_assert(int condition, char *message)
Definition: nn.h:101
static uint8_t float_equal(float golden, float actual, float rel_err)
Definition: nn.h:119
void nn_addscalar2d_f32(Tensor2D_F32 *y, const Tensor2D_F32 *x, float scalar)
void nn_addscalar2d_f16(Tensor2D_F16 *y, const Tensor2D_F16 *x, float16_t scalar)
void nn_mul2d_f16(Tensor2D_F16 *y, const Tensor2D_F16 *x1, const Tensor2D_F16 *x2)
void nn_print_i32(int32_t v)
void nn_max2d_f32(Tensor0D_F32 *y, const Tensor2D_F32 *x)
void nn_tanh2d_f16(Tensor2D_F16 *y, const Tensor2D_F16 *x)
void nn_relu2d_f32(Tensor2D_F32 *y, const Tensor2D_F32 *x)
Tensor2D_F32 * nn_tensor2d_f32(size_t shape[2], const float *data)
void nn_add2d_f32(Tensor2D_F32 *y, const Tensor2D_F32 *x1, const Tensor2D_F32 *x2)
void nn_print_tensor1d_f16(const Tensor1D_F16 *tensor)
void nn_mm_f16(Tensor2D_F16 *y, const Tensor2D_F16 *x1, const Tensor2D_F16 *x2)
void nn_min2d_f32(Tensor0D_F32 *y, const Tensor2D_F32 *x)
void nn_print_tensor2d_f16(const Tensor2D_F16 *tensor)
uint8_t nn_equals2d_f16(const Tensor2D_F16 *a, const Tensor2D_F16 *b, float rel_err)
uint8_t nn_equals0d_f16(const Tensor0D_F16 *a, const Tensor0D_F16 *b, float rel_err)
void nn_elu2d_f32(Tensor2D_F32 *y, const Tensor2D_F32 *x, float alpha)
void nn_addscalar1d_f32(Tensor1D_F32 *y, const Tensor1D_F32 *x, float scalar)
void nn_tanh2d_f32(Tensor2D_F32 *y, const Tensor2D_F32 *x)
void nn_print_u16(uint16_t v)
void nn_mul1d_f32(Tensor1D_F32 *y, const Tensor1D_F32 *x1, const Tensor1D_F32 *x2)
void nn_print_u32(uint32_t v)
void nn_addmm_f16(Tensor2D_F16 *y, const Tensor2D_F16 *x, const Tensor2D_F16 *weight, const Tensor1D_F16 *bias)
void nn_mulscalar1d_f32(Tensor1D_F32 *y, const Tensor1D_F32 *x, float scalar)
void nn_add1d_f32(Tensor1D_F32 *y, const Tensor1D_F32 *x1, const Tensor1D_F32 *x2)
uint8_t nn_equals1d_f32(const Tensor1D_F32 *a, const Tensor1D_F32 *b, float rel_err)
void nn_add1d_f16(Tensor1D_F16 *y, const Tensor1D_F16 *x1, const Tensor1D_F16 *x2)
void nn_max2d_f16(Tensor0D_F16 *y, const Tensor2D_F16 *x)
void nn_mulscalar1d_f16(Tensor1D_F16 *y, const Tensor1D_F16 *x, float16_t scalar)
void nn_print_tensor2d_f32(const Tensor2D_F32 *tensor)
void nn_elu2d_f16(Tensor2D_F16 *y, const Tensor2D_F16 *x, float alpha)
void nn_print_i8(int8_t v)
void nn_min1d_f32(Tensor0D_F32 *y, const Tensor1D_F32 *x)
void nn_mul2d_f32(Tensor2D_F32 *y, const Tensor2D_F32 *x1, const Tensor2D_F32 *x2)
void nn_add2d_f16(Tensor2D_F16 *y, const Tensor2D_F16 *x1, const Tensor2D_F16 *x2)
void nn_relu2d_f16(Tensor2D_F16 *y, const Tensor2D_F16 *x)
void nn_max1d_f16(Tensor0D_F16 *y, const Tensor1D_F16 *x)
uint8_t nn_equals1d_f16(const Tensor1D_F16 *a, const Tensor1D_F16 *b, float rel_err)
Tensor1D_F16 * nn_tensor1d_f16(size_t shape[1], const float16_t *data)
uint8_t nn_equals2d_f32(const Tensor2D_F32 *a, const Tensor2D_F32 *b, float rel_err)
Tensor0D_F32 * nn_tensor0d_f32(float data)
Tensor0D_F16 * nn_tensor0d_f16(float16_t data)
void nn_print_tensor1d_f32(const Tensor1D_F32 *tensor)
void nn_max1d_f32(Tensor0D_F32 *y, const Tensor1D_F32 *x)
Tensor1D_F32 * nn_tensor1d_f32(size_t shape[1], const float *data)
void nn_print_i16(int16_t v)
void nn_addmm_f32(Tensor2D_F32 *y, const Tensor2D_F32 *x, const Tensor2D_F32 *weight, const Tensor1D_F32 *bias)
float16_t data
Definition: nn.h:41
float data
Definition: nn.h:50
float16_t * data
Definition: nn.h:60
float * data
Definition: nn.h:70
float16_t * data
Definition: nn.h:80
float * data
Definition: nn.h:90