Noodle
Loading...
Searching...
No Matches
Public API

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 output with noodle_buffer_require(), and write the result into output->data. They return the output width/length or output count, and return 0 on null input, null storage, invalid shape, allocation failure, or a failing lower-level layer.

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().

Detailed Description

Public functions, types, and configuration intended for application code.

Typedef Documentation

◆ CBFPtr

typedef void(* CBFPtr) (float progress)

Progress callback used by long-running layer routines.

Parameters
progressNormalized progress, usually in the range [0, 1].

Enumeration Type Documentation

◆ Activation

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.

Function Documentation

◆ noodle_array_from_file()

void noodle_array_from_file ( const char * fn,
float * buffer,
uint16_t K )

Read a float array from a file.

Parameters
fnInput file.
bufferDestination array with room for K floats.
KNumber of values to read.

◆ noodle_array_to_file()

void noodle_array_to_file ( float * array,
const char * fn,
uint16_t n )

Write a float array to a file.

Parameters
arraySource array with n values.
fnOutput file.
nNumber of values to write.

◆ noodle_bn() [1/2]

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]].

Parameters
xTensor buffer updated in place.
CNumber of channels.
WPlane width and height.
bn_paramsPacked batch-normalization parameters.
epsSmall value added to variance before inversion.
Returns
W, or 0 when x has no data.

◆ noodle_bn() [2/2]

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].

Parameters
xTensor buffer updated in place.
CNumber of channels.
WPlane width and height.
gammaScale parameters.
betaOffset parameters.
meanMoving-mean parameters.
varMoving-variance parameters.
epsSmall value added to variance before inversion.
Returns
W, or 0 when x has no data.

◆ noodle_bn1d() [1/2]

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]].

Parameters
xVector buffer updated in place.
NNumber of vector elements.
bn_paramsPacked batch-normalization parameters.
epsSmall value added to variance before inversion.
Returns
N, or 0 when x has no data.

◆ noodle_bn1d() [2/2]

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.

Parameters
xVector buffer updated in place.
NNumber of vector elements.
gammaScale parameters.
betaOffset parameters.
meanMoving-mean parameters.
varMoving-variance parameters.
epsSmall value added to variance before inversion.
Returns
N, or 0 when x has no data.

◆ noodle_bn1d_relu() [1/2]

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]].

Parameters
xVector buffer updated in place.
NNumber of vector elements.
bn_paramsPacked batch-normalization parameters.
epsSmall value added to variance before inversion.
Returns
N, or 0 when x has no data.

◆ noodle_bn1d_relu() [2/2]

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.

Parameters
xVector buffer updated in place.
NNumber of vector elements.
gammaScale parameters.
betaOffset parameters.
meanMoving-mean parameters.
varMoving-variance parameters.
epsSmall value added to variance before inversion.
Returns
N, or 0 when x has no data.

◆ noodle_bn2d() [1/2]

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]].

Parameters
xTensor buffer updated in place.
CNumber of channels.
WPlane width and height.
bn_paramsPacked batch-normalization parameters.
epsSmall value added to variance before inversion.
Returns
W, or 0 when x has no data.

◆ noodle_bn2d() [2/2]

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.

Parameters
xTensor buffer updated in place.
CNumber of channels.
WPlane width and height.
gammaScale parameters.
betaOffset parameters.
meanMoving-mean parameters.
varMoving-variance parameters.
epsSmall value added to variance before inversion.
Returns
W, or 0 when x has no data.

◆ noodle_bn2d_relu() [1/2]

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]].

Parameters
xTensor buffer updated in place.
CNumber of channels.
WPlane width and height.
bn_paramsPacked batch-normalization parameters.
epsSmall value added to variance before inversion.
Returns
W, or 0 when x has no data.

◆ noodle_bn2d_relu() [2/2]

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.

Parameters
xTensor buffer updated in place.
CNumber of channels.
WPlane width and height.
gammaScale parameters.
betaOffset parameters.
meanMoving-mean parameters.
varMoving-variance parameters.
epsSmall value added to variance before inversion.
Returns
W, or 0 when x has no data.

◆ noodle_bn_relu() [1/2]

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]].

Parameters
xTensor buffer updated in place.
CNumber of channels.
WPlane width and height.
bn_paramsPacked batch-normalization parameters.
epsSmall value added to variance before inversion.
Returns
W, or 0 when x has no data.

◆ noodle_bn_relu() [2/2]

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].

Parameters
xTensor buffer updated in place.
CNumber of channels.
WPlane width and height.
gammaScale parameters.
betaOffset parameters.
meanMoving-mean parameters.
varMoving-variance parameters.
epsSmall value added to variance before inversion.
Returns
W, or 0 when x has no data.

◆ noodle_buffer_capacity()

size_t noodle_buffer_capacity ( const NoodleBuffer * buf)

Return the buffer capacity in float elements.

Parameters
bufBuffer descriptor to inspect.
Returns
Capacity in float elements, or 0 when buf is NULL.

◆ noodle_buffer_capacity_bytes()

size_t noodle_buffer_capacity_bytes ( const NoodleBuffer * buf)

Return the buffer capacity in bytes.

Parameters
bufBuffer descriptor to inspect.
Returns
Capacity in bytes, or 0 when buf is NULL.

◆ noodle_buffer_free()

void noodle_buffer_free ( NoodleBuffer * buf)

Release a NoodleBuffer.

This frees the internal data pointer and resets the descriptor.

Parameters
bufBuffer descriptor to release. Passing NULL is allowed.

◆ noodle_buffer_init()

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.

Parameters
bufBuffer descriptor to initialize. Passing NULL is allowed.

◆ noodle_buffer_require()

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.

Parameters
bufBuffer descriptor.
required_floatsRequired capacity in float elements.
Returns
Pointer to usable float storage, or NULL on failure.

◆ noodle_conv1d() [1/5]

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.

Parameters
in_fnInput file with packed [I][W] sequences.
n_inputsNumber of input channels.
out_fnOutput file for packed [O][V] sequences.
n_outputsNumber of output channels.
WInput sequence length.
convFile-backed convolution parameters.
progress_cbOptional progress callback.
Returns
Output length before pooling, or 0 on failure.

◆ noodle_conv1d() [2/5]

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].

Parameters
in_fnInput file.
n_inputsNumber of input channels.
out_fnOutput file.
n_outputsNumber of output channels.
WInput sequence length.
convFile-backed convolution parameters.
poolPooling parameters applied after bias and activation.
progress_cbOptional progress callback.
Returns
Output length after pooling, or 0 on failure.

◆ noodle_conv1d() [3/5]

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.

Parameters
in_fnInput file with packed [I][W] sequences.
n_inputsNumber of input channels.
out_fnOutput file for packed [O][V] sequences.
n_outputsNumber of output channels.
WInput sequence length.
convMemory-backed convolution parameters.
progress_cbOptional progress callback.
Returns
Output length before pooling, or 0 on failure.

◆ noodle_conv1d() [4/5]

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].

Parameters
inputInput NoodleBuffer with packed 1D feature maps.
n_inputsNumber of input channels.
outputOutput NoodleBuffer grown as needed.
n_outputsNumber of output channels.
WInput sequence length.
convMemory-backed 1D convolution parameters.
progress_cbOptional progress callback.
Returns
Output length before pooling, or 0 on failure.

◆ noodle_conv1d() [5/5]

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].

Parameters
inputInput NoodleBuffer with packed 1D feature maps.
n_inputsNumber of input channels.
outputOutput NoodleBuffer grown as needed.
n_outputsNumber of output channels.
WInput sequence length.
convMemory-backed 1D convolution parameters.
poolPooling parameters applied after bias and activation.
progress_cbOptional progress callback.
Returns
Output length after pooling, or 0 on failure.

◆ noodle_conv_byte()

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].

Parameters
in_fnInput file.
n_inputsNumber of input channels.
n_outputsNumber of output channels.
out_fnOutput file.
WInput width and height.
convFile-backed convolution parameters.
poolPooling parameters applied after bias and activation.
progress_cbOptional progress callback.
Returns
Output width after pooling, or 0 on failure.

◆ noodle_conv_float() [1/6]

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].

Parameters
in_fnInput file.
n_inputsNumber of input channels.
n_outputsNumber of output channels.
out_fnOutput file.
WInput width and height.
convFile-backed convolution parameters.
poolPooling parameters applied after bias and activation.
progress_cbOptional progress callback.
Returns
Output width after pooling, or 0 on failure.

◆ noodle_conv_float() [2/6]

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.

Parameters
in_fnInput file with packed [I][W][W] planes.
n_inputsNumber of input channels.
n_outputsNumber of output channels.
out_fnOutput file for packed [O][Vout][Vout] planes.
WInput width and height.
convMemory-backed convolution parameters.
poolPooling parameters applied after bias and activation.
progress_cbOptional progress callback.
Returns
Output width after pooling, or 0 on failure.

◆ noodle_conv_float() [3/6]

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.

Parameters
in_fnInput file with packed [I][W][W] planes.
n_inputsNumber of input channels.
n_outputsNumber of output channels.
out_fnOutput file for packed [O][Vout][Vout] planes.
WInput width and height.
convNear-PROGMEM convolution parameters.
poolPooling parameters applied after bias and activation.
progress_cbOptional progress callback.
Returns
Output width after pooling, or 0 on failure.

◆ noodle_conv_float() [4/6]

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].

Parameters
inputInput NoodleBuffer with packed feature maps.
n_inputsNumber of input channels.
n_outputsNumber of output channels.
outputOutput NoodleBuffer grown as needed.
WInput width and height.
convFile-backed convolution parameters.
poolPooling parameters.
progress_cbOptional progress callback.
Returns
Output width after pooling, or 0 on failure.

◆ noodle_conv_float() [5/6]

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.

Parameters
inputInput NoodleBuffer with packed [I][W][W] feature maps.
n_inputsNumber of input channels.
n_outputsNumber of output channels.
outputOutput NoodleBuffer grown as needed.
WInput width and height.
convMemory-backed convolution parameters.
poolPooling parameters.
progress_cbOptional progress callback.
Returns
Output width after pooling, or 0 on failure.

◆ noodle_conv_float() [6/6]

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.

Parameters
inputInput NoodleBuffer with packed [I][W][W] feature maps.
n_inputsNumber of input channels.
n_outputsNumber of output channels.
outputOutput NoodleBuffer grown as needed.
WInput width and height.
convNear-PROGMEM convolution parameters.
poolPooling parameters.
progress_cbOptional progress callback.
Returns
Output width after pooling, or 0 on failure.

◆ noodle_conv_transpose_float()

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.

Parameters
inputInput NoodleBuffer with packed feature maps.
n_inputsNumber of input channels.
n_outputsNumber of output channels.
outputOutput NoodleBuffer grown as needed.
WInput width and height.
convMemory-backed transpose convolution parameters.
progress_cbOptional progress callback.
Returns
Output width, or 0 on failure.

◆ noodle_create_buffer()

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.

Parameters
sizeNumber of bytes to allocate.
Returns
Allocated pointer, or nullptr on allocation failure.

◆ noodle_delete_buffer()

void noodle_delete_buffer ( float * buffer)

Free a buffer allocated by noodle_create_buffer().

Parameters
bufferBuffer pointer. Passing nullptr is allowed.

◆ noodle_delete_file()

void noodle_delete_file ( const char * fn)

Delete a file through the selected filesystem backend.

Parameters
fnFile to remove.

◆ noodle_dwconv_float() [1/5]

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.

Parameters
in_fnInput file with packed [C][W][W] planes.
n_channelsNumber of channels.
out_fnOutput file for packed [C][Vout][Vout] planes.
WInput width and height.
convFile-backed depthwise parameters.
poolPooling parameters applied after bias and activation.
progress_cbOptional progress callback.
Returns
Output width after pooling, or 0 on failure.

◆ noodle_dwconv_float() [2/5]

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.

Parameters
in_fnInput file with packed [C][W][W] planes.
n_channelsNumber of channels.
out_fnOutput file for packed [C][Vout][Vout] planes.
WInput width and height.
convNear-PROGMEM depthwise parameters.
poolPooling parameters applied after bias and activation.
progress_cbOptional progress callback.
Returns
Output width after pooling, or 0 on failure.

◆ noodle_dwconv_float() [3/5]

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].

Parameters
inputInput NoodleBuffer with packed [C][W][W] planes.
n_channelsNumber of channels.
outputOutput NoodleBuffer grown as needed.
WInput width and height.
convFile-backed depthwise parameters.
poolPooling parameters.
progress_cbOptional progress callback.
Returns
Output width after pooling, or 0 on failure.

◆ noodle_dwconv_float() [4/5]

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.

Parameters
inputInput NoodleBuffer with packed [C][W][W] planes.
n_channelsNumber of channels.
outputOutput NoodleBuffer grown as needed.
WInput width and height.
convMemory-backed depthwise parameters.
poolPooling parameters.
progress_cbOptional progress callback.
Returns
Output width after pooling, or 0 on failure.

◆ noodle_dwconv_float() [5/5]

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.

Parameters
inputInput NoodleBuffer with packed [C][W][W] planes.
n_channelsNumber of channels.
outputOutput NoodleBuffer grown as needed.
WInput width and height.
convNear-PROGMEM depthwise parameters.
poolPooling parameters.
progress_cbOptional progress callback.
Returns
Output width after pooling, or 0 on failure.

◆ noodle_fcn() [1/9]

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.

Parameters
inputInput vector with n_inputs values.
n_inputsInput vector length.
n_outputsNumber of output neurons.
out_fnOutput file for n_outputs values.
fcnFile-backed FCN parameters.
progress_cbOptional progress callback.
Returns
n_outputs, or 0 on failure.

◆ noodle_fcn() [2/9]

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.

Parameters
inputInput vector with n_inputs values.
n_inputsInput vector length.
n_outputsNumber of output neurons.
outputOutput NoodleBuffer grown to n_outputs floats.
fcnFile-backed FCN parameters.
progress_cbOptional progress callback.
Returns
n_outputs, or 0 on failure.

◆ noodle_fcn() [3/9]

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.

Parameters
in_fnInput file with n_inputs values.
n_inputsInput vector length.
n_outputsNumber of output neurons.
out_fnOutput file for n_outputs values.
fcnFile-backed FCN parameters.
progress_cbOptional progress callback.
Returns
n_outputs, or 0 on failure.

◆ noodle_fcn() [4/9]

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.

Parameters
in_fnInput file with n_inputs values.
n_inputsInput vector length.
n_outputsNumber of output neurons.
outputOutput NoodleBuffer grown to n_outputs floats.
fcnFile-backed FCN parameters.
progress_cbOptional progress callback.
Returns
n_outputs, or 0 on failure.

◆ noodle_fcn() [5/9]

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.

Parameters
inputInput vector with n_inputs values.
n_inputsInput vector length.
n_outputsNumber of output neurons.
out_fnOutput file for n_outputs values.
fcnFile-backed FCN parameters.
progress_cbOptional progress callback.
Returns
n_outputs, or 0 on failure.

◆ noodle_fcn() [6/9]

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.

Parameters
inputInput vector with n_inputs values.
n_inputsInput vector length.
n_outputsNumber of output neurons.
outputOutput NoodleBuffer grown to n_outputs floats.
fcnFile-backed FCN parameters.
progress_cbOptional progress callback.
Returns
n_outputs, or 0 on failure.

◆ noodle_fcn() [7/9]

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.

Parameters
inputInput NoodleBuffer containing a flat vector.
n_inputsInput vector length.
n_outputsNumber of output neurons.
outputOutput NoodleBuffer grown to n_outputs floats.
fcnFile-backed FCN parameters.
progress_cbOptional progress callback.
Returns
n_outputs, or 0 on failure.

◆ noodle_fcn() [8/9]

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.

Parameters
inputInput NoodleBuffer containing a flat vector.
n_inputsInput vector length.
n_outputsNumber of output neurons.
outputOutput NoodleBuffer grown to n_outputs floats.
fcnMemory-backed FCN parameters.
progress_cbOptional progress callback.
Returns
n_outputs, or 0 on failure.

◆ noodle_fcn() [9/9]

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.

Parameters
inputInput NoodleBuffer containing a flat vector.
n_inputsInput vector length.
n_outputsNumber of output neurons.
outputOutput NoodleBuffer grown to n_outputs floats.
fcnFar-PROGMEM FCN parameters.
progress_cbOptional progress callback.
Returns
n_outputs on AVR, or 0 on failure/non-AVR.

◆ noodle_fcn_progmem()

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.

Parameters
inputInput NoodleBuffer containing a flat vector.
n_inputsInput vector length.
n_outputsNumber of output neurons.
outputOutput NoodleBuffer grown to n_outputs floats.
weightNear-PROGMEM row-major [O][I] weights.
biasNear-PROGMEM output biases, or nullptr.
actActivation applied after each output.
progress_cbOptional progress callback.
Returns
n_outputs, or 0 on failure.

◆ noodle_find_max()

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.

Parameters
inputInput vector buffer.
nNumber of vector elements to inspect.
max_valReceives the maximum value, or 0.0 for null/empty input.
max_idxReceives the maximum index, or 0 for null/empty input.

◆ noodle_flat() [1/2]

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.

Parameters
in_fnInput file containing packed channel-first planes.
outputDestination buffer grown as needed.
VInput plane width and height.
n_filtersNumber of channel planes.
Returns
Number of floats written, or 0 on null input/allocation failure.

◆ noodle_flat() [2/2]

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].

Parameters
inputSource buffer with packed channel-first planes.
outputDestination buffer grown as needed.
VInput plane width and height.
n_filtersNumber of channel planes.
Returns
Number of floats written, or 0 on null input/allocation failure.

◆ noodle_fs_init() [1/5]

bool noodle_fs_init ( )

Initialize the selected filesystem backend with default settings.

Returns
true when the selected backend initializes successfully.

◆ noodle_fs_init() [2/5]

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.

Parameters
clk_pinSD_MMC clock pin.
cmd_pinSD_MMC command pin.
d0_pinSD_MMC D0 pin.
Returns
true when the selected backend initializes successfully.

◆ noodle_fs_init() [3/5]

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.

Parameters
clk_pinSD_MMC clock pin.
cmd_pinSD_MMC command pin.
d0_pinSD_MMC D0 pin.
d1_pinSD_MMC D1 pin.
d2_pinSD_MMC D2 pin.
d3_pinSD_MMC D3 pin.
Returns
true when the selected backend initializes successfully.

◆ noodle_fs_init() [4/5]

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.

Parameters
cs_pinSPI chip-select pin for SdFat.
Returns
true when the selected backend initializes successfully.

◆ noodle_fs_init() [5/5]

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.

Parameters
cs_pinSPI chip-select pin for the SD card.
spiSPI bus instance used by SdFat.
sck_mhzRequested SD SPI clock in MHz.
Returns
true when SdFat initializes successfully.

◆ noodle_gap()

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.

Parameters
inoutBuffer containing packed [C][W][W] data.
CNumber of channels.
WPlane width and height.
Returns
C, or 0 when inout has no data.

◆ noodle_gmp()

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.

Parameters
inoutBuffer containing packed channel data.
CNumber of channels.
WNumber of values scanned per channel.
Returns
C, or 0 when inout has no data.

◆ noodle_grid_from_file() [1/3]

void noodle_grid_from_file ( const char * fn,
byte * buffer,
uint16_t K )

Read a K x K grid into a byte buffer.

Parameters
fnInput file.
bufferDestination buffer with room for K * K byte values.
KGrid width and height.

◆ noodle_grid_from_file() [2/3]

void noodle_grid_from_file ( const char * fn,
float * buffer,
uint16_t K )

Read a K x K grid into a float buffer.

Parameters
fnInput file.
bufferDestination buffer with room for K * K float values.
KGrid width and height.

◆ noodle_grid_from_file() [3/3]

void noodle_grid_from_file ( const char * fn,
int8_t * buffer,
uint16_t K )

Read a K x K grid into an int8 buffer.

Parameters
fnInput file.
bufferDestination buffer with room for K * K int8 values.
KGrid width and height.

◆ noodle_grid_to_file() [1/2]

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.

Parameters
gridSource grid with n * n values.
fnOutput file.
nGrid width and height.

◆ noodle_grid_to_file() [2/2]

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.

Parameters
gridSource grid with n * n values.
fnOutput file.
nGrid width and height.

◆ noodle_logit()

uint16_t noodle_logit ( NoodleBuffer * input_output,
uint16_t n )

Apply logistic sigmoid in place on a NoodleBuffer.

Parameters
input_outputVector buffer updated in place.
nNumber of vector elements.
Returns
n, or 0 when input_output has no data.

◆ noodle_pgm_float()

float noodle_pgm_float ( const float * p,
uint32_t idx )
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.

Parameters
pBase pointer to packed float values.
idxElement index to read.
Returns
Float value at idx.

◆ noodle_read_byte()

byte noodle_read_byte ( NDL_File & f)

Read a byte using NOODLE_FILE_FORMAT.

Parameters
fOpen input file.
Returns
Parsed or decoded byte value.

◆ noodle_read_bytes_until()

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.

Parameters
fileOpen file handle.
terminatorCharacter that ends the read.
bufferDestination character buffer.
lengthDestination capacity, including the trailing NUL.
Returns
Number of characters written, excluding the trailing NUL.

◆ noodle_read_float()

float noodle_read_float ( NDL_File & f)

Read a float using NOODLE_FILE_FORMAT.

Parameters
fOpen input file.
Returns
Parsed or decoded float value.

◆ noodle_read_top_line()

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.

Parameters
fnFile to read.
lineDestination character buffer.
maxlenDestination capacity, including the trailing NUL.

◆ noodle_relu()

uint16_t noodle_relu ( NoodleBuffer * input_output,
uint16_t n )

Apply ReLU in place on a NoodleBuffer.

Parameters
input_outputVector buffer updated in place.
nNumber of vector elements.
Returns
n, or 0 when input_output has no data.

◆ noodle_reshape()

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.

Parameters
src_hwcSource buffer in src[pixel * C + channel] order.
dst_chwDestination buffer grown as needed.
WOutput plane width and height.
CNumber of channel planes.
Returns
Number of floats written, or 0 on null input/allocation failure.

◆ noodle_setup_temp_buffers() [1/2]

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().

Parameters
b1Input scratch buffer for file-backed input planes or sequences.
b2Accumulation scratch buffer for one pre-pooling output map.

◆ noodle_setup_temp_buffers() [2/2]

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.

Parameters
b2Accumulation scratch buffer for one pre-pooling output map.

◆ noodle_sigmoid()

uint16_t noodle_sigmoid ( NoodleBuffer * input_output,
uint16_t n )

Apply sigmoid in place on a NoodleBuffer.

Parameters
input_outputVector buffer updated in place.
nNumber of vector elements.
Returns
n, or 0 when input_output has no data.

◆ noodle_sigmoidf()

float noodle_sigmoidf ( float x)

Compute sigmoid for one scalar.

Parameters
xScalar input.
Returns
Logistic sigmoid of x.

◆ noodle_soft_max()

uint16_t noodle_soft_max ( NoodleBuffer * input_output,
uint16_t n )

Apply numerically stabilized softmax in place on a NoodleBuffer.

Parameters
input_outputVector buffer updated in place.
nNumber of vector elements.
Returns
n, or 0 when input_output has no data.

◆ noodle_temp_buffers_free()

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.

◆ noodle_write_byte()

void noodle_write_byte ( NDL_File & f,
byte d )

Write a byte using NOODLE_FILE_FORMAT.

Parameters
fOpen output file.
dValue to write.

◆ noodle_write_float()

void noodle_write_float ( NDL_File & f,
float d )

Write a float using NOODLE_FILE_FORMAT.

Parameters
fOpen output file.
dValue to write.