|
Noodle
|
Files | |
| file | noodle.h |
| CNN/ML primitives for tiny MCUs with pluggable filesystem backends. | |
Classes | |
| struct | Conv |
| File-backed convolution parameters. More... | |
| struct | ConvMem |
| Memory-backed convolution parameters. More... | |
| struct | Pool |
| 2D pooling parameters. Use M = 1 and T = 1 for identity (no pooling). More... | |
| struct | FCN |
| struct | FCNFile |
| struct | FCNMem |
Typedefs | |
| typedef void(* | CBFPtr) (float progress) |
| Progress callback type used by long-running routines. | |
Common parameter semantics | |||||||||||||||||||||||||||
Standard meanings shared by many functions.
| |||||||||||||||||||||||||||
| void | noodle_setup_temp_buffers (void *b1, void *b2) | ||||||||||||||||||||||||||
| Provide two reusable temporary buffers used internally by file-streaming operations.Must be called before conv/FCN variants that read from files. Two temp buffers are needed for operations that read from a file. For C*W*W tensor, the buffer should be W*W. | |||||||||||||||||||||||||||
| void | noodle_setup_temp_buffers (void *b2) | ||||||||||||||||||||||||||
| Provide a single reusable temporary buffer used internally by file-streaming ops.Must be called before conv/FCN variants that read from files. One temp buffer is needed for operations that reads from a variable. Hence, only output accumulator buffe is needed. For C*W*W tensor, the buffer should be W*W. | |||||||||||||||||||||||||||
File and File-System Utilities | |
| bool | noodle_fs_init (uint8_t clk_pin, uint8_t cmd_pin, uint8_t d0_pin) |
| Initialize SD/FS backend (pins variant is meaningful only for SD_MMC). | |
| bool | noodle_fs_init (uint8_t clk_pin, uint8_t cmd_pin, uint8_t d0_pin, uint8_t d1_pin, uint8_t d2_pin, uint8_t d3_pin) |
| Initialize SD/FS backend with default pins/settings. | |
| bool | noodle_fs_init () |
| bool | noodle_fs_init (uint8_t cs_pin) |
| Initialize SD/FS backend with a specific CS_PIN. | |
| void | noodle_read_top_line (const char *fn, char *line, size_t maxlen) |
| Read the first line of a given text file. | |
| size_t | noodle_read_bytes_until (NDL_File &file, char terminator, char *buffer, size_t length) |
| Read bytes from a file until a terminator or length-1 (NULL terminated). | |
| void | noodle_delete_file (const char *fn) |
| Delete a file if it exists. | |
Memory utilities | |
| float * | noodle_create_buffer (uint16_t size) |
Allocate a raw float buffer of size bytes. | |
| void | noodle_delete_buffer (float *buffer) |
| Free a buffer allocated by noodle_create_buffer. | |
| void | noodle_array_to_file (float *array, const char *fn, uint16_t n) |
Write an array of n floats to fn, one value per line. File will be opened and closed. | |
| void | noodle_grid_to_file (byte *grid, const char *fn, uint16_t n) |
Write an n× grid to fn as bytes, row-major. File will be opened and closed. | |
| void | noodle_grid_to_file (float *grid, const char *fn, uint16_t n) |
Write an n× grid to fn, row-major. | |
| void | noodle_array_from_file (const char *fn, float *buffer, uint16_t K) |
Read a float array of length K from fn (one value per line). | |
| void | noodle_array_from_file (NDL_File &fi, float *buffer, uint16_t K) |
Read a float array of length K from an opened file handler fi (one value per line). | |
| void | noodle_grid_from_file (const char *fn, byte *buffer, uint16_t K) |
| void | noodle_grid_from_file (NDL_File &fi, byte *buffer, uint16_t K) |
Read an K × K grid (stored as byte) from fi (opened file handler) into buffer. | |
| void | noodle_grid_from_file (const char *fn, int8_t *buffer, uint16_t K) |
Read an K × K grid (stored as float) from fn into buffer. | |
| void | noodle_grid_from_file (NDL_File &fi, int8_t *buffer, uint16_t K) |
Read an K × K grid (stored as int8) from fi (opened file handler) into buffer. | |
| void | noodle_grid_from_file (const char *fn, float *buffer, uint16_t K) |
Read an K × K grid (stored as float) from fn into buffer. | |
| void | noodle_reset_buffer (float *buffer, uint16_t n) |
Fill buffer with zeros (n floats). | |
| float * | noodle_slice (float *flat, size_t W, size_t z) |
| void | noodle_array_to_file (float *array, NDL_File &fo, uint16_t n) |
Write an array of n floats to fo (an opened file handler), one value per line. No file open and close operations. | |
| void | noodle_grid_to_file (byte *grid, NDL_File &fo, uint16_t n) |
Write an n× grid to fo (opened file handler) as bytes, row-major. No file open and close operations. | |
| void | noodle_grid_to_file (float *grid, NDL_File &fo, uint16_t n) |
Write an n× grid to fo (an opened file handler), row-major. | |
| void | noodle_grid_from_file (NDL_File &fi, float *buffer, uint16_t K) |
2D Convolution | |
Packed-file conventions:
Padding:
Requires temporary buffers set via noodle_setup_temp_buffers. Buffer sizes are typically W×W floats, used as per-channel scratch space. | |
| uint16_t | noodle_conv_byte (const char *in_fn, uint16_t n_inputs, uint16_t n_outputs, const char *out_fn, uint16_t W, const Conv &conv, const Pool &pool, CBFPtr progress_cb=NULL) |
| File→File 2D conv with BYTE input feature maps. | |
| uint16_t | noodle_conv_float (const char *in_fn, uint16_t n_inputs, uint16_t n_outputs, const char *out_fn, uint16_t W, const Conv &conv, const Pool &pool, CBFPtr progress_cb=NULL) |
| File→File 2D conv with FLOAT input feature maps. | |
| uint16_t | noodle_conv_float (const char *in_fn, uint16_t n_inputs, uint16_t n_outputs, float *output, uint16_t W, const Conv &conv, const Pool &pool, CBFPtr progress_cb=NULL) |
| File→Memory 2D conv with FLOAT inputs; writes [O, Wo, Wo] tensor to output. | |
| uint16_t | noodle_conv_float (float *input, uint16_t n_inputs, uint16_t n_outputs, const char *out_fn, uint16_t W, const Conv &conv, const Pool &pool, CBFPtr progress_cb=NULL) |
| Memory→File 2D conv with FLOAT inputs and in-file conv parameters. | |
| uint16_t | noodle_conv_float (float *input, uint16_t n_inputs, uint16_t n_outputs, const char *out_fn, uint16_t W, const ConvMem &conv, const Pool &pool, CBFPtr progress_cb=NULL) |
| Memory→File 2D conv with FLOAT inputs and in-varibale conv parameters. | |
| uint16_t | noodle_conv_float (float *input, uint16_t n_inputs, uint16_t n_outputs, float *output, uint16_t W, const Conv &conv, const Pool &pool, CBFPtr progress_cb=NULL) |
| Memory→Memory 2D conv with FLOAT inputs and in-file conv parameters. | |
| uint16_t | noodle_conv_float (float *input, uint16_t n_inputs, uint16_t n_outputs, float *output, uint16_t W, const ConvMem &conv, const Pool &pool, CBFPtr progress_cb=NULL) |
1D Convolution | |
| |
| uint16_t | noodle_conv1d (const char *in_fn, uint16_t n_inputs, const char *out_fn, uint16_t n_outputs, uint16_t W, const Conv &conv, const Pool &pool, CBFPtr progress_cb=NULL) |
| uint16_t | noodle_conv1d (const char *in_fn, uint16_t n_inputs, const char *out_fn, uint16_t n_outputs, uint16_t W, const Conv &conv, CBFPtr progress_cb=NULL) |
| uint16_t | noodle_conv1d (float *in, uint16_t n_inputs, float *out, uint16_t n_outputs, uint16_t W, const ConvMem &conv, CBFPtr progress_cb=NULL) |
| uint16_t | noodle_conv1d (const char *in_fn, uint16_t n_inputs, const char *out_fn, uint16_t n_outputs, uint16_t W, const ConvMem &conv, CBFPtr progress_cb) |
| uint16_t | noodle_conv1d (float *in, uint16_t n_inputs, const char *out_fn, uint16_t n_outputs, uint16_t W, const ConvMem &conv, CBFPtr progress_cb) |
| uint16_t | noodle_conv1d (const char *in_fn, uint16_t n_inputs, float *out, uint16_t n_outputs, uint16_t W, const ConvMem &conv, CBFPtr progress_cb) |
Activations | |
| uint16_t | noodle_soft_max (float *input_output, uint16_t n) |
| uint16_t | noodle_sigmoid (float *input_output, uint16_t n) |
| uint16_t | noodle_relu (float *input_output, uint16_t n) |
Fully Connected Network | |
| uint16_t | noodle_fcn (const int8_t *input, uint16_t n_inputs, uint16_t n_outputs, const char *out_fn, const FCNFile &fcn, CBFPtr progress_cb=NULL) |
| uint16_t | noodle_fcn (const char *in_fn, uint16_t n_inputs, uint16_t n_outputs, const char *out_fn, const FCNFile &fcn, CBFPtr progress_cb=NULL) |
| uint16_t | noodle_fcn (const float *input, uint16_t n_inputs, uint16_t n_outputs, float *output, const FCNMem &fcn, CBFPtr progress_cb=NULL) |
| uint16_t | noodle_fcn (const byte *input, uint16_t n_inputs, uint16_t n_outputs, float *output, const FCNFile &fcn, CBFPtr progress_cb=NULL) |
| uint16_t | noodle_fcn (const int8_t *input, uint16_t n_inputs, uint16_t n_outputs, float *output, const FCNFile &fcn, CBFPtr progress_cb=NULL) |
| uint16_t | noodle_fcn (const char *in_fn, uint16_t n_inputs, uint16_t n_outputs, float *output, const FCNFile &fcn, CBFPtr progress_cb=NULL) |
| uint16_t | noodle_fcn (const float *input, uint16_t n_inputs, uint16_t n_outputs, float *output, const FCNFile &fcn, CBFPtr progress_cb) |
| uint16_t | noodle_fcn (const float *input, uint16_t n_inputs, uint16_t n_outputs, const char *out_fn, const FCNFile &fcn, CBFPtr progress_cb) |
Tensor Reshaping | |
| uint16_t | noodle_flat (const char *in_fn, float *output, uint16_t V, uint16_t n_filters) |
| uint16_t | noodle_flat (float *input, float *output, uint16_t V, uint16_t n_filters) |
| uint16_t | noodle_gap (float *inout, uint16_t C, uint16_t W) |
| void | noodle_find_max (float *input, uint16_t n, float &max_val, uint16_t &max_idx) |
2D Depth-wise Convolution | |
| uint16_t | noodle_dwconv_float (const char *in_fn, uint16_t n_channels, const char *out_fn, uint16_t W, const Conv &conv, const Pool &pool, CBFPtr progress_cb) |
| uint16_t | noodle_dwconv_float (float *input, uint16_t n_channels, float *output, uint16_t W, const Conv &conv, const Pool &pool, CBFPtr progress_cb) |
| uint16_t | noodle_dwconv_float (float *input, uint16_t n_channels, float *output, uint16_t W, const ConvMem &conv, const Pool &pool, CBFPtr progress_cb) |
| void | noodle_unpack_bn_params (const float *bn_params, uint16_t C, const float **gamma, const float **beta, const float **mean, const float **var) |
Batch Normalization | |
| uint16_t | noodle_bn (float *x, uint16_t C, uint16_t W, const float *gamma, const float *beta, const float *mean, const float *var, float eps=1e-3) |
| uint16_t | noodle_bn (float *x, uint16_t C, uint16_t W, const float *bn_params, float eps=1e-3) |
| uint16_t | noodle_bn_relu (float *x, uint16_t C, uint16_t W, const float *gamma, const float *beta, const float *mean, const float *var, float eps=1e-3) |
| uint16_t | noodle_bn_relu (float *x, uint16_t C, uint16_t W, const float *bn_params, float eps=1e-3) |
Public functions, types, and configuration intended for application use.
| typedef void(* CBFPtr) (float progress) |
Progress callback type used by long-running routines.
| progress | A normalized progress in [0,1], monotonically nondecreasing. |
| void noodle_array_from_file | ( | const char * | fn, |
| float * | buffer, | ||
| uint16_t | K | ||
| ) |
Read a float array of length K from fn (one value per line).
| void noodle_array_from_file | ( | NDL_File & | fi, |
| float * | buffer, | ||
| uint16_t | K | ||
| ) |
Read a float array of length K from an opened file handler fi (one value per line).
| void noodle_array_to_file | ( | float * | array, |
| const char * | fn, | ||
| uint16_t | n | ||
| ) |
Write an array of n floats to fn, one value per line. File will be opened and closed.
| void noodle_array_to_file | ( | float * | array, |
| NDL_File & | fo, | ||
| uint16_t | n | ||
| ) |
Write an array of n floats to fo (an opened file handler), one value per line. No file open and close operations.
| uint16_t noodle_bn | ( | float * | x, |
| uint16_t | C, | ||
| uint16_t | W, | ||
| const float * | bn_params, | ||
| float | eps = 1e-3 |
||
| ) |
Batch Normalization for a channel-first tensor in memory.
| x | Pointer to the input tensor in [C][W][W] layout. |
| C | Number of channels. |
| W | Width/height of each channel plane. |
| bn_params | Pointer to the packed batch normalization parameters. |
| eps | Small constant to avoid division by zero. |
| uint16_t noodle_bn | ( | float * | x, |
| uint16_t | C, | ||
| uint16_t | W, | ||
| const float * | gamma, | ||
| const float * | beta, | ||
| const float * | mean, | ||
| const float * | var, | ||
| float | eps = 1e-3 |
||
| ) |
Batch Normalization for a channel-first tensor in memory.
| x | Pointer to the input tensor in [C][W][W] layout. |
| C | Number of channels. |
| W | Width/height of each channel plane. |
| gamma | Pointer to the per-channel scale parameters. |
| beta | Pointer to the per-channel shift parameters. |
| mean | Pointer to the per-channel mean parameters. |
| var | Pointer to the per-channel variance parameters. |
| eps | Small constant to avoid division by zero. |
| uint16_t noodle_bn_relu | ( | float * | x, |
| uint16_t | C, | ||
| uint16_t | W, | ||
| const float * | bn_params, | ||
| float | eps = 1e-3 |
||
| ) |
| uint16_t noodle_bn_relu | ( | float * | x, |
| uint16_t | C, | ||
| uint16_t | W, | ||
| const float * | gamma, | ||
| const float * | beta, | ||
| const float * | mean, | ||
| const float * | var, | ||
| float | eps = 1e-3 |
||
| ) |
Batch Normalization followed by ReLU for a channel-first tensor in memory.
| x | Pointer to the input tensor in [C][W][W] layout. |
| C | Number of channels. |
| W | Width/height of each channel plane. |
| gamma | Pointer to the per-channel scale parameters. |
| beta | Pointer to the per-channel shift parameters. |
| mean | Pointer to the per-channel mean parameters. |
| var | Pointer to the per-channel variance parameters. |
| eps | Small constant to avoid division by zero. |
| uint16_t noodle_conv1d | ( | const char * | in_fn, |
| uint16_t | n_inputs, | ||
| const char * | out_fn, | ||
| uint16_t | n_outputs, | ||
| uint16_t | W, | ||
| const Conv & | conv, | ||
| CBFPtr | progress_cb = NULL |
||
| ) |
File CHW→File CHW 1D convolution with bias+activation and NO pooling stage.
Semantics as above but appends raw conv+bias(+ReLU) sequences for each output channel to out_fn.
| in_fn | Packed input filename (CHW). |
| n_inputs | Number of input channels I. |
| out_fn | Packed output filename (CHW). |
| n_outputs | Number of output channels O. |
| W | Input length. |
| conv | Convolution parameters (K, P, S, weight_fn, bias_fn, act). |
| progress_cb | Optional progress callback in [0,1]. |
| uint16_t noodle_conv1d | ( | const char * | in_fn, |
| uint16_t | n_inputs, | ||
| const char * | out_fn, | ||
| uint16_t | n_outputs, | ||
| uint16_t | W, | ||
| const Conv & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb = NULL |
||
| ) |
File CHW→File CHW 1D convolution with optional bias+activation and a pooling stage.
This follows the same I/O convention as noodle_conv_float():
in_fn is a single packed input file containing all input channels in CHW order (for 1D: C then W samples, one channel after another).out_fn is a single packed output file; for each output channel O we append either the pooled sequence or the raw sequence (depending on overload).conv.weight_fn in the order: for O in [0..n_outputs) and I in [0..n_inputs), read K floats (kernel taps).conv.bias_fn (one float per output channel).| in_fn | Packed input filename (CHW). |
| n_inputs | Number of input channels I. |
| out_fn | Packed output filename (CHW). |
| n_outputs | Number of output channels O. |
| W | Input length. |
| conv | Convolution parameters (K, P, S, weight_fn, bias_fn, act). |
| pool | Pool parameters (kernel M, stride T). |
| progress_cb | Optional progress callback in [0,1]. |
| uint16_t noodle_conv1d | ( | const char * | in_fn, |
| uint16_t | n_inputs, | ||
| const char * | out_fn, | ||
| uint16_t | n_outputs, | ||
| uint16_t | W, | ||
| const ConvMem & | conv, | ||
| CBFPtr | progress_cb | ||
| ) |
| uint16_t noodle_conv1d | ( | const char * | in_fn, |
| uint16_t | n_inputs, | ||
| float * | out, | ||
| uint16_t | n_outputs, | ||
| uint16_t | W, | ||
| const ConvMem & | conv, | ||
| CBFPtr | progress_cb | ||
| ) |
| uint16_t noodle_conv1d | ( | float * | in, |
| uint16_t | n_inputs, | ||
| const char * | out_fn, | ||
| uint16_t | n_outputs, | ||
| uint16_t | W, | ||
| const ConvMem & | conv, | ||
| CBFPtr | progress_cb | ||
| ) |
| uint16_t noodle_conv1d | ( | float * | in, |
| uint16_t | n_inputs, | ||
| float * | out, | ||
| uint16_t | n_outputs, | ||
| uint16_t | W, | ||
| const ConvMem & | conv, | ||
| CBFPtr | progress_cb = NULL |
||
| ) |
Memory→Memory 1D convolution with optional bias+activation and NO pooling stage. This operation does NOT need temp buffers!
| in | Input array (CHW). |
| n_inputs | Number of input channels I. |
| out | Output array (CHW). |
| n_outputs | Number of output channels O. |
| W | Input length. |
| conv | Convolution parameters (K, P, S, weight_fn, bias_fn, act). |
| progress_cb | Optional progress callback in [0,1]. |
| uint16_t noodle_conv_byte | ( | const char * | in_fn, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| const char * | out_fn, | ||
| uint16_t | W, | ||
| const Conv & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb = NULL |
||
| ) |
File→File 2D conv with BYTE input feature maps.
| uint16_t noodle_conv_float | ( | const char * | in_fn, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| const char * | out_fn, | ||
| uint16_t | W, | ||
| const Conv & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb = NULL |
||
| ) |
File→File 2D conv with FLOAT input feature maps.
| uint16_t noodle_conv_float | ( | const char * | in_fn, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| float * | output, | ||
| uint16_t | W, | ||
| const Conv & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb = NULL |
||
| ) |
File→Memory 2D conv with FLOAT inputs; writes [O, Wo, Wo] tensor to output.
| uint16_t noodle_conv_float | ( | float * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| const char * | out_fn, | ||
| uint16_t | W, | ||
| const Conv & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb = NULL |
||
| ) |
Memory→File 2D conv with FLOAT inputs and in-file conv parameters.
| uint16_t noodle_conv_float | ( | float * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| const char * | out_fn, | ||
| uint16_t | W, | ||
| const ConvMem & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb = NULL |
||
| ) |
Memory→File 2D conv with FLOAT inputs and in-varibale conv parameters.
| uint16_t noodle_conv_float | ( | float * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| float * | output, | ||
| uint16_t | W, | ||
| const Conv & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb = NULL |
||
| ) |
Memory→Memory 2D conv with FLOAT inputs and in-file conv parameters.
| uint16_t noodle_conv_float | ( | float * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| float * | output, | ||
| uint16_t | W, | ||
| const ConvMem & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb = NULL |
||
| ) |
Memory→Memory 2D conv with FLOAT inputs and in-variable conv parameters.
| float * noodle_create_buffer | ( | uint16_t | size | ) |
Allocate a raw float buffer of size bytes.
| void noodle_delete_buffer | ( | float * | buffer | ) |
Free a buffer allocated by noodle_create_buffer.
| void noodle_delete_file | ( | const char * | fn | ) |
Delete a file if it exists.
| uint16_t noodle_dwconv_float | ( | const char * | in_fn, |
| uint16_t | n_channels, | ||
| const char * | out_fn, | ||
| uint16_t | W, | ||
| const Conv & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb | ||
| ) |
Depthwise convolution (float input/output; params from files).
For each input channel I, reads the I-th input feature map from in_fn (tokenized by I), convolves it with the depthwise kernel read from conv.weight_fn (also tokenized by I), adds bias from conv.bias_fn (one bias per input channel), applies activation, and writes the output feature map to out_fn (tokenized by I). Requires temp buffers set via noodle_setup_temp_buffers.
| in_fn | Base input filename template (receives I). |
| n_channels | Number of input/output channels. |
| out_fn | Base output filename template (receives I). |
| W | Input width/height. |
| conv | Convolution parameters (K, P, S, weight_fn, bias_fn, act). |
| pool | Pool parameters (kernel M, stride T). |
| progress_cb | Optional progress callback in [0,1]. |
| uint16_t noodle_dwconv_float | ( | float * | input, |
| uint16_t | n_channels, | ||
| float * | output, | ||
| uint16_t | W, | ||
| const Conv & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb | ||
| ) |
Memory → memory depthwise conv (float input).
Assumes:
| input | Pointer to the input tensor in [C][W][W] layout. |
| n_channels | Number of input/output channels. |
| output | Pointer to the output tensor in [C][Wo][Wo] layout. |
| W | Input width/height. |
| conv | Convolution parameters (K, P, S, weight_fn, bias_fn, act). |
| pool | Pool parameters (kernel M, stride T). |
| progress_cb | Optional progress callback in [0,1]. |
| uint16_t noodle_dwconv_float | ( | float * | input, |
| uint16_t | n_channels, | ||
| float * | output, | ||
| uint16_t | W, | ||
| const ConvMem & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb | ||
| ) |
Memory → memory depthwise conv (float input) with in-variable weights/bias. Assumes:
| input | Pointer to the input tensor in [C][W][W] layout. |
| n_channels | Number of input/output channels. |
| output | Pointer to the output tensor in [C][Wo][Wo] layout. |
| W | Input width/height. |
| conv | Convolution parameters with in-variable weights/bias. |
| pool | Pool parameters (kernel M, stride T). |
| progress_cb | Optional progress callback in [0,1]. |
| uint16_t noodle_fcn | ( | const byte * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| float * | output, | ||
| const FCNFile & | fcn, | ||
| CBFPtr | progress_cb = NULL |
||
| ) |
Memory→Memory fully-connected layer (byte inputs; params from files).
| input | Byte array of length n_inputs (0..255 interpreted as float). |
| n_inputs | Number of inputs. |
| n_outputs | Number of outputs. |
| output | Float array of length n_outputs (written). |
| fcn | Filenames for weights/bias and activation mode. |
| progress_cb | Optional progress callback. |
| uint16_t noodle_fcn | ( | const char * | in_fn, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| const char * | out_fn, | ||
| const FCNFile & | fcn, | ||
| CBFPtr | progress_cb = NULL |
||
| ) |
File→File fully-connected layer (float text inputs; params from files).
For each output neuron O, rewinds in_fn, accumulates dot(W[O], x) + b[O], applies activation, and appends to out_fn.
| in_fn | Input filename containing n_inputs floats (one per line). |
| n_inputs | Number of inputs. |
| n_outputs | Number of outputs. |
| out_fn | Output filename (appends/overwrites as created). |
| fcn | Filenames for weights/bias. |
| progress_cb | Optional progress callback in [0,1]. |
| uint16_t noodle_fcn | ( | const char * | in_fn, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| float * | output, | ||
| const FCNFile & | fcn, | ||
| CBFPtr | progress_cb = NULL |
||
| ) |
File→Memory fully-connected layer (float output; params from files).
Reads inputs from in_fn for each output neuron O, computing y[O] = dot(W[O], x) + b[O], then applies activation.
| in_fn | Input filename with n_inputs floats per forward pass. |
| n_inputs | Number of inputs. |
| n_outputs | Number of outputs. |
| output | Float array of length n_outputs (written). |
| fcn | Filenames for weights/bias. |
| progress_cb | Optional progress callback. |
| uint16_t noodle_fcn | ( | const float * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| const char * | out_fn, | ||
| const FCNFile & | fcn, | ||
| CBFPtr | progress_cb | ||
| ) |
Memory→File fully-connected layer (float inputs; params from files).
Computes y = W·x + b, optionally applies activation, and writes n_outputs lines to out_fn.
| input | Pointer to n_inputs float values. |
| n_inputs | Number of inputs. |
| n_outputs | Number of outputs. |
| out_fn | Output filename (one float per line). |
| fcn | Filenames for weights and bias; weights read row-major [O, I]. |
| progress_cb | Optional progress callback in [0,1]. |
| uint16_t noodle_fcn | ( | const float * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| float * | output, | ||
| const FCNFile & | fcn, | ||
| CBFPtr | progress_cb | ||
| ) |
Memory→Memory fully-connected layer (float output; params from files).
Reads inputs from input for each output neuron O, computing y[O] = dot(W[O], x) + b[O], then applies activation.
| input | Float array of length n_inputs. |
| n_inputs | Number of inputs. |
| n_outputs | Number of outputs. |
| output | Float array of length n_outputs (written). |
| fcn | Filenames for weights/bias. |
| progress_cb | Optional progress callback. |
| uint16_t noodle_fcn | ( | const float * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| float * | output, | ||
| const FCNMem & | fcn, | ||
| CBFPtr | progress_cb = NULL |
||
| ) |
Memory→Memory fully-connected layer (float inputs; explicit in-variable weights/bias).
Weights are row-major [n_outputs, n_inputs] and biases length n_outputs.
| input | Float array of length n_inputs. |
| n_inputs | Number of inputs. |
| n_outputs | Number of outputs. |
| output | Float array of length n_outputs (written). |
| fcn | in-variable weights/bias and activation. |
| progress_cb | Optional progress callback in [0,1]. |
| uint16_t noodle_fcn | ( | const int8_t * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| const char * | out_fn, | ||
| const FCNFile & | fcn, | ||
| CBFPtr | progress_cb = NULL |
||
| ) |
Memory→File fully-connected layer (int8 inputs; weights/bias from files).
Computes y = W·x + b, optionally applies ReLU, and writes n_outputs lines to out_fn.
| input | Pointer to n_inputs int8 values. |
| n_inputs | Number of inputs. |
| n_outputs | Number of outputs. |
| out_fn | Output filename (one float per line). |
| fcn | Filenames for weights and bias; weights read row-major [O, I]. |
| progress_cb | Optional progress callback in [0,1]. |
| uint16_t noodle_fcn | ( | const int8_t * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| float * | output, | ||
| const FCNFile & | fcn, | ||
| CBFPtr | progress_cb = NULL |
||
| ) |
Memory→Memory fully-connected layer (int8 inputs; params from files).
| input | Int8 array of length n_inputs. |
| n_inputs | Number of inputs. |
| n_outputs | Number of outputs. |
| output | Float array of length n_outputs (written). |
| fcn | Filenames for weights/bias and activation mode. |
| progress_cb | Optional progress callback. |
| void noodle_find_max | ( | float * | input, |
| uint16_t | n, | ||
| float & | max_val, | ||
| uint16_t & | max_idx | ||
| ) |
Find the maximum value and its index in a float array.
| input | Pointer to the input float array. |
| n | Length of the input array. |
| max_val | Reference to store the maximum value found. |
| max_idx | Reference to store the index of the maximum value. |
| uint16_t noodle_flat | ( | const char * | in_fn, |
| float * | output, | ||
| uint16_t | V, | ||
| uint16_t | n_filters | ||
| ) |
File→Memory flatten: reads n_filters feature maps from files named by in_fn
(tokenized by O via ::noodle_n2ll at positions 4/6 as appropriate) and writes a vector of length V×V×n_filters in row-major [i* n_filters + k].
| in_fn | Base filename of pooled feature maps (receives O). |
| output | Output buffer of length V×V×n_filters. |
| V | Spatial size (width=height). |
| n_filters | Number of channels (O). |
| uint16_t noodle_flat | ( | float * | input, |
| float * | output, | ||
| uint16_t | V, | ||
| uint16_t | n_filters | ||
| ) |
Memory→Memory flatten: flattens [O, V, V] into a vector of length V×V×n_filters.
| input | Base pointer to stacked feature maps [O, V, V]. |
| output | Output buffer of length V×V×n_filters. |
| V | Spatial size. |
| n_filters | Number of channels O. |
| bool noodle_fs_init | ( | ) |
Initialize SD/FS backend with default pins/settings.
| bool noodle_fs_init | ( | uint8_t | clk_pin, |
| uint8_t | cmd_pin, | ||
| uint8_t | d0_pin | ||
| ) |
Initialize SD/FS backend (pins variant is meaningful only for SD_MMC).
| bool noodle_fs_init | ( | uint8_t | clk_pin, |
| uint8_t | cmd_pin, | ||
| uint8_t | d0_pin, | ||
| uint8_t | d1_pin, | ||
| uint8_t | d2_pin, | ||
| uint8_t | d3_pin | ||
| ) |
Initialize SD/FS backend with default pins/settings.
| bool noodle_fs_init | ( | uint8_t | cs_pin | ) |
Initialize SD/FS backend with a specific CS_PIN.
| uint16_t noodle_gap | ( | float * | inout, |
| uint16_t | C, | ||
| uint16_t | W | ||
| ) |
Global Average Pooling for a channel-first tensor in memory.
| x_chw | Pointer to the input tensor in [C][W][W] layout. |
| C | Number of channels. |
| W | Width/height of each channel plane. |
| void noodle_grid_from_file | ( | const char * | fn, |
| byte * | buffer, | ||
| uint16_t | K | ||
| ) |
Read an K× grid (stored as float) from K bytefn into buffer.
| void noodle_grid_from_file | ( | const char * | fn, |
| float * | buffer, | ||
| uint16_t | K | ||
| ) |
Read an K × K grid (stored as float) from fn into buffer.
| void noodle_grid_from_file | ( | const char * | fn, |
| int8_t * | buffer, | ||
| uint16_t | K | ||
| ) |
Read an K × K grid (stored as float) from fn into buffer.
| void noodle_grid_from_file | ( | NDL_File & | fi, |
| byte * | buffer, | ||
| uint16_t | K | ||
| ) |
Read an K × K grid (stored as byte) from fi (opened file handler) into buffer.
| void noodle_grid_from_file | ( | NDL_File & | fi, |
| float * | buffer, | ||
| uint16_t | K | ||
| ) |
Read an K × K grid (stored as float) from an opened file handler fi into buffer.
| void noodle_grid_from_file | ( | NDL_File & | fi, |
| int8_t * | buffer, | ||
| uint16_t | K | ||
| ) |
Read an K × K grid (stored as int8) from fi (opened file handler) into buffer.
| void noodle_grid_to_file | ( | byte * | grid, |
| const char * | fn, | ||
| uint16_t | n | ||
| ) |
Write an n× grid to n bytefn as bytes, row-major. File will be opened and closed.
| void noodle_grid_to_file | ( | byte * | grid, |
| NDL_File & | fo, | ||
| uint16_t | n | ||
| ) |
Write an n× grid to n bytefo (opened file handler) as bytes, row-major. No file open and close operations.
| void noodle_grid_to_file | ( | float * | grid, |
| const char * | fn, | ||
| uint16_t | n | ||
| ) |
Write an n× grid to n floatfn, row-major.
| void noodle_grid_to_file | ( | float * | grid, |
| NDL_File & | fo, | ||
| uint16_t | n | ||
| ) |
Write an n× grid to n floatfo (an opened file handler), row-major.
| size_t noodle_read_bytes_until | ( | NDL_File & | file, |
| char | terminator, | ||
| char * | buffer, | ||
| size_t | length | ||
| ) |
Read bytes from a file until a terminator or length-1 (NULL terminated).
| file | Open file handle. |
| terminator | Stop when this character is read (not stored). |
| buffer | Destination buffer (will always be NULL terminated). |
| length | Maximum bytes to write into buffer including the NULL. |
| void noodle_read_top_line | ( | const char * | fn, |
| char * | line, | ||
| size_t | maxlen | ||
| ) |
Read the first line of a given text file.
| fn | File name to read. |
| line | Reading result. |
| maxlen | Maximum character length to read. |
| uint16_t noodle_relu | ( | float * | input_output, |
| uint16_t | n | ||
| ) |
In-place ReLU over a length-n vector. Returns n.
| void noodle_reset_buffer | ( | float * | buffer, |
| uint16_t | n | ||
| ) |
Fill buffer with zeros (n floats).
| void noodle_setup_temp_buffers | ( | void * | b1, |
| void * | b2 | ||
| ) |
Provide two reusable temporary buffers used internally by file-streaming operations.Must be called before conv/FCN variants that read from files. Two temp buffers are needed for operations that read from a file. For C*W*W tensor, the buffer should be W*W.
| b1 | Buffer #1 (input scratch). See size guidance above. |
| b2 | Buffer #2 (float accumulator). See size guidance above. |
| void noodle_setup_temp_buffers | ( | void * | b2 | ) |
Provide a single reusable temporary buffer used internally by file-streaming ops.Must be called before conv/FCN variants that read from files. One temp buffer is needed for operations that reads from a variable. Hence, only output accumulator buffe is needed. For C*W*W tensor, the buffer should be W*W.
| b2 | Buffer #2 (float accumulator). See size guidance above. |
| uint16_t noodle_sigmoid | ( | float * | input_output, |
| uint16_t | n | ||
| ) |
In-place sigmoid over a length-n vector. Returns n.
|
inline |
Slice a stacked [Z, W, W] tensor laid out as contiguous planes.
| flat | Pointer to base of the contiguous array. |
| W | Width/height of each 2D plane. |
| z | Plane index to slice. |
z (no bounds checks). | uint16_t noodle_soft_max | ( | float * | input_output, |
| uint16_t | n | ||
| ) |
In-place softmax over a length-n vector. Returns n.
| void noodle_unpack_bn_params | ( | const float * | bn_params, |
| uint16_t | C, | ||
| const float ** | gamma, | ||
| const float ** | beta, | ||
| const float ** | mean, | ||
| const float ** | var | ||
| ) |
Unpack batch normalization parameters from a flat array.
| bn_params | Pointer to the packed batch normalization parameters. |
| C | Number of channels. |
| gamma | Output pointer to the per-channel scale parameters. |
| beta | Output pointer to the per-channel shift parameters. |
| mean | Output pointer to the per-channel mean parameters. |
| var | Output pointer to the per-channel variance parameters. |