Files | |
| file | noodle.h |
| Public Noodle API for small CNN/ML inference on microcontrollers. | |
| file | noodle_buffer.h |
| Grow-only float buffers used by NoodleBuffer convolution overloads. | |
Classes | |
| struct | Conv |
| File-backed convolution parameter bundle. More... | |
| struct | ConvFile |
| File-backed convolution parameter bundle alias. More... | |
| struct | ConvMem |
| Memory-backed convolution parameter bundle. More... | |
| struct | ConvProgmem |
| Near-PROGMEM convolution parameter bundle. More... | |
| struct | Pool |
| Valid-pooling parameter bundle. More... | |
| struct | FCN |
| File-backed fully connected parameter bundle. More... | |
| struct | FCNFile |
| File-backed fully connected parameter bundle alias. More... | |
| struct | FCNMem |
| Memory-backed fully connected parameter bundle. More... | |
| struct | FCNProgmem |
| Far-PROGMEM fully connected parameter bundle for AVR. More... | |
| struct | NoodleBuffer |
| Grow-only float buffer managed by Noodle. More... | |
Typedefs | |
| typedef void(* | CBFPtr) (float progress) |
| Progress callback used by long-running layer routines. | |
Enumerations | |
| enum | Activation : uint8_t { ACT_NONE = 0 , ACT_RELU = 1 , ACT_SOFTMAX = 2 } |
| Activation applied after bias where supported. More... | |
Functions | |
| static float | noodle_pgm_float (const float *p, uint32_t idx) |
| Read a float from normal memory or near AVR PROGMEM. | |
| bool | noodle_fs_init (uint8_t clk_pin, uint8_t cmd_pin, uint8_t d0_pin) |
| Initialize SD_MMC with explicit 1-bit pins, or default-init other backends. | |
| 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_MMC with explicit 4-bit pins, or default-init other backends. | |
| bool | noodle_fs_init () |
| Initialize the selected filesystem backend with default settings. | |
| bool | noodle_fs_init (uint8_t cs_pin) |
| Initialize the selected filesystem backend with an SPI chip-select pin. | |
| bool | noodle_fs_init (uint8_t cs_pin, SPIClass &spi, uint8_t sck_mhz) |
| Initialize SdFat with an explicit SPI bus and clock speed. | |
| void | noodle_read_top_line (const char *fn, char *line, size_t maxlen) |
| Read the first line from a text file. | |
| void | noodle_delete_file (const char *fn) |
| Delete a file through the selected filesystem backend. | |
| size_t | noodle_read_bytes_until (NDL_File &file, char terminator, char *buffer, size_t length) |
| Read bytes until a terminator or until the buffer is full. | |
| void | noodle_write_float (NDL_File &f, float d) |
| Write a float using NOODLE_FILE_FORMAT. | |
| float | noodle_read_float (NDL_File &f) |
| Read a float using NOODLE_FILE_FORMAT. | |
| byte | noodle_read_byte (NDL_File &f) |
| Read a byte using NOODLE_FILE_FORMAT. | |
| void | noodle_write_byte (NDL_File &f, byte d) |
| Write a byte using NOODLE_FILE_FORMAT. | |
| void | noodle_setup_temp_buffers (void *b1, void *b2) |
| Install caller-owned internal scratch buffers. | |
| void | noodle_setup_temp_buffers (void *b2) |
| Install only the caller-owned accumulation scratch buffer. | |
| void | noodle_temp_buffers_free (void) |
| Release automatically allocated internal scratch buffers. | |
| float * | noodle_create_buffer (uint16_t size) |
| Allocate a raw byte buffer and return it as a float pointer. | |
| 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 a float array to a file. | |
| void | noodle_grid_to_file (byte *grid, const char *fn, uint16_t n) |
| Write an n x n byte grid to a file in row-major order. | |
| void | noodle_grid_to_file (float *grid, const char *fn, uint16_t n) |
| Write an n x n float grid to a file in row-major order. | |
| void | noodle_array_from_file (const char *fn, float *buffer, uint16_t K) |
| Read a float array from a file. | |
| void | noodle_grid_from_file (const char *fn, byte *buffer, uint16_t K) |
| Read a K x K grid into a byte buffer. | |
| void | noodle_grid_from_file (const char *fn, int8_t *buffer, uint16_t K) |
| Read a K x K grid into an int8 buffer. | |
| void | noodle_grid_from_file (const char *fn, float *buffer, uint16_t K) |
| Read a K x K grid into a float buffer. | |
| void | noodle_buffer_init (NoodleBuffer *buf) |
| Initialize a NoodleBuffer. | |
| float * | noodle_buffer_require (NoodleBuffer *buf, size_t required_floats) |
| Ensure that a buffer can hold at least required_floats floats. | |
| void | noodle_buffer_free (NoodleBuffer *buf) |
| Release a NoodleBuffer. | |
| size_t | noodle_buffer_capacity (const NoodleBuffer *buf) |
| Return the buffer capacity in float elements. | |
| size_t | noodle_buffer_capacity_bytes (const NoodleBuffer *buf) |
| Return the buffer capacity in bytes. | |
File-backed layers | |
File-backed convolution APIs read packed input tensors from files, stream parameters from files or memory/PROGMEM, and write packed output tensors to a file. They return the output width/length, or 0 on allocation/open/shape failure. | |
| 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=0) |
| Run file-to-file 2D convolution on 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=0) |
| Run file-to-file 2D convolution on float 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 ConvMem &conv, const Pool &pool, CBFPtr progress_cb=0) |
| Run file-to-file 2D convolution with memory-backed parameters. | |
| 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 ConvProgmem &conv, const Pool &pool, CBFPtr progress_cb=0) |
| Run file-to-file 2D convolution with near-PROGMEM parameters. | |
| 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=0) |
| Run file-to-file 1D convolution with file-backed parameters and pooling. | |
| 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=0) |
| Run file-to-file 1D convolution with file-backed parameters. | |
| 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=0) |
| Run file-to-file 1D convolution with memory-backed parameters. | |
| 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=0) |
| Run file-to-file depthwise 2D convolution with file-backed parameters. | |
| uint16_t | noodle_dwconv_float (const char *in_fn, uint16_t n_channels, const char *out_fn, uint16_t W, const ConvProgmem &conv, const Pool &pool, CBFPtr progress_cb=0) |
| Run file-to-file depthwise 2D convolution with near-PROGMEM parameters. | |
| 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=0) |
| Run a fully connected layer from int8 memory to a file. | |
| uint16_t | noodle_fcn (const byte *input, uint16_t n_inputs, uint16_t n_outputs, const char *out_fn, const FCNFile &fcn, CBFPtr progress_cb=0) |
| Run a fully connected layer from byte memory to a file. | |
| 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=0) |
| Run a fully connected layer from a file to a file. | |
NoodleBuffer RAM-to-RAM layers | |
These overloads read input from input->data, grow | |
| uint16_t | noodle_conv_float (NoodleBuffer *input, uint16_t n_inputs, uint16_t n_outputs, NoodleBuffer *output, uint16_t W, const Conv &conv, const Pool &pool, CBFPtr progress_cb=0) |
| Run 2D convolution using file-backed parameters. | |
| uint16_t | noodle_conv_float (NoodleBuffer *input, uint16_t n_inputs, uint16_t n_outputs, NoodleBuffer *output, uint16_t W, const ConvMem &conv, const Pool &pool, CBFPtr progress_cb=0) |
| Run 2D convolution using memory-backed parameters. | |
| uint16_t | noodle_conv_float (NoodleBuffer *input, uint16_t n_inputs, uint16_t n_outputs, NoodleBuffer *output, uint16_t W, const ConvProgmem &conv, const Pool &pool, CBFPtr progress_cb=0) |
| Run 2D convolution using near-PROGMEM parameters. | |
| uint16_t | noodle_conv1d (NoodleBuffer *input, uint16_t n_inputs, NoodleBuffer *output, uint16_t n_outputs, uint16_t W, const ConvMem &conv, CBFPtr progress_cb=0) |
| Run 1D convolution using memory-backed parameters. | |
| uint16_t | noodle_conv1d (NoodleBuffer *input, uint16_t n_inputs, NoodleBuffer *output, uint16_t n_outputs, uint16_t W, const ConvMem &conv, const Pool &pool, CBFPtr progress_cb=0) |
| Run 1D convolution using memory-backed parameters and pooling. | |
| uint16_t | noodle_dwconv_float (NoodleBuffer *input, uint16_t n_channels, NoodleBuffer *output, uint16_t W, const Conv &conv, const Pool &pool, CBFPtr progress_cb=0) |
| Run depthwise 2D convolution using file-backed parameters. | |
| uint16_t | noodle_dwconv_float (NoodleBuffer *input, uint16_t n_channels, NoodleBuffer *output, uint16_t W, const ConvMem &conv, const Pool &pool, CBFPtr progress_cb=0) |
| Run depthwise 2D convolution using memory-backed parameters. | |
| uint16_t | noodle_dwconv_float (NoodleBuffer *input, uint16_t n_channels, NoodleBuffer *output, uint16_t W, const ConvProgmem &conv, const Pool &pool, CBFPtr progress_cb=0) |
| Run depthwise 2D convolution using near-PROGMEM parameters. | |
| uint16_t | noodle_conv_transpose_float (NoodleBuffer *input, uint16_t n_inputs, uint16_t n_outputs, NoodleBuffer *output, uint16_t W, const ConvMem &conv, CBFPtr progress_cb=0) |
| Run 2D transpose convolution using memory-backed parameters. | |
| uint16_t | noodle_fcn (NoodleBuffer *input, uint16_t n_inputs, uint16_t n_outputs, NoodleBuffer *output, const FCNMem &fcn, CBFPtr progress_cb=0) |
| Run a fully connected layer using memory-backed parameters. | |
| uint16_t | noodle_fcn (NoodleBuffer *input, uint16_t n_inputs, uint16_t n_outputs, NoodleBuffer *output, const FCNFile &fcn, CBFPtr progress_cb=0) |
| Run a fully connected layer using file-backed parameters. | |
| uint16_t | noodle_fcn (NoodleBuffer *input, uint16_t n_inputs, uint16_t n_outputs, NoodleBuffer *output, const FCNProgmem &fcn, CBFPtr progress_cb=0) |
| Run a fully connected layer using far-PROGMEM parameters. | |
| uint16_t | noodle_fcn (const byte *input, uint16_t n_inputs, uint16_t n_outputs, NoodleBuffer *output, const FCNFile &fcn, CBFPtr progress_cb=0) |
| Run a fully connected layer from byte memory to a NoodleBuffer. | |
| uint16_t | noodle_fcn (const int8_t *input, uint16_t n_inputs, uint16_t n_outputs, NoodleBuffer *output, const FCNFile &fcn, CBFPtr progress_cb=0) |
| Run a fully connected layer from int8 memory to a NoodleBuffer. | |
| uint16_t | noodle_fcn (const char *in_fn, uint16_t n_inputs, uint16_t n_outputs, NoodleBuffer *output, const FCNFile &fcn, CBFPtr progress_cb=0) |
| Run a fully connected layer from a file to a NoodleBuffer. | |
| uint16_t | noodle_fcn_progmem (NoodleBuffer *input, uint16_t n_inputs, uint16_t n_outputs, NoodleBuffer *output, const float *weight, const float *bias, Activation act, CBFPtr progress_cb=0) |
| Run a fully connected layer using near-PROGMEM weights. | |
| uint16_t | noodle_flat (const char *in_fn, NoodleBuffer *output, uint16_t V, uint16_t n_filters) |
| Flatten a packed file tensor into a NoodleBuffer. | |
| uint16_t | noodle_flat (NoodleBuffer *input, NoodleBuffer *output, uint16_t V, uint16_t n_filters) |
| Flatten a packed NoodleBuffer tensor into HWC-like order. | |
| uint16_t | noodle_reshape (NoodleBuffer *src_hwc, NoodleBuffer *dst_chw, uint16_t W, uint16_t C) |
| Convert HWC-like NoodleBuffer data to packed channel-first data. | |
| uint16_t | noodle_gap (NoodleBuffer *inout, uint16_t C, uint16_t W) |
| Apply global average pooling in place on packed channel-first maps. | |
| uint16_t | noodle_gmp (NoodleBuffer *inout, uint16_t C, uint16_t W) |
| Apply global max pooling in place on packed channel-first data. | |
| uint16_t | noodle_soft_max (NoodleBuffer *input_output, uint16_t n) |
| Apply numerically stabilized softmax in place on a NoodleBuffer. | |
| uint16_t | noodle_sigmoid (NoodleBuffer *input_output, uint16_t n) |
| Apply sigmoid in place on a NoodleBuffer. | |
| float | noodle_sigmoidf (float x) |
| Compute sigmoid for one scalar. | |
| uint16_t | noodle_logit (NoodleBuffer *input_output, uint16_t n) |
| Apply logistic sigmoid in place on a NoodleBuffer. | |
| uint16_t | noodle_relu (NoodleBuffer *input_output, uint16_t n) |
| Apply ReLU in place on a NoodleBuffer. | |
| void | noodle_find_max (NoodleBuffer *input, uint16_t n, float &max_val, uint16_t &max_idx) |
| Find the maximum value and its index in a NoodleBuffer vector. | |
| uint16_t | noodle_bn1d (NoodleBuffer *x, uint16_t N, const float *gamma, const float *beta, const float *mean, const float *var, float eps) |
| Apply 1D batch normalization in place to a NoodleBuffer vector. | |
| uint16_t | noodle_bn1d (NoodleBuffer *x, uint16_t N, const float *bn_params, float eps) |
| Apply 1D batch normalization from a packed parameter array. | |
| uint16_t | noodle_bn1d_relu (NoodleBuffer *x, uint16_t N, const float *gamma, const float *beta, const float *mean, const float *var, float eps) |
| Apply 1D batch normalization followed by ReLU in place. | |
| uint16_t | noodle_bn1d_relu (NoodleBuffer *x, uint16_t N, const float *bn_params, float eps) |
| Apply packed 1D batch normalization followed by ReLU in place. | |
| uint16_t | noodle_bn2d (NoodleBuffer *x, uint16_t C, uint16_t W, const float *gamma, const float *beta, const float *mean, const float *var, float eps) |
| Apply 2D channel-wise batch normalization in place. | |
| uint16_t | noodle_bn2d (NoodleBuffer *x, uint16_t C, uint16_t W, const float *bn_params, float eps) |
| Apply 2D channel-wise batch normalization from packed parameters. | |
| uint16_t | noodle_bn2d_relu (NoodleBuffer *x, uint16_t C, uint16_t W, const float *gamma, const float *beta, const float *mean, const float *var, float eps) |
| Apply 2D channel-wise batch normalization followed by ReLU. | |
| uint16_t | noodle_bn2d_relu (NoodleBuffer *x, uint16_t C, uint16_t W, const float *bn_params, float eps) |
| Apply packed 2D batch normalization followed by ReLU. | |
| uint16_t | noodle_bn (NoodleBuffer *x, uint16_t C, uint16_t W, const float *gamma, const float *beta, const float *mean, const float *var, float eps) |
| Backward-compatible alias for noodle_bn2d(). | |
| uint16_t | noodle_bn (NoodleBuffer *x, uint16_t C, uint16_t W, const float *bn_params, float eps) |
| Backward-compatible alias for packed-parameter noodle_bn2d(). | |
| uint16_t | noodle_bn_relu (NoodleBuffer *x, uint16_t C, uint16_t W, const float *gamma, const float *beta, const float *mean, const float *var, float eps) |
| Backward-compatible alias for noodle_bn2d_relu(). | |
| uint16_t | noodle_bn_relu (NoodleBuffer *x, uint16_t C, uint16_t W, const float *bn_params, float eps) |
| Backward-compatible alias for packed-parameter noodle_bn2d_relu(). | |
Public functions, types, and configuration intended for application code.
| typedef void(* CBFPtr) (float progress) |
Progress callback used by long-running layer routines.
| progress | Normalized progress, usually in the range [0, 1]. |
| enum Activation : uint8_t |
Activation applied after bias where supported.
| Enumerator | |
|---|---|
| ACT_NONE | Do not apply an activation. |
| ACT_RELU | Clamp negative values to zero. |
| ACT_SOFTMAX | Normalize a final output vector where supported. |
| void noodle_array_from_file | ( | const char * | fn, |
| float * | buffer, | ||
| uint16_t | K ) |
Read a float array from a file.
| fn | Input file. |
| buffer | Destination array with room for K floats. |
| K | Number of values to read. |
| void noodle_array_to_file | ( | float * | array, |
| const char * | fn, | ||
| uint16_t | n ) |
Write a float array to a file.
| array | Source array with n values. |
| fn | Output file. |
| n | Number of values to write. |
| uint16_t noodle_bn | ( | NoodleBuffer * | x, |
| uint16_t | C, | ||
| uint16_t | W, | ||
| const float * | bn_params, | ||
| float | eps ) |
Backward-compatible alias for packed-parameter noodle_bn2d().
Treats x as packed [C][W][W]. bn_params is packed as [gamma[C]][beta[C]][mean[C]][var[C]].
| x | Tensor buffer updated in place. |
| C | Number of channels. |
| W | Plane width and height. |
| bn_params | Packed batch-normalization parameters. |
| eps | Small value added to variance before inversion. |
W, or 0 when x has no data. | uint16_t noodle_bn | ( | NoodleBuffer * | x, |
| uint16_t | C, | ||
| uint16_t | W, | ||
| const float * | gamma, | ||
| const float * | beta, | ||
| const float * | mean, | ||
| const float * | var, | ||
| float | eps ) |
Backward-compatible alias for noodle_bn2d().
Treats x as packed [C][W][W].
| x | Tensor buffer updated in place. |
| C | Number of channels. |
| W | Plane width and height. |
| gamma | Scale parameters. |
| beta | Offset parameters. |
| mean | Moving-mean parameters. |
| var | Moving-variance parameters. |
| eps | Small value added to variance before inversion. |
W, or 0 when x has no data. | uint16_t noodle_bn1d | ( | NoodleBuffer * | x, |
| uint16_t | N, | ||
| const float * | bn_params, | ||
| float | eps ) |
Apply 1D batch normalization from a packed parameter array.
bn_params is packed as [gamma[N]][beta[N]][mean[N]][var[N]].
| x | Vector buffer updated in place. |
| N | Number of vector elements. |
| bn_params | Packed batch-normalization parameters. |
| eps | Small value added to variance before inversion. |
N, or 0 when x has no data. | uint16_t noodle_bn1d | ( | NoodleBuffer * | x, |
| uint16_t | N, | ||
| const float * | gamma, | ||
| const float * | beta, | ||
| const float * | mean, | ||
| const float * | var, | ||
| float | eps ) |
Apply 1D batch normalization in place to a NoodleBuffer vector.
gamma, beta, mean, and var each contain N values.
| x | Vector buffer updated in place. |
| N | Number of vector elements. |
| gamma | Scale parameters. |
| beta | Offset parameters. |
| mean | Moving-mean parameters. |
| var | Moving-variance parameters. |
| eps | Small value added to variance before inversion. |
N, or 0 when x has no data. | uint16_t noodle_bn1d_relu | ( | NoodleBuffer * | x, |
| uint16_t | N, | ||
| const float * | bn_params, | ||
| float | eps ) |
Apply packed 1D batch normalization followed by ReLU in place.
bn_params is packed as [gamma[N]][beta[N]][mean[N]][var[N]].
| x | Vector buffer updated in place. |
| N | Number of vector elements. |
| bn_params | Packed batch-normalization parameters. |
| eps | Small value added to variance before inversion. |
N, or 0 when x has no data. | uint16_t noodle_bn1d_relu | ( | NoodleBuffer * | x, |
| uint16_t | N, | ||
| const float * | gamma, | ||
| const float * | beta, | ||
| const float * | mean, | ||
| const float * | var, | ||
| float | eps ) |
Apply 1D batch normalization followed by ReLU in place.
gamma, beta, mean, and var each contain N values.
| x | Vector buffer updated in place. |
| N | Number of vector elements. |
| gamma | Scale parameters. |
| beta | Offset parameters. |
| mean | Moving-mean parameters. |
| var | Moving-variance parameters. |
| eps | Small value added to variance before inversion. |
N, or 0 when x has no data. | uint16_t noodle_bn2d | ( | NoodleBuffer * | x, |
| uint16_t | C, | ||
| uint16_t | W, | ||
| const float * | bn_params, | ||
| float | eps ) |
Apply 2D channel-wise batch normalization from packed parameters.
Treats x as packed [C][W][W]. bn_params is packed as [gamma[C]][beta[C]][mean[C]][var[C]].
| x | Tensor buffer updated in place. |
| C | Number of channels. |
| W | Plane width and height. |
| bn_params | Packed batch-normalization parameters. |
| eps | Small value added to variance before inversion. |
W, or 0 when x has no data. | uint16_t noodle_bn2d | ( | NoodleBuffer * | x, |
| uint16_t | C, | ||
| uint16_t | W, | ||
| const float * | gamma, | ||
| const float * | beta, | ||
| const float * | mean, | ||
| const float * | var, | ||
| float | eps ) |
Apply 2D channel-wise batch normalization in place.
Treats x as packed [C][W][W]. The parameter arrays each contain C values, one per channel.
| x | Tensor buffer updated in place. |
| C | Number of channels. |
| W | Plane width and height. |
| gamma | Scale parameters. |
| beta | Offset parameters. |
| mean | Moving-mean parameters. |
| var | Moving-variance parameters. |
| eps | Small value added to variance before inversion. |
W, or 0 when x has no data. | uint16_t noodle_bn2d_relu | ( | NoodleBuffer * | x, |
| uint16_t | C, | ||
| uint16_t | W, | ||
| const float * | bn_params, | ||
| float | eps ) |
Apply packed 2D batch normalization followed by ReLU.
Treats x as packed [C][W][W]. bn_params is packed as [gamma[C]][beta[C]][mean[C]][var[C]].
| x | Tensor buffer updated in place. |
| C | Number of channels. |
| W | Plane width and height. |
| bn_params | Packed batch-normalization parameters. |
| eps | Small value added to variance before inversion. |
W, or 0 when x has no data. | uint16_t noodle_bn2d_relu | ( | NoodleBuffer * | x, |
| uint16_t | C, | ||
| uint16_t | W, | ||
| const float * | gamma, | ||
| const float * | beta, | ||
| const float * | mean, | ||
| const float * | var, | ||
| float | eps ) |
Apply 2D channel-wise batch normalization followed by ReLU.
Treats x as packed [C][W][W]. The parameter arrays each contain C values, one per channel.
| x | Tensor buffer updated in place. |
| C | Number of channels. |
| W | Plane width and height. |
| gamma | Scale parameters. |
| beta | Offset parameters. |
| mean | Moving-mean parameters. |
| var | Moving-variance parameters. |
| eps | Small value added to variance before inversion. |
W, or 0 when x has no data. | uint16_t noodle_bn_relu | ( | NoodleBuffer * | x, |
| uint16_t | C, | ||
| uint16_t | W, | ||
| const float * | bn_params, | ||
| float | eps ) |
Backward-compatible alias for packed-parameter noodle_bn2d_relu().
Treats x as packed [C][W][W]. bn_params is packed as [gamma[C]][beta[C]][mean[C]][var[C]].
| x | Tensor buffer updated in place. |
| C | Number of channels. |
| W | Plane width and height. |
| bn_params | Packed batch-normalization parameters. |
| eps | Small value added to variance before inversion. |
W, or 0 when x has no data. | uint16_t noodle_bn_relu | ( | NoodleBuffer * | x, |
| uint16_t | C, | ||
| uint16_t | W, | ||
| const float * | gamma, | ||
| const float * | beta, | ||
| const float * | mean, | ||
| const float * | var, | ||
| float | eps ) |
Backward-compatible alias for noodle_bn2d_relu().
Treats x as packed [C][W][W].
| x | Tensor buffer updated in place. |
| C | Number of channels. |
| W | Plane width and height. |
| gamma | Scale parameters. |
| beta | Offset parameters. |
| mean | Moving-mean parameters. |
| var | Moving-variance parameters. |
| eps | Small value added to variance before inversion. |
W, or 0 when x has no data. | size_t noodle_buffer_capacity | ( | const NoodleBuffer * | buf | ) |
Return the buffer capacity in float elements.
| buf | Buffer descriptor to inspect. |
buf is NULL. | size_t noodle_buffer_capacity_bytes | ( | const NoodleBuffer * | buf | ) |
Return the buffer capacity in bytes.
| buf | Buffer descriptor to inspect. |
buf is NULL. | void noodle_buffer_free | ( | NoodleBuffer * | buf | ) |
Release a NoodleBuffer.
This frees the internal data pointer and resets the descriptor.
| buf | Buffer descriptor to release. Passing NULL is allowed. |
| void noodle_buffer_init | ( | NoodleBuffer * | buf | ) |
Initialize a NoodleBuffer.
Sets the data pointer to NULL and the capacity to zero. Call this before the first use of a stack- or static-allocated NoodleBuffer.
| buf | Buffer descriptor to initialize. Passing NULL is allowed. |
| float * noodle_buffer_require | ( | NoodleBuffer * | buf, |
| size_t | required_floats ) |
Ensure that a buffer can hold at least required_floats floats.
If the buffer is NULL, this allocates it. If the buffer is already large enough, this reuses it. If the buffer is too small, this allocates a larger block first, then frees the old block only after the new allocation succeeds.
| buf | Buffer descriptor. |
| required_floats | Required capacity in float elements. |
| 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 = 0 ) |
Run file-to-file 1D convolution with file-backed parameters.
This overload does not apply pooling.
| in_fn | Input file with packed [I][W] sequences. |
| n_inputs | Number of input channels. |
| out_fn | Output file for packed [O][V] sequences. |
| n_outputs | Number of output channels. |
| W | Input sequence length. |
| conv | File-backed convolution parameters. |
| progress_cb | Optional progress callback. |
| 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 = 0 ) |
Run file-to-file 1D convolution with file-backed parameters and pooling.
Input is packed [I][W]; output is packed [O][Vout].
| in_fn | Input file. |
| n_inputs | Number of input channels. |
| out_fn | Output file. |
| n_outputs | Number of output channels. |
| W | Input sequence length. |
| conv | File-backed convolution parameters. |
| pool | Pooling parameters applied after bias and activation. |
| progress_cb | Optional progress callback. |
| 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 = 0 ) |
Run file-to-file 1D convolution with memory-backed parameters.
This overload does not apply pooling. conv.weight uses [O][I][K]; nullptr bias means zero bias.
| in_fn | Input file with packed [I][W] sequences. |
| n_inputs | Number of input channels. |
| out_fn | Output file for packed [O][V] sequences. |
| n_outputs | Number of output channels. |
| W | Input sequence length. |
| conv | Memory-backed convolution parameters. |
| progress_cb | Optional progress callback. |
| uint16_t noodle_conv1d | ( | NoodleBuffer * | input, |
| uint16_t | n_inputs, | ||
| NoodleBuffer * | output, | ||
| uint16_t | n_outputs, | ||
| uint16_t | W, | ||
| const ConvMem & | conv, | ||
| CBFPtr | progress_cb = 0 ) |
Run 1D convolution using memory-backed parameters.
This overload does not apply pooling. Input is [I][W]; output is [O][V].
| input | Input NoodleBuffer with packed 1D feature maps. |
| n_inputs | Number of input channels. |
| output | Output NoodleBuffer grown as needed. |
| n_outputs | Number of output channels. |
| W | Input sequence length. |
| conv | Memory-backed 1D convolution parameters. |
| progress_cb | Optional progress callback. |
| uint16_t noodle_conv1d | ( | NoodleBuffer * | input, |
| uint16_t | n_inputs, | ||
| NoodleBuffer * | output, | ||
| uint16_t | n_outputs, | ||
| uint16_t | W, | ||
| const ConvMem & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb = 0 ) |
Run 1D convolution using memory-backed parameters and pooling.
Input is [I][W]; output is [O][Vout].
| input | Input NoodleBuffer with packed 1D feature maps. |
| n_inputs | Number of input channels. |
| output | Output NoodleBuffer grown as needed. |
| n_outputs | Number of output channels. |
| W | Input sequence length. |
| conv | Memory-backed 1D convolution parameters. |
| pool | Pooling parameters applied after bias and activation. |
| progress_cb | Optional progress callback. |
| 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 = 0 ) |
Run file-to-file 2D convolution on byte input feature maps.
Input is packed [I][W][W]; output is packed [O][Vout][Vout].
| in_fn | Input file. |
| n_inputs | Number of input channels. |
| n_outputs | Number of output channels. |
| out_fn | Output file. |
| W | Input width and height. |
| conv | File-backed convolution parameters. |
| pool | Pooling parameters applied after bias and activation. |
| progress_cb | Optional progress callback. |
| 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 = 0 ) |
Run file-to-file 2D convolution on float input feature maps.
Input is packed [I][W][W]; output is packed [O][Vout][Vout].
| in_fn | Input file. |
| n_inputs | Number of input channels. |
| n_outputs | Number of output channels. |
| out_fn | Output file. |
| W | Input width and height. |
| conv | File-backed convolution parameters. |
| pool | Pooling parameters applied after bias and activation. |
| progress_cb | Optional progress callback. |
| 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 ConvMem & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb = 0 ) |
Run file-to-file 2D convolution with memory-backed parameters.
conv.weight uses [O][I][K][K]; nullptr bias means zero bias.
| in_fn | Input file with packed [I][W][W] planes. |
| n_inputs | Number of input channels. |
| n_outputs | Number of output channels. |
| out_fn | Output file for packed [O][Vout][Vout] planes. |
| W | Input width and height. |
| conv | Memory-backed convolution parameters. |
| pool | Pooling parameters applied after bias and activation. |
| progress_cb | Optional progress callback. |
| 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 ConvProgmem & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb = 0 ) |
Run file-to-file 2D convolution with near-PROGMEM parameters.
conv.weight uses [O][I][K][K]; nullptr bias means zero bias.
| in_fn | Input file with packed [I][W][W] planes. |
| n_inputs | Number of input channels. |
| n_outputs | Number of output channels. |
| out_fn | Output file for packed [O][Vout][Vout] planes. |
| W | Input width and height. |
| conv | Near-PROGMEM convolution parameters. |
| pool | Pooling parameters applied after bias and activation. |
| progress_cb | Optional progress callback. |
| uint16_t noodle_conv_float | ( | NoodleBuffer * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| NoodleBuffer * | output, | ||
| uint16_t | W, | ||
| const Conv & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb = 0 ) |
Run 2D convolution using file-backed parameters.
Input is packed [I][W][W]; output is packed [O][Vout][Vout].
| input | Input NoodleBuffer with packed feature maps. |
| n_inputs | Number of input channels. |
| n_outputs | Number of output channels. |
| output | Output NoodleBuffer grown as needed. |
| W | Input width and height. |
| conv | File-backed convolution parameters. |
| pool | Pooling parameters. |
| progress_cb | Optional progress callback. |
| uint16_t noodle_conv_float | ( | NoodleBuffer * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| NoodleBuffer * | output, | ||
| uint16_t | W, | ||
| const ConvMem & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb = 0 ) |
Run 2D convolution using memory-backed parameters.
conv.weight uses [O][I][K][K]; nullptr bias means zero bias.
| input | Input NoodleBuffer with packed [I][W][W] feature maps. |
| n_inputs | Number of input channels. |
| n_outputs | Number of output channels. |
| output | Output NoodleBuffer grown as needed. |
| W | Input width and height. |
| conv | Memory-backed convolution parameters. |
| pool | Pooling parameters. |
| progress_cb | Optional progress callback. |
| uint16_t noodle_conv_float | ( | NoodleBuffer * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| NoodleBuffer * | output, | ||
| uint16_t | W, | ||
| const ConvProgmem & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb = 0 ) |
Run 2D convolution using near-PROGMEM parameters.
conv.weight uses [O][I][K][K]; nullptr bias means zero bias.
| input | Input NoodleBuffer with packed [I][W][W] feature maps. |
| n_inputs | Number of input channels. |
| n_outputs | Number of output channels. |
| output | Output NoodleBuffer grown as needed. |
| W | Input width and height. |
| conv | Near-PROGMEM convolution parameters. |
| pool | Pooling parameters. |
| progress_cb | Optional progress callback. |
| uint16_t noodle_conv_transpose_float | ( | NoodleBuffer * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| NoodleBuffer * | output, | ||
| uint16_t | W, | ||
| const ConvMem & | conv, | ||
| CBFPtr | progress_cb = 0 ) |
Run 2D transpose convolution using memory-backed parameters.
Input is packed [I][W][W]; output is packed [O][Vt][Vt]. Weights use [O][I][K][K].
For explicit padding, callers set conv.OP so Vt = (W - 1) * conv.S - 2 * conv.P + conv.K + conv.OP matches the desired output width. With conv.P == 65535, SAME-style output uses Vt = W * conv.S.
| input | Input NoodleBuffer with packed feature maps. |
| n_inputs | Number of input channels. |
| n_outputs | Number of output channels. |
| output | Output NoodleBuffer grown as needed. |
| W | Input width and height. |
| conv | Memory-backed transpose convolution parameters. |
| progress_cb | Optional progress callback. |
| float * noodle_create_buffer | ( | uint16_t | size | ) |
Allocate a raw byte buffer and return it as a float pointer.
This compatibility wrapper calls malloc() with size bytes.
| size | Number of bytes to allocate. |
| void noodle_delete_buffer | ( | float * | buffer | ) |
Free a buffer allocated by noodle_create_buffer().
| buffer | Buffer pointer. Passing nullptr is allowed. |
| void noodle_delete_file | ( | const char * | fn | ) |
Delete a file through the selected filesystem backend.
| fn | File to remove. |
| 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 = 0 ) |
Run file-to-file depthwise 2D convolution with file-backed parameters.
Input and output are packed channel-first. conv.weight_fn stores [C][K][K], and conv.bias_fn stores one scalar per channel.
| in_fn | Input file with packed [C][W][W] planes. |
| n_channels | Number of channels. |
| out_fn | Output file for packed [C][Vout][Vout] planes. |
| W | Input width and height. |
| conv | File-backed depthwise parameters. |
| pool | Pooling parameters applied after bias and activation. |
| progress_cb | Optional progress callback. |
| uint16_t noodle_dwconv_float | ( | const char * | in_fn, |
| uint16_t | n_channels, | ||
| const char * | out_fn, | ||
| uint16_t | W, | ||
| const ConvProgmem & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb = 0 ) |
Run file-to-file depthwise 2D convolution with near-PROGMEM parameters.
conv.weight stores [C][K][K], and nullptr bias means zero bias.
| in_fn | Input file with packed [C][W][W] planes. |
| n_channels | Number of channels. |
| out_fn | Output file for packed [C][Vout][Vout] planes. |
| W | Input width and height. |
| conv | Near-PROGMEM depthwise parameters. |
| pool | Pooling parameters applied after bias and activation. |
| progress_cb | Optional progress callback. |
| uint16_t noodle_dwconv_float | ( | NoodleBuffer * | input, |
| uint16_t | n_channels, | ||
| NoodleBuffer * | output, | ||
| uint16_t | W, | ||
| const Conv & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb = 0 ) |
Run depthwise 2D convolution using file-backed parameters.
Input and output are packed channel-first. conv.weight_fn stores [C][K][K].
| input | Input NoodleBuffer with packed [C][W][W] planes. |
| n_channels | Number of channels. |
| output | Output NoodleBuffer grown as needed. |
| W | Input width and height. |
| conv | File-backed depthwise parameters. |
| pool | Pooling parameters. |
| progress_cb | Optional progress callback. |
| uint16_t noodle_dwconv_float | ( | NoodleBuffer * | input, |
| uint16_t | n_channels, | ||
| NoodleBuffer * | output, | ||
| uint16_t | W, | ||
| const ConvMem & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb = 0 ) |
Run depthwise 2D convolution using memory-backed parameters.
conv.weight stores [C][K][K]; nullptr bias means zero bias.
| input | Input NoodleBuffer with packed [C][W][W] planes. |
| n_channels | Number of channels. |
| output | Output NoodleBuffer grown as needed. |
| W | Input width and height. |
| conv | Memory-backed depthwise parameters. |
| pool | Pooling parameters. |
| progress_cb | Optional progress callback. |
| uint16_t noodle_dwconv_float | ( | NoodleBuffer * | input, |
| uint16_t | n_channels, | ||
| NoodleBuffer * | output, | ||
| uint16_t | W, | ||
| const ConvProgmem & | conv, | ||
| const Pool & | pool, | ||
| CBFPtr | progress_cb = 0 ) |
Run depthwise 2D convolution using near-PROGMEM parameters.
conv.weight stores [C][K][K]; nullptr bias means zero bias.
| input | Input NoodleBuffer with packed [C][W][W] planes. |
| n_channels | Number of channels. |
| output | Output NoodleBuffer grown as needed. |
| W | Input width and height. |
| conv | Near-PROGMEM depthwise parameters. |
| pool | Pooling parameters. |
| progress_cb | Optional progress callback. |
| uint16_t noodle_fcn | ( | const byte * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| const char * | out_fn, | ||
| const FCNFile & | fcn, | ||
| CBFPtr | progress_cb = 0 ) |
Run a fully connected layer from byte memory to a file.
Input is a flat vector. Weights are read in [O][I] order from fcn.
| input | Input vector with n_inputs values. |
| n_inputs | Input vector length. |
| n_outputs | Number of output neurons. |
| out_fn | Output file for n_outputs values. |
| fcn | File-backed FCN parameters. |
| progress_cb | Optional progress callback. |
n_outputs, or 0 on failure. | uint16_t noodle_fcn | ( | const byte * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| NoodleBuffer * | output, | ||
| const FCNFile & | fcn, | ||
| CBFPtr | progress_cb = 0 ) |
Run a fully connected layer from byte memory to a NoodleBuffer.
| input | Input vector with n_inputs values. |
| n_inputs | Input vector length. |
| n_outputs | Number of output neurons. |
| output | Output NoodleBuffer grown to n_outputs floats. |
| fcn | File-backed FCN parameters. |
| progress_cb | Optional progress callback. |
n_outputs, or 0 on failure. | 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 = 0 ) |
Run a fully connected layer from a file to a file.
Input and output are flat vectors. Weights are read in [O][I] order from fcn.
| in_fn | Input file with n_inputs values. |
| n_inputs | Input vector length. |
| n_outputs | Number of output neurons. |
| out_fn | Output file for n_outputs values. |
| fcn | File-backed FCN parameters. |
| progress_cb | Optional progress callback. |
n_outputs, or 0 on failure. | uint16_t noodle_fcn | ( | const char * | in_fn, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| NoodleBuffer * | output, | ||
| const FCNFile & | fcn, | ||
| CBFPtr | progress_cb = 0 ) |
Run a fully connected layer from a file to a NoodleBuffer.
| in_fn | Input file with n_inputs values. |
| n_inputs | Input vector length. |
| n_outputs | Number of output neurons. |
| output | Output NoodleBuffer grown to n_outputs floats. |
| fcn | File-backed FCN parameters. |
| progress_cb | Optional progress callback. |
n_outputs, or 0 on failure. | 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 = 0 ) |
Run a fully connected layer from int8 memory to a file.
Input is a flat vector. Weights are read in [O][I] order from fcn.
| input | Input vector with n_inputs values. |
| n_inputs | Input vector length. |
| n_outputs | Number of output neurons. |
| out_fn | Output file for n_outputs values. |
| fcn | File-backed FCN parameters. |
| progress_cb | Optional progress callback. |
n_outputs, or 0 on failure. | uint16_t noodle_fcn | ( | const int8_t * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| NoodleBuffer * | output, | ||
| const FCNFile & | fcn, | ||
| CBFPtr | progress_cb = 0 ) |
Run a fully connected layer from int8 memory to a NoodleBuffer.
| input | Input vector with n_inputs values. |
| n_inputs | Input vector length. |
| n_outputs | Number of output neurons. |
| output | Output NoodleBuffer grown to n_outputs floats. |
| fcn | File-backed FCN parameters. |
| progress_cb | Optional progress callback. |
n_outputs, or 0 on failure. | uint16_t noodle_fcn | ( | NoodleBuffer * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| NoodleBuffer * | output, | ||
| const FCNFile & | fcn, | ||
| CBFPtr | progress_cb = 0 ) |
Run a fully connected layer using file-backed parameters.
| input | Input NoodleBuffer containing a flat vector. |
| n_inputs | Input vector length. |
| n_outputs | Number of output neurons. |
| output | Output NoodleBuffer grown to n_outputs floats. |
| fcn | File-backed FCN parameters. |
| progress_cb | Optional progress callback. |
n_outputs, or 0 on failure. | uint16_t noodle_fcn | ( | NoodleBuffer * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| NoodleBuffer * | output, | ||
| const FCNMem & | fcn, | ||
| CBFPtr | progress_cb = 0 ) |
Run a fully connected layer using memory-backed parameters.
| input | Input NoodleBuffer containing a flat vector. |
| n_inputs | Input vector length. |
| n_outputs | Number of output neurons. |
| output | Output NoodleBuffer grown to n_outputs floats. |
| fcn | Memory-backed FCN parameters. |
| progress_cb | Optional progress callback. |
n_outputs, or 0 on failure. | uint16_t noodle_fcn | ( | NoodleBuffer * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| NoodleBuffer * | output, | ||
| const FCNProgmem & | fcn, | ||
| CBFPtr | progress_cb = 0 ) |
Run a fully connected layer using far-PROGMEM parameters.
| input | Input NoodleBuffer containing a flat vector. |
| n_inputs | Input vector length. |
| n_outputs | Number of output neurons. |
| output | Output NoodleBuffer grown to n_outputs floats. |
| fcn | Far-PROGMEM FCN parameters. |
| progress_cb | Optional progress callback. |
n_outputs on AVR, or 0 on failure/non-AVR. | uint16_t noodle_fcn_progmem | ( | NoodleBuffer * | input, |
| uint16_t | n_inputs, | ||
| uint16_t | n_outputs, | ||
| NoodleBuffer * | output, | ||
| const float * | weight, | ||
| const float * | bias, | ||
| Activation | act, | ||
| CBFPtr | progress_cb = 0 ) |
Run a fully connected layer using near-PROGMEM weights.
weight is read with noodle_pgm_float() in [O][I] order. bias may be nullptr for zero bias.
| input | Input NoodleBuffer containing a flat vector. |
| n_inputs | Input vector length. |
| n_outputs | Number of output neurons. |
| output | Output NoodleBuffer grown to n_outputs floats. |
| weight | Near-PROGMEM row-major [O][I] weights. |
| bias | Near-PROGMEM output biases, or nullptr. |
| act | Activation applied after each output. |
| progress_cb | Optional progress callback. |
n_outputs, or 0 on failure. | void noodle_find_max | ( | NoodleBuffer * | input, |
| uint16_t | n, | ||
| float & | max_val, | ||
| uint16_t & | max_idx ) |
Find the maximum value and its index in a NoodleBuffer vector.
| input | Input vector buffer. |
| n | Number of vector elements to inspect. |
| max_val | Receives the maximum value, or 0.0 for null/empty input. |
| max_idx | Receives the maximum index, or 0 for null/empty input. |
| uint16_t noodle_flat | ( | const char * | in_fn, |
| NoodleBuffer * | output, | ||
| uint16_t | V, | ||
| uint16_t | n_filters ) |
Flatten a packed file tensor into a NoodleBuffer.
Reads packed [C][V][V] input and writes HWC-like order: output[pixel * C + channel]. The output buffer grows automatically to V * V * n_filters floats.
| in_fn | Input file containing packed channel-first planes. |
| output | Destination buffer grown as needed. |
| V | Input plane width and height. |
| n_filters | Number of channel planes. |
| uint16_t noodle_flat | ( | NoodleBuffer * | input, |
| NoodleBuffer * | output, | ||
| uint16_t | V, | ||
| uint16_t | n_filters ) |
Flatten a packed NoodleBuffer tensor into HWC-like order.
Reads input as packed [C][V][V], grows output to V * V * n_filters floats, and writes output[pixel * C + channel].
| input | Source buffer with packed channel-first planes. |
| output | Destination buffer grown as needed. |
| V | Input plane width and height. |
| n_filters | Number of channel planes. |
| bool noodle_fs_init | ( | ) |
Initialize the selected filesystem backend with default settings.
| bool noodle_fs_init | ( | uint8_t | clk_pin, |
| uint8_t | cmd_pin, | ||
| uint8_t | d0_pin ) |
Initialize SD_MMC with explicit 1-bit pins, or default-init other backends.
| clk_pin | SD_MMC clock pin. |
| cmd_pin | SD_MMC command pin. |
| d0_pin | SD_MMC D0 pin. |
| 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_MMC with explicit 4-bit pins, or default-init other backends.
| clk_pin | SD_MMC clock pin. |
| cmd_pin | SD_MMC command pin. |
| d0_pin | SD_MMC D0 pin. |
| d1_pin | SD_MMC D1 pin. |
| d2_pin | SD_MMC D2 pin. |
| d3_pin | SD_MMC D3 pin. |
| bool noodle_fs_init | ( | uint8_t | cs_pin | ) |
Initialize the selected filesystem backend with an SPI chip-select pin.
The chip-select pin is used by the SdFat backend. Other real backends ignore it and use their default initializer.
| cs_pin | SPI chip-select pin for SdFat. |
| bool noodle_fs_init | ( | uint8_t | cs_pin, |
| SPIClass & | spi, | ||
| uint8_t | sck_mhz ) |
Initialize SdFat with an explicit SPI bus and clock speed.
Use this overload when the SD card is connected to a non-default SPI bus or custom SPI pins that have already been configured on spi.
| cs_pin | SPI chip-select pin for the SD card. |
| spi | SPI bus instance used by SdFat. |
| sck_mhz | Requested SD SPI clock in MHz. |
| uint16_t noodle_gap | ( | NoodleBuffer * | inout, |
| uint16_t | C, | ||
| uint16_t | W ) |
Apply global average pooling in place on packed channel-first maps.
Reduces [C][W][W] to [C] by writing each channel mean into the first C positions of inout.
| inout | Buffer containing packed [C][W][W] data. |
| C | Number of channels. |
| W | Plane width and height. |
C, or 0 when inout has no data. | uint16_t noodle_gmp | ( | NoodleBuffer * | inout, |
| uint16_t | C, | ||
| uint16_t | W ) |
Apply global max pooling in place on packed channel-first data.
Reduces each channel to one maximum value in the first C positions of inout. The current helper scans W values per channel.
| inout | Buffer containing packed channel data. |
| C | Number of channels. |
| W | Number of values scanned per channel. |
C, or 0 when inout has no data. | void noodle_grid_from_file | ( | const char * | fn, |
| byte * | buffer, | ||
| uint16_t | K ) |
Read a K x K grid into a byte buffer.
| fn | Input file. |
| buffer | Destination buffer with room for K * K byte values. |
| K | Grid width and height. |
| void noodle_grid_from_file | ( | const char * | fn, |
| float * | buffer, | ||
| uint16_t | K ) |
Read a K x K grid into a float buffer.
| fn | Input file. |
| buffer | Destination buffer with room for K * K float values. |
| K | Grid width and height. |
| void noodle_grid_from_file | ( | const char * | fn, |
| int8_t * | buffer, | ||
| uint16_t | K ) |
Read a K x K grid into an int8 buffer.
| fn | Input file. |
| buffer | Destination buffer with room for K * K int8 values. |
| K | Grid width and height. |
| void noodle_grid_to_file | ( | byte * | grid, |
| const char * | fn, | ||
| uint16_t | n ) |
Write an n x n byte grid to a file in row-major order.
| grid | Source grid with n * n values. |
| fn | Output file. |
| n | Grid width and height. |
| void noodle_grid_to_file | ( | float * | grid, |
| const char * | fn, | ||
| uint16_t | n ) |
Write an n x n float grid to a file in row-major order.
| grid | Source grid with n * n values. |
| fn | Output file. |
| n | Grid width and height. |
| uint16_t noodle_logit | ( | NoodleBuffer * | input_output, |
| uint16_t | n ) |
Apply logistic sigmoid in place on a NoodleBuffer.
| input_output | Vector buffer updated in place. |
| n | Number of vector elements. |
n, or 0 when input_output has no data.
|
inlinestatic |
Read a float from normal memory or near AVR PROGMEM.
On AVR this uses pgm_read_float_near(). On other platforms it indexes normal memory directly, which lets the same PROGMEM-backed wrappers compile across targets.
| p | Base pointer to packed float values. |
| idx | Element index to read. |
idx. | byte noodle_read_byte | ( | NDL_File & | f | ) |
Read a byte using NOODLE_FILE_FORMAT.
| f | Open input file. |
| size_t noodle_read_bytes_until | ( | NDL_File & | file, |
| char | terminator, | ||
| char * | buffer, | ||
| size_t | length ) |
Read bytes until a terminator or until the buffer is full.
The terminator is consumed but not stored. buffer is NUL-terminated when length is greater than zero.
| file | Open file handle. |
| terminator | Character that ends the read. |
| buffer | Destination character buffer. |
| length | Destination capacity, including the trailing NUL. |
| float noodle_read_float | ( | NDL_File & | f | ) |
Read a float using NOODLE_FILE_FORMAT.
| f | Open input file. |
| void noodle_read_top_line | ( | const char * | fn, |
| char * | line, | ||
| size_t | maxlen ) |
Read the first line from a text file.
The destination is NUL-terminated when maxlen is greater than zero. If the file cannot be opened, line is set to an empty string.
| fn | File to read. |
| line | Destination character buffer. |
| maxlen | Destination capacity, including the trailing NUL. |
| uint16_t noodle_relu | ( | NoodleBuffer * | input_output, |
| uint16_t | n ) |
Apply ReLU in place on a NoodleBuffer.
| input_output | Vector buffer updated in place. |
| n | Number of vector elements. |
n, or 0 when input_output has no data. | uint16_t noodle_reshape | ( | NoodleBuffer * | src_hwc, |
| NoodleBuffer * | dst_chw, | ||
| uint16_t | W, | ||
| uint16_t | C ) |
Convert HWC-like NoodleBuffer data to packed channel-first data.
The destination buffer grows automatically to W * W * C floats.
| src_hwc | Source buffer in src[pixel * C + channel] order. |
| dst_chw | Destination buffer grown as needed. |
| W | Output plane width and height. |
| C | Number of channel planes. |
| void noodle_setup_temp_buffers | ( | void * | b1, |
| void * | b2 ) |
Install caller-owned internal scratch buffers.
This legacy hook is optional because Noodle now allocates scratch buffers on demand. When installed, these pointers are used as-is, never resized, and not freed by noodle_temp_buffers_free().
| b1 | Input scratch buffer for file-backed input planes or sequences. |
| b2 | Accumulation scratch buffer for one pre-pooling output map. |
| void noodle_setup_temp_buffers | ( | void * | b2 | ) |
Install only the caller-owned accumulation scratch buffer.
Use this when a legacy raw-pointer path needs only temp buffer 2.
| b2 | Accumulation scratch buffer for one pre-pooling output map. |
| uint16_t noodle_sigmoid | ( | NoodleBuffer * | input_output, |
| uint16_t | n ) |
Apply sigmoid in place on a NoodleBuffer.
| input_output | Vector buffer updated in place. |
| n | Number of vector elements. |
n, or 0 when input_output has no data. | float noodle_sigmoidf | ( | float | x | ) |
Compute sigmoid for one scalar.
| x | Scalar input. |
x. | uint16_t noodle_soft_max | ( | NoodleBuffer * | input_output, |
| uint16_t | n ) |
Apply numerically stabilized softmax in place on a NoodleBuffer.
| input_output | Vector buffer updated in place. |
| n | Number of vector elements. |
n, or 0 when input_output has no data. | void noodle_temp_buffers_free | ( | void | ) |
Release automatically allocated internal scratch buffers.
External buffers installed with noodle_setup_temp_buffers() are detached but not freed.
| void noodle_write_byte | ( | NDL_File & | f, |
| byte | d ) |
Write a byte using NOODLE_FILE_FORMAT.
| f | Open output file. |
| d | Value to write. |
| void noodle_write_float | ( | NDL_File & | f, |
| float | d ) |
Write a float using NOODLE_FILE_FORMAT.
| f | Open output file. |
| d | Value to write. |