Baremetal-NN
Baremetal-NN API documentation
Loading...
Searching...
No Matches
nn_f16.h File Reference

Baremetal-NN Library functions for half-precision floating-point (fp16) numbers. More...

#include "float16.h"
Include dependency graph for nn_f16.h:

Go to the source code of this file.

Data Structures

struct  Tensor0D_F16
 A 0D tensor (scalar) with a half-precision floating-point data type. More...
 
struct  Tensor1D_F16
 A 1D tensor with a half-precision floating-point data type. More...
 
struct  Tensor2D_F16
 A 2D tensor with a half-precision floating-point data type. More...
 

Functions

static uint8_t nn_equal_f16 (float16_t golden, float16_t actual, float rel_err)
 Checks if two half-precision floating-point numbers are equal within a relative error. More...
 
Tensor0D_F16nn_tensor0d_f16 (float16_t data)
 Creates a 0D tensor with type F16. More...
 
Tensor1D_F16nn_tensor1d_f16 (size_t shape[1], const float16_t *data)
 Creates a 1D tensor with type F16. More...
 
Tensor2D_F16nn_tensor2d_f16 (size_t shape[2], const float16_t *data)
 Creates a 2D tensor with type F16. More...
 
Tensor0D_F16nn_zeros0d_f16 ()
 Creates a 0D tensor with type F16 and initializes it to 0. More...
 
Tensor1D_F16nn_zeros1d_f16 (size_t shape[1])
 Creates a 1D tensor with type F16 and initializes it to 0. More...
 
Tensor2D_F16nn_zeros2d_f16 (size_t shape[2])
 Creates a 2D tensor with type F16 and initializes it to 0. More...
 
Tensor0D_F16nn_ones0d_f16 ()
 Creates a 0D tensor with type F16 and initializes it to 1. More...
 
Tensor1D_F16nn_ones1d_f16 (size_t shape[1])
 Creates a 1D tensor with type F16 and initializes it to 1. More...
 
Tensor2D_F16nn_ones2d_f16 (size_t shape[2])
 Creates a 2D tensor with type F16 and initializes it to 1. More...
 
Tensor0D_F16nn_full0d_f16 (float16_t data)
 Creates a 0D tensor with type F16 and initializes it to a specific value. More...
 
Tensor1D_F16nn_full1d_f16 (size_t shape[1], float16_t data)
 Creates a 1D tensor with type F16 and initializes it to a specific value. More...
 
Tensor2D_F16nn_full2d_f16 (size_t shape[2], float16_t data)
 Creates a 2D tensor with type F16 and initializes it to a specific value. More...
 
Tensor0D_F16nn_rand0d_f16 ()
 Creates a 0D tensor with type F16 and initializes it to a random value. More...
 
Tensor1D_F16nn_rand1d_f16 (size_t shape[1])
 Creates a 1D tensor with type F16 and initializes it to a random value. More...
 
Tensor2D_F16nn_rand2d_f16 (size_t shape[2])
 Creates a 2D tensor with type F16 and initializes it to a random value. More...
 
void nn_print_f16 (float16_t v, int16_t num_digits)
 Prints a half-precision floating-point number. More...
 
void nn_print_tensor1d_f16 (const Tensor1D_F16 *tensor)
 Prints the content of a 1D tensor with type F16. More...
 
void nn_print_tensor2d_f16 (const Tensor2D_F16 *tensor)
 Prints the content of a 2D tensor with type F16. More...
 
uint8_t nn_equals0d_f16 (const Tensor0D_F16 *a, const Tensor0D_F16 *b, float rel_err)
 Checks if two 0D tensors with type F16 are equal. More...
 
uint8_t nn_equals1d_f16 (const Tensor1D_F16 *a, const Tensor1D_F16 *b, float rel_err)
 Checks if two 1D tensors with type F16 are equal. More...
 
uint8_t nn_equals2d_f16 (const Tensor2D_F16 *a, const Tensor2D_F16 *b, float rel_err)
 Checks if two 2D tensors with type F16 are equal. More...
 
void nn_max1d_f16 (Tensor0D_F16 *y, const Tensor1D_F16 *x)
 Finds the maximum value in a 1D tensor with type F16. More...
 
void nn_max2d_f16 (Tensor0D_F16 *y, const Tensor2D_F16 *x)
 Finds the maximum value in a 2D tensor with type F16. More...
 
void nn_min1d_f16 (Tensor0D_F16 *y, const Tensor1D_F16 *x)
 Finds the minimum value in a 1D tensor with type F16. More...
 
void nn_min2d_f16 (Tensor0D_F16 *y, const Tensor2D_F16 *x)
 Finds the minimum value in a 2D tensor with type F16. More...
 
void nn_add1d_f16 (Tensor1D_F16 *y, const Tensor1D_F16 *x1, const Tensor1D_F16 *x2)
 Adds x1 and x2 element-wise and stores the result in y. More...
 
void nn_add2d_f16 (Tensor2D_F16 *y, const Tensor2D_F16 *x1, const Tensor2D_F16 *x2)
 Adds x1 and x2 element-wise and stores the result in y. More...
 
void nn_addscalar1d_f16 (Tensor1D_F16 *y, const Tensor1D_F16 *x, float16_t scalar)
 Adds a scalar to a 1D tensor with type F16. More...
 
void nn_addscalar2d_f16 (Tensor2D_F16 *y, const Tensor2D_F16 *x, float16_t scalar)
 Adds a scalar to a 2D tensor with type F16. More...
 
void nn_mul1d_f16 (Tensor1D_F16 *y, const Tensor1D_F16 *x1, const Tensor1D_F16 *x2)
 Multiplies x1 and x2 element-wise and stores the result in y. More...
 
void nn_mul2d_f16 (Tensor2D_F16 *y, const Tensor2D_F16 *x1, const Tensor2D_F16 *x2)
 Multiplies x1 and x2 element-wise and stores the result in y. More...
 
void nn_mulscalar1d_f16 (Tensor1D_F16 *y, const Tensor1D_F16 *x, float16_t scalar)
 Multiplies a scalar with a 1D tensor with type F16. More...
 
void nn_mulscalar2d_f16 (Tensor2D_F16 *y, const Tensor2D_F16 *x, float16_t scalar)
 Multiplies a scalar with a 2D tensor with type F16. More...
 
void nn_dot_f16 (Tensor1D_F16 *y, const Tensor1D_F16 *x1, const Tensor1D_F16 *x2)
 Performs a dot product of two 1D tensors with type F16. More...
 
void nn_mm_f16 (Tensor2D_F16 *y, const Tensor2D_F16 *x1, const Tensor2D_F16 *x2)
 Performs a matrix multiplication of the matrices x1 and x2. More...
 
void nn_addmm_f16 (Tensor2D_F16 *y, const Tensor2D_F16 *c, const Tensor2D_F16 *x1, const Tensor2D_F16 *x2)
 Performs a matrix multiplication of the matrices x1 and x2. More...
 
void nn_linear_f16 (Tensor2D_F16 *y, const Tensor2D_F16 *x, const Tensor2D_F16 *weight, const Tensor1D_F16 *bias)
 Linear neural network layer. More...
 
void nn_elu2d_f16 (Tensor2D_F16 *y, const Tensor2D_F16 *x, float alpha)
 Applies the ELU activation function to a 2D tensor with type F16. More...
 
void nn_relu2d_f16 (Tensor2D_F16 *y, const Tensor2D_F16 *x)
 Applies the ReLU activation function to a 2D tensor with type F16. More...
 
void nn_softmax1d_f16 (Tensor1D_F16 *y, const Tensor1D_F16 *x)
 Applies the softmax activation function to a 1D tensor with type F16. More...
 
void nn_tanh2d_f16 (Tensor2D_F16 *y, const Tensor2D_F16 *x)
 Applies the tanh activation function to a 2D tensor with type F16. More...
 

Detailed Description

Baremetal-NN Library functions for half-precision floating-point (fp16) numbers.

This file contains the declarations of the functions and structures for the Baremetal-NN Library.