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

Baremetal-NN Library functions for single-precision floating-point (fp32) numbers. More...

#include <float.h>
#include <stdint.h>
Include dependency graph for nn_f32.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Tensor0D_F32
 A 0D tensor (scalar) with a float data type. More...
 
struct  Tensor1D_F32
 A 1D tensor with a float data type. More...
 
struct  Tensor2D_F32
 A 2D tensor with a float data type. More...
 
struct  Tensor3D_F32
 A 3D tensor with a float data type. More...
 
struct  Tensor4D_F32
 A 4D tensor with a float data type. More...
 

Functions

static uint8_t nn_equal_f32 (float golden, float actual, float rel_err)
 Checks if two floating-point numbers are equal within a relative error. More...
 
Tensor0D_F32nn_tensor0d_f32 (float data)
 Creates a 0D floating-point data tensor. More...
 
Tensor1D_F32nn_tensor1d_f32 (size_t shape[1], const float *data)
 Creates a 1D floating-point data tensor, with the shape defined by the 1-element array shape. More...
 
Tensor2D_F32nn_tensor2d_f32 (size_t shape[2], const float *data)
 Creates a 2D floating-point data tensor, with the shape defined by the 2-element array shape. More...
 
Tensor3D_F32nn_tensor3d_f32 (size_t shape[3], const float *data)
 Creates a 3D floating-point data tensor, with the shape defined by the 3-element array shape. More...
 
Tensor4D_F32nn_tensor4d_f32 (size_t shape[4], const float *data)
 Creates a 4D floating-point data tensor, with the shape defined by the 4-element array shape. More...
 
Tensor1D_F32nn_as_tensor1d_f32 (size_t shape[1], float *data)
 Converts data into a tensor, with the shape defined by the 1-element array shape. More...
 
Tensor2D_F32nn_as_tensor2d_f32 (size_t shape[2], float *data)
 Converts data into a tensor, with the shape defined by the 2-element array shape. More...
 
Tensor3D_F32nn_as_tensor3d_f32 (size_t shape[3], float *data)
 Converts data into a tensor, with the shape defined by the 3-element array shape. More...
 
Tensor4D_F32nn_as_tensor4d_f32 (size_t shape[4], float *data)
 Converts data into a tensor, with the shape defined by the 4-element array shape. More...
 
Tensor0D_F32nn_zeros0d_f32 ()
 Returns a 0D floating-point tensor (scalar) filled with the scalar value 0. More...
 
Tensor1D_F32nn_zeros1d_f32 (size_t shape[1])
 Returns a 1D floating-point tensor filled with the scalar value 0, with the shape defined by the 1-element array shape. More...
 
Tensor2D_F32nn_zeros2d_f32 (size_t shape[2])
 Returns a 2D floating-point data tensor filled with the scalar value 0, with the shape defined by the 2-element array shape. More...
 
Tensor3D_F32nn_zeros3d_f32 (size_t shape[3])
 Returns a 3D floating-point data tensor filled with the scalar value 0, with the shape defined by the 3-element array shape. More...
 
Tensor4D_F32nn_zeros4d_f32 (size_t shape[4])
 Returns a 4D floating-point data tensor filled with the scalar value 0, with the shape defined by the 4-element array shape. More...
 
Tensor0D_F32nn_ones0d_f32 ()
 Returns a 0D floating-point data tensor (scalar) filled with the scalar value 1. More...
 
Tensor1D_F32nn_ones1d_f32 (size_t shape[1])
 Returns a 1D floating-point data tensor filled with the scalar value 1, with the shape defined by the 1-element array shape. More...
 
Tensor2D_F32nn_ones2d_f32 (size_t shape[2])
 Returns a 2D floating-point data tensor filled with the scalar value 1, with the shape defined by the 2-element array shape. More...
 
Tensor0D_F32nn_full0d_f32 (float data)
 Returns a 0D floating-point data tensor (scalar) filled with the scalar value data. More...
 
Tensor1D_F32nn_full1d_f32 (size_t shape[1], float data)
 Returns a 1D floating-point data tensor filled with the scalar value data, with the shape defined by the 1-element array shape. More...
 
Tensor2D_F32nn_full2d_f32 (size_t shape[2], float data)
 Returns a 2D floating-point data tensor filled with the scalar value data, with the shape defined by the 2-element array shape. More...
 
Tensor0D_F32nn_rand0d_f32 ()
 Returns a 0D floating-point data tensor (scalar) filled with a random floating-point number. More...
 
Tensor1D_F32nn_rand1d_f32 (size_t shape[1])
 Returns a 1D floating-point data tensor filled with random floating-point numbers, with the shape defined by the 1-element array shape. More...
 
Tensor2D_F32nn_rand2d_f32 (size_t shape[2])
 Returns a 2D floating-point data tensor filled with random floating-point numbers, with the shape defined by the 2-element array shape. More...
 
void nn_print_tensor1d_f32 (const Tensor1D_F32 *tensor)
 Prints the content of a 1D floating-point data tensor. More...
 
void nn_print_tensor2d_f32 (const Tensor2D_F32 *tensor)
 Prints the content of a 2D floating-point data tensor. More...
 
void nn_print_tensor3d_f32 (const Tensor3D_F32 *tensor)
 Prints the content of a 3D floating-point data tensor. More...
 
void nn_print_tensor4d_f32 (const Tensor4D_F32 *tensor)
 Prints the content of a 4D floating-point data tensor. More...
 
uint8_t nn_equals0d_f32 (const Tensor0D_F32 *a, const Tensor0D_F32 *b, float rel_err)
 Checks if two 0D floating-point tensors are equal. More...
 
uint8_t nn_equals1d_f32 (const Tensor1D_F32 *a, const Tensor1D_F32 *b, float rel_err)
 Checks if two 1D floating-point tensors are equal. More...
 
uint8_t nn_equals2d_f32 (const Tensor2D_F32 *a, const Tensor2D_F32 *b, float rel_err)
 Checks if two 2D floating-point tensors are equal. More...
 
uint8_t nn_equals3d_f32 (const Tensor3D_F32 *a, const Tensor3D_F32 *b, float rel_err)
 Checks if two 3D floating-point tensors are equal. More...
 
uint8_t nn_equals4d_f32 (const Tensor4D_F32 *a, const Tensor4D_F32 *b, float rel_err)
 Checks if two 4D floating-point tensors are equal. More...
 
void nn_max1d_f32 (Tensor0D_F32 *y, const Tensor1D_F32 *x)
 Finds the maximum value in a 1D floating-point tensor. More...
 
void nn_max2d_f32 (Tensor0D_F32 *y, const Tensor2D_F32 *x)
 Finds the maximum value in a 2D floating-point tensor. More...
 
void nn_min1d_f32 (Tensor0D_F32 *y, const Tensor1D_F32 *x)
 Finds the minimum value in a 1D floating-point tensor. More...
 
void nn_min2d_f32 (Tensor0D_F32 *y, const Tensor2D_F32 *x)
 Finds the minimum value in a 2D floating-point tensor. More...
 
void nn_add1d_f32 (Tensor1D_F32 *y, const Tensor1D_F32 *x1, const Tensor1D_F32 *x2)
 Adds x1 and x2 element-wise and stores the result in y. More...
 
void nn_add2d_f32 (Tensor2D_F32 *y, const Tensor2D_F32 *x1, const Tensor2D_F32 *x2)
 Adds x1 and x2 element-wise and stores the result in y. More...
 
void nn_addscalar1d_f32 (Tensor1D_F32 *y, const Tensor1D_F32 *x, float scalar)
 Adds a scalar to a 1D floating-point tensor and stores the result in y. More...
 
void nn_addscalar2d_f32 (Tensor2D_F32 *y, const Tensor2D_F32 *x, float scalar)
 Adds a scalar to a 2D floating-point tensor and stores the result in y. More...
 
void nn_mul1d_f32 (Tensor1D_F32 *y, const Tensor1D_F32 *x1, const Tensor1D_F32 *x2)
 Multiplies x1 and x2 element-wise and stores the result in y. More...
 
void nn_mul2d_f32 (Tensor2D_F32 *y, const Tensor2D_F32 *x1, const Tensor2D_F32 *x2)
 Multiplies x1 and x2 element-wise and stores the result in y. More...
 
void nn_mulscalar1d_f32 (Tensor1D_F32 *y, const Tensor1D_F32 *x, float scalar)
 Multiplies a scalar with a 1D floating-point tensor and stores the result in y. More...
 
void nn_mulscalar2d_f32 (Tensor2D_F32 *y, const Tensor2D_F32 *x, float scalar)
 Multiplies a scalar with a 2D floating-point tensor and stores the result in y. More...
 
void nn_nchw_to_nhwc_f32 (Tensor4D_F32 *out, const Tensor4D_F32 *in)
 Converts a 4D tensor from NCHW format to NHWC format. More...
 
void nn_nhwc_to_nchw_f32 (Tensor4D_F32 *out, const Tensor4D_F32 *in)
 Converts a 4D tensor from NHWC format to NCHW format. More...
 
void nn_conv2d_f32 (Tensor4D_F32 *out, const Tensor4D_F32 *in, const Tensor4D_F32 *weight, const Tensor1D_F32 *bias, const size_t *stride, const size_t *padding, const size_t *dilation, size_t groups)
 Performs a 2D convolution on a 4D tensor. More...
 
void nn_dot_f32 (Tensor1D_F32 *y, const Tensor1D_F32 *x1, const Tensor1D_F32 *x2)
 Computes the dot product of two 1D floating-point tensors. More...
 
void nn_mv_f32 (Tensor1D_F32 *y, const Tensor2D_F32 *x1, const Tensor1D_F32 *x2)
 Performs a matrix-vector multiplication of the matrix x1 and the vector x2. More...
 
void nn_mm_f32 (Tensor2D_F32 *y, const Tensor2D_F32 *x1, const Tensor2D_F32 *x2)
 Performs a matrix multiplication of the matrices x1 and x2. More...
 
void nn_addmm_f32 (Tensor2D_F32 *y, const Tensor2D_F32 *c, const Tensor2D_F32 *x1, const Tensor2D_F32 *x2)
 Performs a matrix multiplication of two 2D floating-point tensors and adds the result to a third tensor. More...
 
void nn_linear_f32 (Tensor2D_F32 *y, const Tensor2D_F32 *x, const Tensor2D_F32 *weight, const Tensor1D_F32 *bias)
 Linear neural network layer. More...
 
void nn_elu2d_f32 (Tensor2D_F32 *y, const Tensor2D_F32 *x, float alpha)
 Applies the ELU activation function to a 2D floating-point tensor. More...
 
void nn_relu2d_f32 (Tensor2D_F32 *y, const Tensor2D_F32 *x)
 Applies the ReLU activation function to a 2D floating-point tensor. More...
 
void nn_silu1d_f32 (Tensor1D_F32 *y, const Tensor1D_F32 *x)
 Applies the SiLU (Sigmoid Linear Unit) activation function to a 1D floating-point tensor. More...
 
void nn_softmax1d_f32 (Tensor1D_F32 *y, const Tensor1D_F32 *x)
 Applies the softmax activation function to a 1D floating-point tensor. More...
 
void nn_softmax2d_f32 (Tensor2D_F32 *y, const Tensor2D_F32 *x, size_t dim)
 Applies the softmax activation function to a 2D floating-point tensor. More...
 
void nn_tanh2d_f32 (Tensor2D_F32 *y, const Tensor2D_F32 *x)
 Applies the tanh activation function to a 2D floating-point tensor. More...
 
void nn_rms_norm1d_f32 (Tensor1D_F32 *y, const Tensor1D_F32 *x, const Tensor1D_F32 *weight, float eps)
 
void nn_scaled_dot_product_attention_f32 (Tensor4D_F32 *y, const Tensor4D_F32 *query, const Tensor4D_F32 *key, const Tensor4D_F32 *value)
 Computes scaled dot product attention on query, key and value tensors. More...
 

Detailed Description

Baremetal-NN Library functions for single-precision floating-point (fp32) numbers.

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