Noodle
Loading...
Searching...
No Matches
Internal Helpers
Collaboration diagram for Internal Helpers:

Files

file  noodle_internal.h
 Private declarations shared by Noodle implementation files.

Functions

float * noodle_temp1_require (size_t required_floats)
 Ensure temp buffer 1 can hold a number of floats.
float * noodle_temp2_require (size_t required_floats)
 Ensure temp buffer 2 can hold a number of floats.
void noodle_temp_buffers_free (void)
 Free Noodle-owned scratch buffers and detach external scratch buffers.
float * noodle_slice (float *flat, size_t W, size_t z)
 Return a channel plane from a packed [Z][W][W] tensor.
size_t noodle_read_raw (NDL_File &f, void *dst, size_t n)
 Read raw bytes from a backend file handle.
size_t noodle_write_raw (NDL_File &f, const void *src, size_t n)
 Write raw bytes to a backend file handle.
size_t noodle_read_float_block (NDL_File &f, float *dst, size_t n_floats)
 Read a block of floats using the configured scalar file format.
float noodle_dot_float_block (const float *x, const float *w, uint16_t n)
 Compute a dot product with a small unrolled loop.
uint16_t noodle_do_conv1d (float *input, float *kernel, uint16_t W, uint16_t K, float *output, uint16_t P, uint16_t S)
 Accumulate one 1D convolution into an output sequence.
uint16_t noodle_do_pooling1d (float *input, uint16_t W, uint16_t K, uint16_t S, const char *fn)
 Apply valid 1D max pooling and write to a file.
uint16_t noodle_do_pooling1d (float *input, uint16_t W, uint16_t K, uint16_t S, NDL_File &fo)
 Apply valid 1D max pooling and write to an open file.
uint16_t noodle_do_pooling1d (const float *input, uint16_t W, uint16_t K, uint16_t S, float *output)
 Apply valid 1D pooling and write to memory.
float noodle_get_padded_x (byte *grid, int16_t i, int16_t j, int16_t W, int16_t P0, int16_t P1)
 Read a byte grid sample with asymmetric zero padding.
float noodle_get_padded_x (float *grid, int16_t i, int16_t j, int16_t W, int16_t P0, int16_t P1)
 Read a float grid sample with asymmetric zero padding.
uint16_t noodle_do_bias (float *output, float bias, uint16_t n)
 Add bias to a square output map and apply ReLU.
uint16_t noodle_do_pooling (const float *input, uint16_t W, uint16_t K, uint16_t S, const char *fn)
 Apply 2D pooling and write to a file.
uint16_t noodle_do_pooling (const float *input, uint16_t W, uint16_t K, uint16_t S, NDL_File &fo)
 Apply 2D pooling and write to an open file.
uint16_t noodle_do_pooling (const float *input, uint16_t W, uint16_t K, uint16_t S, float *output)
 Apply 2D pooling and write to memory.
uint16_t noodle_do_conv (byte *grid, const float *kernel, uint16_t K, uint16_t W, float *output, uint16_t P, uint16_t S)
 Accumulate one byte-input 2D convolution plane.
uint16_t noodle_do_conv (float *grid, const float *kernel, uint16_t K, uint16_t W, float *output, uint16_t P, uint16_t S)
 Accumulate one float-input 2D convolution plane.
void noodle_reset_buffer (float *buffer, uint16_t n)
 Clear a float buffer.
uint16_t noodle_do_bias_act (float *output, float bias, uint16_t n, Activation act)
 Add bias to a square output map and apply the requested activation.
uint16_t noodle_do_conv_transpose (float *input, const float *kernel, uint16_t K, uint16_t W, float *output, uint16_t P, uint16_t S, uint16_t OP)
 Accumulate one 2D transpose-convolution plane.
void noodle_find_max (float *input, uint16_t n, float &max_val, uint16_t &max_idx)
 Find the maximum value and its index in a vector.
void noodle_unpack_bn_params (const float *bn_params, uint16_t N, const float **gamma, const float **beta, const float **mean, const float **var)
 Split packed batch-normalization parameters into four arrays.
uint16_t noodle_bn1d (float *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 raw vector.
uint16_t noodle_bn1d (float *x, uint16_t N, const float *bn_params, float eps)
 Apply 1D batch normalization from packed parameters.
uint16_t noodle_bn1d_relu (float *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 (float *x, uint16_t N, const float *bn_params, float eps)
 Apply packed 1D batch normalization followed by ReLU in place.
uint16_t noodle_bn2d (float *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 (float *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 (float *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 (float *x, uint16_t C, uint16_t W, const float *bn_params, float eps)
 Apply packed 2D batch normalization followed by ReLU.
uint16_t noodle_compute_V (uint16_t K, uint16_t W, uint16_t P, uint16_t S)
 Compute 2D convolution output width.
uint16_t noodle_compute_V_and_P (uint16_t K, uint16_t W, uint16_t P, uint16_t S, uint16_t &P0, uint16_t &P1)
 Compute 2D convolution output width and effective asymmetric padding.
uint16_t noodle_valid_max_pool (float *inplace, uint16_t W, uint16_t C, const Pool &pool)
 Apply valid max pooling to a packed channel-first tensor in place.
uint16_t noodle_compute_Vt (uint16_t K, uint16_t W, uint16_t P, uint16_t S, uint16_t OP)
 Compute transpose-convolution output width.
uint16_t noodle_compute_Vt_and_P (uint16_t K, uint16_t W, uint16_t P, uint16_t S, uint16_t OP, uint16_t &P0, uint16_t &P1)
 Compute transpose-convolution output width and effective padding.
uint16_t noodle_conv1d (float *in, uint16_t n_inputs, float *out, uint16_t n_outputs, uint16_t W, const ConvMem &conv, CBFPtr progress_cb)
 Raw memory-to-memory 1D convolution without pooling.
uint16_t noodle_conv1d (float *in, uint16_t n_inputs, float *out, uint16_t n_outputs, uint16_t W, const ConvMem &conv, const Pool &pool, CBFPtr progress_cb)
 Raw memory-to-memory 1D convolution with pooling.
uint16_t noodle_conv1d (float *in, uint16_t n_inputs, const char *out_fn, uint16_t n_outputs, uint16_t W, const ConvMem &conv, CBFPtr progress_cb)
 Raw memory-to-file 1D convolution without pooling.
uint16_t noodle_conv1d (const char *in_fn, uint16_t n_inputs, float *out, uint16_t n_outputs, uint16_t W, const ConvMem &conv, CBFPtr progress_cb)
 Raw file-to-memory 1D convolution without pooling.
uint16_t noodle_conv_float (const char *in_fn, uint16_t n_inputs, uint16_t n_outputs, float *output, uint16_t W, const Conv &conv, const Pool &pool, CBFPtr progress_cb)
 File-to-memory 2D convolution with file-backed parameters.
uint16_t noodle_conv_float (float *input, uint16_t n_inputs, uint16_t n_outputs, const char *out_fn, uint16_t W, const Conv &conv, const Pool &pool, CBFPtr progress_cb)
 Memory-to-file 2D convolution with file-backed parameters.
uint16_t noodle_conv_float (float *input, uint16_t n_inputs, uint16_t n_outputs, const char *out_fn, uint16_t W, const ConvMem &conv, const Pool &pool, CBFPtr progress_cb)
 Memory-to-file 2D convolution with memory-backed parameters.
uint16_t noodle_conv_float (float *input, uint16_t n_inputs, uint16_t n_outputs, float *output, uint16_t W, const Conv &conv, const Pool &pool, CBFPtr progress_cb)
 Raw memory-to-memory 2D convolution with file-backed parameters.
uint16_t noodle_conv_float (float *input, uint16_t n_inputs, uint16_t n_outputs, float *output, uint16_t W, const ConvMem &conv, const Pool &pool, CBFPtr progress_cb)
 Raw memory-to-memory 2D convolution with memory-backed parameters.
uint16_t noodle_conv_float (float *input, uint16_t n_inputs, uint16_t n_outputs, float *output, uint16_t W, const ConvProgmem &conv, const Pool &pool, CBFPtr progress_cb)
 Raw memory-to-memory 2D convolution with near-PROGMEM parameters.
uint16_t noodle_conv_transpose_float (float *input, uint16_t n_inputs, uint16_t n_outputs, float *output, uint16_t W, const ConvMem &conv, CBFPtr progress_cb)
 Raw memory-to-memory 2D transpose convolution.
uint16_t noodle_dwconv_float (float *input, uint16_t n_channels, float *output, uint16_t W, const Conv &conv, const Pool &pool, CBFPtr progress_cb)
 Raw memory-to-memory depthwise convolution with file-backed parameters.
uint16_t noodle_dwconv_float (float *input, uint16_t n_channels, float *output, uint16_t W, const ConvMem &conv, const Pool &pool, CBFPtr progress_cb)
 Raw memory-to-memory depthwise convolution with memory-backed parameters.
uint16_t noodle_dwconv_float (float *input, uint16_t n_channels, float *output, uint16_t W, const ConvProgmem &conv, const Pool &pool, CBFPtr progress_cb)
 Raw memory-to-memory depthwise convolution with near-PROGMEM parameters.
uint16_t noodle_fcn (const byte *input, uint16_t n_inputs, uint16_t n_outputs, float *output, const FCNFile &fcn, CBFPtr progress_cb)
 Byte-input fully connected layer with file-backed parameters.
uint16_t noodle_fcn (const int8_t *input, uint16_t n_inputs, uint16_t n_outputs, float *output, const FCNFile &fcn, CBFPtr progress_cb)
 Int8-input fully connected layer with file-backed parameters.
uint16_t noodle_fcn (const float *input, uint16_t n_inputs, uint16_t n_outputs, float *output, const FCNFile &fcn, CBFPtr progress_cb)
 Float-input fully connected layer with file-backed parameters.
uint16_t noodle_fcn (const float *input, uint16_t n_inputs, uint16_t n_outputs, const char *out_fn, const FCNFile &fcn, CBFPtr progress_cb)
 Float-input fully connected layer that writes output to a file.
uint16_t noodle_fcn (const char *in_fn, uint16_t n_inputs, uint16_t n_outputs, float *output, const FCNFile &fcn, CBFPtr progress_cb)
 File-input fully connected layer that writes output to memory.
uint16_t noodle_fcn (const float *input, uint16_t n_inputs, uint16_t n_outputs, float *output, const FCNMem &fcn, CBFPtr progress_cb)
 Float-input fully connected layer with memory-backed parameters.
uint16_t noodle_fcn (const float *input, uint16_t n_inputs, uint16_t n_outputs, float *output, const FCNProgmem &fcn, CBFPtr progress_cb)
 Float-input fully connected layer with far-PROGMEM parameters.
uint16_t noodle_fcn_progmem (const float *input, uint16_t n_inputs, uint16_t n_outputs, float *output, const float *weight, const float *bias, Activation act, CBFPtr progress_cb)
 Float-input fully connected layer with near-PROGMEM parameters.
void noodle_array_to_file (float *array, NDL_File &fo, uint16_t n)
 Write a float array to an already-open file.
void noodle_grid_to_file (byte *grid, NDL_File &fo, uint16_t n)
 Write a byte grid to an already-open file.
void noodle_grid_to_file (float *grid, NDL_File &fo, uint16_t n)
 Write a float grid to an already-open file.
void noodle_array_from_file (NDL_File &fi, float *buffer, uint16_t K)
 Read a float array from an already-open file.
void noodle_grid_from_file (NDL_File &fi, byte *buffer, uint16_t K)
 Read a byte grid from an already-open file.
void noodle_grid_from_file (NDL_File &fi, int8_t *buffer, uint16_t K)
 Read an int8 grid from an already-open file.
void noodle_grid_from_file (NDL_File &fi, float *buffer, uint16_t K)
 Read a float grid from an already-open file.
void noodle_copy_kernel_progmem (const float *w, uint32_t base, uint16_t K, float *kernel)
 Copy one square kernel from near-PROGMEM into RAM.
uint16_t noodle_flat (const char *in_fn, float *output, uint16_t V, uint16_t n_filters)
 Flatten a packed file tensor into an HWC-like raw vector.
uint16_t noodle_flat (float *input, float *output, uint16_t V, uint16_t n_filters)
 Flatten a packed memory tensor into an HWC-like raw vector.
uint16_t noodle_reshape (const float *src_hwc, float *dst_chw, uint16_t W, uint16_t C)
 Convert HWC-like raw data to packed channel-first raw data.
uint16_t noodle_gap (float *inout, uint16_t C, uint16_t W)
 Apply global average pooling in place to packed channel-first maps.
uint16_t noodle_gmp (float *inout, uint16_t C, uint16_t W)
 Apply global max pooling in place to packed channel-first data.
uint16_t noodle_soft_max (float *input_output, uint16_t n)
 Apply numerically stabilized softmax in place.
uint16_t noodle_sigmoid (float *input_output, uint16_t n)
 Apply sigmoid in place.
float noodle_sigmoidf (float x)
 Compute sigmoid for one scalar.
uint16_t noodle_logit (float *input_output, uint16_t n)
 Apply logistic sigmoid in place.
uint16_t noodle_relu (float *input_output, uint16_t n)
 Apply ReLU in place.
uint16_t noodle_bn (float *x, uint16_t C, uint16_t W, const float *gamma, const float *beta, const float *mean, const float *var, float eps)
 Backward-compatible raw alias for noodle_bn2d().
uint16_t noodle_bn (float *x, uint16_t C, uint16_t W, const float *bn_params, float eps)
 Backward-compatible raw alias for packed-parameter noodle_bn2d().
uint16_t noodle_bn_relu (float *x, uint16_t C, uint16_t W, const float *gamma, const float *beta, const float *mean, const float *var, float eps)
 Backward-compatible raw alias for noodle_bn2d_relu().
uint16_t noodle_bn_relu (float *x, uint16_t C, uint16_t W, const float *bn_params, float eps)
 Backward-compatible raw alias for packed-parameter noodle_bn2d_relu().

Detailed Description

Maintainer-facing helpers used by Noodle implementation files.

Function Documentation

◆ noodle_array_from_file()

void noodle_array_from_file ( NDL_File & fi,
float * buffer,
uint16_t K )

Read a float array from an already-open file.

◆ noodle_array_to_file()

void noodle_array_to_file ( float * array,
NDL_File & fo,
uint16_t n )

Write a float array to an already-open file.

◆ noodle_bn() [1/2]

uint16_t noodle_bn ( float * x,
uint16_t C,
uint16_t W,
const float * bn_params,
float eps )

Backward-compatible raw 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 updated in place.
CNumber of channels.
WPlane width and height.
bn_paramsPacked batch-normalization parameters.
epsSmall value added to variance before inversion.
Returns
W.

◆ noodle_bn() [2/2]

uint16_t noodle_bn ( float * x,
uint16_t C,
uint16_t W,
const float * gamma,
const float * beta,
const float * mean,
const float * var,
float eps )

Backward-compatible raw alias for noodle_bn2d().

Treats x as packed [C][W][W].

Parameters
xTensor 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.

◆ noodle_bn1d() [1/2]

uint16_t noodle_bn1d ( float * x,
uint16_t N,
const float * bn_params,
float eps )

Apply 1D batch normalization from packed parameters.

bn_params is packed as [gamma[N]][beta[N]][mean[N]][var[N]].

Parameters
xVector updated in place.
NNumber of vector elements.
bn_paramsPacked batch-normalization parameters.
epsSmall value added to variance before inversion.
Returns
N.

◆ noodle_bn1d() [2/2]

uint16_t noodle_bn1d ( float * 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 raw vector.

gamma, beta, mean, and var each contain N values.

Parameters
xVector 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.

◆ noodle_bn1d_relu() [1/2]

uint16_t noodle_bn1d_relu ( float * 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 updated in place.
NNumber of vector elements.
bn_paramsPacked batch-normalization parameters.
epsSmall value added to variance before inversion.
Returns
N.

◆ noodle_bn1d_relu() [2/2]

uint16_t noodle_bn1d_relu ( float * 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 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.

◆ noodle_bn2d() [1/2]

uint16_t noodle_bn2d ( float * 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 updated in place.
CNumber of channels.
WPlane width and height.
bn_paramsPacked batch-normalization parameters.
epsSmall value added to variance before inversion.
Returns
W.

◆ noodle_bn2d() [2/2]

uint16_t noodle_bn2d ( float * 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 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.

◆ noodle_bn2d_relu() [1/2]

uint16_t noodle_bn2d_relu ( float * 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 updated in place.
CNumber of channels.
WPlane width and height.
bn_paramsPacked batch-normalization parameters.
epsSmall value added to variance before inversion.
Returns
W.

◆ noodle_bn2d_relu() [2/2]

uint16_t noodle_bn2d_relu ( float * 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 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.

◆ noodle_bn_relu() [1/2]

uint16_t noodle_bn_relu ( float * x,
uint16_t C,
uint16_t W,
const float * bn_params,
float eps )

Backward-compatible raw 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 updated in place.
CNumber of channels.
WPlane width and height.
bn_paramsPacked batch-normalization parameters.
epsSmall value added to variance before inversion.
Returns
W.

◆ noodle_bn_relu() [2/2]

uint16_t noodle_bn_relu ( float * x,
uint16_t C,
uint16_t W,
const float * gamma,
const float * beta,
const float * mean,
const float * var,
float eps )

Backward-compatible raw alias for noodle_bn2d_relu().

Treats x as packed [C][W][W].

Parameters
xTensor 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.

◆ noodle_compute_V()

uint16_t noodle_compute_V ( uint16_t K,
uint16_t W,
uint16_t P,
uint16_t S )

Compute 2D convolution output width.

Parameters
KKernel width.
WInput width.
PPadding per side, or 65535 for SAME-style padding.
SStride.
Returns
Output width.

◆ noodle_compute_V_and_P()

uint16_t noodle_compute_V_and_P ( uint16_t K,
uint16_t W,
uint16_t P,
uint16_t S,
uint16_t & P0,
uint16_t & P1 )

Compute 2D convolution output width and effective asymmetric padding.

Parameters
KKernel width.
WInput width.
PPadding per side, or 65535 for SAME-style padding.
SStride.
P0Receives top/left padding.
P1Receives bottom/right padding.
Returns
Output width.

◆ noodle_compute_Vt()

uint16_t noodle_compute_Vt ( uint16_t K,
uint16_t W,
uint16_t P,
uint16_t S,
uint16_t OP )

Compute transpose-convolution output width.

For explicit padding, this computes V = (W - 1) * S - 2 * P + K + OP; callers choose OP to match the desired output width. With P == 65535, SAME-style output uses V = W * S.

Parameters
KKernel width.
WInput width.
PPadding per side, or 65535 for SAME-style padding.
SStride.
OPUser-computed output padding for explicit padding.
Returns
Output width.

◆ noodle_compute_Vt_and_P()

uint16_t noodle_compute_Vt_and_P ( uint16_t K,
uint16_t W,
uint16_t P,
uint16_t S,
uint16_t OP,
uint16_t & P0,
uint16_t & P1 )

Compute transpose-convolution output width and effective padding.

For explicit padding, this computes V = (W - 1) * S - 2 * P + K + OP; callers choose OP to match the desired output width. With P == 65535, SAME-style output uses V = W * S and derives asymmetric crop values.

Parameters
KKernel width.
WInput width.
PPadding per side, or 65535 for SAME-style padding.
SStride.
OPUser-computed output padding for explicit padding.
P0Receives top/left padding.
P1Receives bottom/right padding.
Returns
Output width.

◆ noodle_conv1d() [1/4]

uint16_t noodle_conv1d ( const char * in_fn,
uint16_t n_inputs,
float * out,
uint16_t n_outputs,
uint16_t W,
const ConvMem & conv,
CBFPtr progress_cb )

Raw file-to-memory 1D convolution without pooling.

◆ noodle_conv1d() [2/4]

uint16_t noodle_conv1d ( float * in,
uint16_t n_inputs,
const char * out_fn,
uint16_t n_outputs,
uint16_t W,
const ConvMem & conv,
CBFPtr progress_cb )

Raw memory-to-file 1D convolution without pooling.

◆ noodle_conv1d() [3/4]

uint16_t noodle_conv1d ( float * in,
uint16_t n_inputs,
float * out,
uint16_t n_outputs,
uint16_t W,
const ConvMem & conv,
CBFPtr progress_cb )

Raw memory-to-memory 1D convolution without pooling.

◆ noodle_conv1d() [4/4]

uint16_t noodle_conv1d ( float * in,
uint16_t n_inputs,
float * out,
uint16_t n_outputs,
uint16_t W,
const ConvMem & conv,
const Pool & pool,
CBFPtr progress_cb )

Raw memory-to-memory 1D convolution with pooling.

◆ noodle_conv_float() [1/6]

uint16_t noodle_conv_float ( const char * in_fn,
uint16_t n_inputs,
uint16_t n_outputs,
float * output,
uint16_t W,
const Conv & conv,
const Pool & pool,
CBFPtr progress_cb )

File-to-memory 2D convolution with file-backed parameters.

◆ noodle_conv_float() [2/6]

uint16_t noodle_conv_float ( float * input,
uint16_t n_inputs,
uint16_t n_outputs,
const char * out_fn,
uint16_t W,
const Conv & conv,
const Pool & pool,
CBFPtr progress_cb )

Memory-to-file 2D convolution with file-backed parameters.

◆ noodle_conv_float() [3/6]

uint16_t noodle_conv_float ( float * input,
uint16_t n_inputs,
uint16_t n_outputs,
const char * out_fn,
uint16_t W,
const ConvMem & conv,
const Pool & pool,
CBFPtr progress_cb )

Memory-to-file 2D convolution with memory-backed parameters.

◆ noodle_conv_float() [4/6]

uint16_t noodle_conv_float ( float * input,
uint16_t n_inputs,
uint16_t n_outputs,
float * output,
uint16_t W,
const Conv & conv,
const Pool & pool,
CBFPtr progress_cb )

Raw memory-to-memory 2D convolution with file-backed parameters.

◆ noodle_conv_float() [5/6]

uint16_t noodle_conv_float ( float * input,
uint16_t n_inputs,
uint16_t n_outputs,
float * output,
uint16_t W,
const ConvMem & conv,
const Pool & pool,
CBFPtr progress_cb )

Raw memory-to-memory 2D convolution with memory-backed parameters.

◆ noodle_conv_float() [6/6]

uint16_t noodle_conv_float ( float * input,
uint16_t n_inputs,
uint16_t n_outputs,
float * output,
uint16_t W,
const ConvProgmem & conv,
const Pool & pool,
CBFPtr progress_cb )

Raw memory-to-memory 2D convolution with near-PROGMEM parameters.

◆ noodle_conv_transpose_float()

uint16_t noodle_conv_transpose_float ( float * input,
uint16_t n_inputs,
uint16_t n_outputs,
float * output,
uint16_t W,
const ConvMem & conv,
CBFPtr progress_cb )

Raw memory-to-memory 2D transpose convolution.

Input and output use packed channel-first layout. conv.weight is packed as [O][I][K][K]. For explicit padding, callers set conv.OP so V = (W - 1) * conv.S - 2 * conv.P + conv.K + conv.OP matches the desired output width.

Parameters
inputPacked [I][W][W] input tensor.
n_inputsNumber of input channels.
n_outputsNumber of output channels.
outputPacked [O][V][V] output tensor.
WInput width and height.
convMemory-backed transpose convolution parameters.
progress_cbOptional progress callback.
Returns
Output width, or 0 on null input/output/weights or invalid shape.

◆ noodle_copy_kernel_progmem()

void noodle_copy_kernel_progmem ( const float * w,
uint32_t base,
uint16_t K,
float * kernel )

Copy one square kernel from near-PROGMEM into RAM.

Parameters
wBase pointer to packed PROGMEM weights.
baseElement offset of the first kernel value.
KKernel width.
kernelDestination buffer with room for K * K floats.

◆ noodle_do_bias()

uint16_t noodle_do_bias ( float * output,
float bias,
uint16_t n )

Add bias to a square output map and apply ReLU.

Parameters
outputOutput map with n * n values.
biasBias scalar.
nMap width and height.
Returns
n.

◆ noodle_do_bias_act()

uint16_t noodle_do_bias_act ( float * output,
float bias,
uint16_t n,
Activation act )

Add bias to a square output map and apply the requested activation.

ACT_RELU clamps negative values to zero. ACT_NONE leaves biased values unchanged. Other activation values are ignored here.

Parameters
outputOutput map with n * n values.
biasBias scalar.
nMap width and height.
actActivation to apply.
Returns
n.

◆ noodle_do_conv() [1/2]

uint16_t noodle_do_conv ( byte * grid,
const float * kernel,
uint16_t K,
uint16_t W,
float * output,
uint16_t P,
uint16_t S )

Accumulate one byte-input 2D convolution plane.

The input plane is [W][W]; the kernel is [K][K]; output is accumulated in [V][V] order instead of cleared.

Parameters
gridInput plane.
kernelKernel values.
KKernel width.
WInput width and height.
outputOutput accumulator.
PPadding per side, or 65535 for SAME-style padding.
SStride.
Returns
Output width before pooling.

◆ noodle_do_conv() [2/2]

uint16_t noodle_do_conv ( float * grid,
const float * kernel,
uint16_t K,
uint16_t W,
float * output,
uint16_t P,
uint16_t S )

Accumulate one float-input 2D convolution plane.

The input plane is [W][W]; the kernel is [K][K]; output is accumulated in [V][V] order instead of cleared.

Parameters
gridInput plane.
kernelKernel values.
KKernel width.
WInput width and height.
outputOutput accumulator.
PPadding per side, or 65535 for SAME-style padding.
SStride.
Returns
Output width before pooling.

◆ noodle_do_conv1d()

uint16_t noodle_do_conv1d ( float * input,
float * kernel,
uint16_t W,
uint16_t K,
float * output,
uint16_t P,
uint16_t S )

Accumulate one 1D convolution into an output sequence.

Values outside the input sequence are treated as zero.

Parameters
inputInput sequence with W values.
kernelKernel with K values.
WInput sequence length.
KKernel length.
outputAccumulator receiving V values.
PZero padding per side.
SStride.
Returns
Output length before pooling.

◆ noodle_do_conv_transpose()

uint16_t noodle_do_conv_transpose ( float * input,
const float * kernel,
uint16_t K,
uint16_t W,
float * output,
uint16_t P,
uint16_t S,
uint16_t OP )

Accumulate one 2D transpose-convolution plane.

The input plane is [W][W]; the kernel is [K][K]; output is accumulated in [Vt][Vt] order instead of cleared.

For explicit padding, callers choose OP so Vt = (W - 1) * S - 2 * P + K + OP matches the desired output width. With P == 65535, SAME-style transpose output uses Vt = W * S.

Parameters
inputInput plane.
kernelKernel values.
KKernel width.
WInput width and height.
outputOutput accumulator.
PPadding per side, or 65535 for SAME-style padding.
SStride.
OPUser-computed output padding for explicit padding.
Returns
Output width.

◆ noodle_do_pooling() [1/3]

uint16_t noodle_do_pooling ( const float * input,
uint16_t W,
uint16_t K,
uint16_t S,
const char * fn )

Apply 2D pooling and write to a file.

When NOODLE_POOL_MODE is NOODLE_POOL_NONE, this writes the input map unchanged.

Parameters
inputInput map with W * W values.
WInput width and height.
KPool window size.
SPool stride.
fnOutput file.
Returns
Output width, or 0 for invalid pooling parameters.

◆ noodle_do_pooling() [2/3]

uint16_t noodle_do_pooling ( const float * input,
uint16_t W,
uint16_t K,
uint16_t S,
float * output )

Apply 2D pooling and write to memory.

Parameters
inputInput map with W * W values.
WInput width and height.
KPool window size.
SPool stride.
outputDestination map.
Returns
Output width, or W for identity/no pooling.

◆ noodle_do_pooling() [3/3]

uint16_t noodle_do_pooling ( const float * input,
uint16_t W,
uint16_t K,
uint16_t S,
NDL_File & fo )

Apply 2D pooling and write to an open file.

Parameters
inputInput map with W * W values.
WInput width and height.
KPool window size.
SPool stride.
foOpen output file handle.
Returns
Output width, or 0 for invalid pooling parameters.

◆ noodle_do_pooling1d() [1/3]

uint16_t noodle_do_pooling1d ( const float * input,
uint16_t W,
uint16_t K,
uint16_t S,
float * output )

Apply valid 1D pooling and write to memory.

K <= 1 copies the input unchanged. S == 0 defaults the stride to K. The helper computes mean pooling only when NOODLE_POOL_MODE selects mean pooling; otherwise it computes max pooling.

Parameters
inputInput sequence with W values.
WInput sequence length.
KPool window size.
SPool stride, or 0 to use K.
outputDestination sequence.
Returns
Output sequence length.

◆ noodle_do_pooling1d() [2/3]

uint16_t noodle_do_pooling1d ( float * input,
uint16_t W,
uint16_t K,
uint16_t S,
const char * fn )

Apply valid 1D max pooling and write to a file.

Parameters
inputInput sequence with W values.
WInput sequence length.
KPool window size.
SPool stride.
fnOutput file.
Returns
Output sequence length.

◆ noodle_do_pooling1d() [3/3]

uint16_t noodle_do_pooling1d ( float * input,
uint16_t W,
uint16_t K,
uint16_t S,
NDL_File & fo )

Apply valid 1D max pooling and write to an open file.

Parameters
inputInput sequence with W values.
WInput sequence length.
KPool window size.
SPool stride.
foOpen output file handle.
Returns
Output sequence length.

◆ noodle_dot_float_block()

float noodle_dot_float_block ( const float * x,
const float * w,
uint16_t n )

Compute a dot product with a small unrolled loop.

Parameters
xInput vector.
wWeight vector.
nNumber of elements.
Returns
Sum of element-wise products.

◆ noodle_dwconv_float() [1/3]

uint16_t noodle_dwconv_float ( float * input,
uint16_t n_channels,
float * output,
uint16_t W,
const Conv & conv,
const Pool & pool,
CBFPtr progress_cb )

Raw memory-to-memory depthwise convolution with file-backed parameters.

◆ noodle_dwconv_float() [2/3]

uint16_t noodle_dwconv_float ( float * input,
uint16_t n_channels,
float * output,
uint16_t W,
const ConvMem & conv,
const Pool & pool,
CBFPtr progress_cb )

Raw memory-to-memory depthwise convolution with memory-backed parameters.

◆ noodle_dwconv_float() [3/3]

uint16_t noodle_dwconv_float ( float * input,
uint16_t n_channels,
float * output,
uint16_t W,
const ConvProgmem & conv,
const Pool & pool,
CBFPtr progress_cb )

Raw memory-to-memory depthwise convolution with near-PROGMEM parameters.

◆ noodle_fcn() [1/7]

uint16_t noodle_fcn ( const byte * input,
uint16_t n_inputs,
uint16_t n_outputs,
float * output,
const FCNFile & fcn,
CBFPtr progress_cb )

Byte-input fully connected layer with file-backed parameters.

◆ noodle_fcn() [2/7]

uint16_t noodle_fcn ( const char * in_fn,
uint16_t n_inputs,
uint16_t n_outputs,
float * output,
const FCNFile & fcn,
CBFPtr progress_cb )

File-input fully connected layer that writes output to memory.

◆ noodle_fcn() [3/7]

uint16_t noodle_fcn ( const float * input,
uint16_t n_inputs,
uint16_t n_outputs,
const char * out_fn,
const FCNFile & fcn,
CBFPtr progress_cb )

Float-input fully connected layer that writes output to a file.

◆ noodle_fcn() [4/7]

uint16_t noodle_fcn ( const float * input,
uint16_t n_inputs,
uint16_t n_outputs,
float * output,
const FCNFile & fcn,
CBFPtr progress_cb )

Float-input fully connected layer with file-backed parameters.

◆ noodle_fcn() [5/7]

uint16_t noodle_fcn ( const float * input,
uint16_t n_inputs,
uint16_t n_outputs,
float * output,
const FCNMem & fcn,
CBFPtr progress_cb )

Float-input fully connected layer with memory-backed parameters.

◆ noodle_fcn() [6/7]

uint16_t noodle_fcn ( const float * input,
uint16_t n_inputs,
uint16_t n_outputs,
float * output,
const FCNProgmem & fcn,
CBFPtr progress_cb )

Float-input fully connected layer with far-PROGMEM parameters.

◆ noodle_fcn() [7/7]

uint16_t noodle_fcn ( const int8_t * input,
uint16_t n_inputs,
uint16_t n_outputs,
float * output,
const FCNFile & fcn,
CBFPtr progress_cb )

Int8-input fully connected layer with file-backed parameters.

◆ noodle_fcn_progmem()

uint16_t noodle_fcn_progmem ( const float * input,
uint16_t n_inputs,
uint16_t n_outputs,
float * output,
const float * weight,
const float * bias,
Activation act,
CBFPtr progress_cb )

Float-input fully connected layer with near-PROGMEM parameters.

◆ noodle_find_max()

void noodle_find_max ( float * input,
uint16_t n,
float & max_val,
uint16_t & max_idx )

Find the maximum value and its index in a vector.

Parameters
inputInput vector.
nNumber of values.
max_valReceives the maximum value.
max_idxReceives the index of the maximum value.

◆ noodle_flat() [1/2]

uint16_t noodle_flat ( const char * in_fn,
float * output,
uint16_t V,
uint16_t n_filters )

Flatten a packed file tensor into an HWC-like raw vector.

Reads packed [C][V][V] input and writes output[pixel * n_filters + channel].

Parameters
in_fnInput file containing packed channel-first planes.
outputDestination buffer with room for V * V * n_filters floats.
VInput plane width and height.
n_filtersNumber of channel planes.
Returns
Number of floats written.

◆ noodle_flat() [2/2]

uint16_t noodle_flat ( float * input,
float * output,
uint16_t V,
uint16_t n_filters )

Flatten a packed memory tensor into an HWC-like raw vector.

Reads input as packed [C][V][V] and writes output[pixel * n_filters + channel].

Parameters
inputSource buffer with packed channel-first planes.
outputDestination buffer with room for V * V * n_filters floats.
VInput plane width and height.
n_filtersNumber of channel planes.
Returns
Number of floats written.

◆ noodle_gap()

uint16_t noodle_gap ( float * inout,
uint16_t C,
uint16_t W )

Apply global average pooling in place to 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.

◆ noodle_get_padded_x() [1/2]

float noodle_get_padded_x ( byte * grid,
int16_t i,
int16_t j,
int16_t W,
int16_t P0,
int16_t P1 )

Read a byte grid sample with asymmetric zero padding.

Parameters
gridInput plane with W * W byte values.
iPadded-row coordinate.
jPadded-column coordinate.
WInput width and height.
P0Top/left padding.
P1Bottom/right padding.
Returns
Input value, or 0.0 outside the unpadded grid.

◆ noodle_get_padded_x() [2/2]

float noodle_get_padded_x ( float * grid,
int16_t i,
int16_t j,
int16_t W,
int16_t P0,
int16_t P1 )

Read a float grid sample with asymmetric zero padding.

Parameters
gridInput plane with W * W float values.
iPadded-row coordinate.
jPadded-column coordinate.
WInput width and height.
P0Top/left padding.
P1Bottom/right padding.
Returns
Input value, or 0.0 outside the unpadded grid.

◆ noodle_gmp()

uint16_t noodle_gmp ( float * inout,
uint16_t C,
uint16_t W )

Apply global max pooling in place to 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.

◆ noodle_grid_from_file() [1/3]

void noodle_grid_from_file ( NDL_File & fi,
byte * buffer,
uint16_t K )

Read a byte grid from an already-open file.

◆ noodle_grid_from_file() [2/3]

void noodle_grid_from_file ( NDL_File & fi,
float * buffer,
uint16_t K )

Read a float grid from an already-open file.

◆ noodle_grid_from_file() [3/3]

void noodle_grid_from_file ( NDL_File & fi,
int8_t * buffer,
uint16_t K )

Read an int8 grid from an already-open file.

◆ noodle_grid_to_file() [1/2]

void noodle_grid_to_file ( byte * grid,
NDL_File & fo,
uint16_t n )

Write a byte grid to an already-open file.

◆ noodle_grid_to_file() [2/2]

void noodle_grid_to_file ( float * grid,
NDL_File & fo,
uint16_t n )

Write a float grid to an already-open file.

◆ noodle_logit()

uint16_t noodle_logit ( float * input_output,
uint16_t n )

Apply logistic sigmoid in place.

Parameters
input_outputVector updated in place.
nNumber of vector elements.
Returns
n.

◆ noodle_read_float_block()

size_t noodle_read_float_block ( NDL_File & f,
float * dst,
size_t n_floats )

Read a block of floats using the configured scalar file format.

In binary mode this reads raw float32 bytes. In text mode it calls noodle_read_float() once per value.

Parameters
fOpen input file.
dstDestination float buffer.
n_floatsNumber of floats requested.
Returns
Number of floats read.

◆ noodle_read_raw()

size_t noodle_read_raw ( NDL_File & f,
void * dst,
size_t n )

Read raw bytes from a backend file handle.

Parameters
fOpen file handle.
dstDestination buffer.
nNumber of bytes to read.
Returns
Number of bytes read, or 0 for the no-filesystem backend.

◆ noodle_relu()

uint16_t noodle_relu ( float * input_output,
uint16_t n )

Apply ReLU in place.

Parameters
input_outputVector updated in place.
nNumber of vector elements.
Returns
n.

◆ noodle_reset_buffer()

void noodle_reset_buffer ( float * buffer,
uint16_t n )

Clear a float buffer.

Parameters
bufferBuffer to fill with zero.
nNumber of float elements.

◆ noodle_reshape()

uint16_t noodle_reshape ( const float * src_hwc,
float * dst_chw,
uint16_t W,
uint16_t C )

Convert HWC-like raw data to packed channel-first raw data.

Reads src_hwc[pixel * C + channel] and writes packed [C][W][W] data into dst_chw.

Parameters
src_hwcSource buffer in HWC-like order.
dst_chwDestination buffer with room for W * W * C floats.
WOutput plane width and height.
CNumber of channel planes.
Returns
Number of floats written.

◆ noodle_sigmoid()

uint16_t noodle_sigmoid ( float * input_output,
uint16_t n )

Apply sigmoid in place.

Parameters
input_outputVector updated in place.
nNumber of vector elements.
Returns
n.

◆ noodle_sigmoidf()

float noodle_sigmoidf ( float x)

Compute sigmoid for one scalar.

Parameters
xScalar input.
Returns
Logistic sigmoid of x.

◆ noodle_slice()

float * noodle_slice ( float * flat,
size_t W,
size_t z )

Return a channel plane from a packed [Z][W][W] tensor.

Parameters
flatBase pointer to the packed tensor.
WWidth and height of each plane.
zPlane/channel index.
Returns
Pointer to the first element of plane z.

◆ noodle_soft_max()

uint16_t noodle_soft_max ( float * input_output,
uint16_t n )

Apply numerically stabilized softmax in place.

Parameters
input_outputVector updated in place.
nNumber of vector elements.
Returns
n.

◆ noodle_temp1_require()

float * noodle_temp1_require ( size_t required_floats)

Ensure temp buffer 1 can hold a number of floats.

Automatically allocated buffers grow when needed. A buffer installed with noodle_setup_temp_buffers() has unknown capacity and is returned as-is.

Parameters
required_floatsRequired capacity in float elements.
Returns
Usable float pointer, or NULL on allocation failure/zero request.

◆ noodle_temp2_require()

float * noodle_temp2_require ( size_t required_floats)

Ensure temp buffer 2 can hold a number of floats.

Automatically allocated buffers grow when needed. A buffer installed with noodle_setup_temp_buffers() has unknown capacity and is returned as-is.

Parameters
required_floatsRequired capacity in float elements.
Returns
Usable float pointer, or NULL on allocation failure/zero request.

◆ noodle_temp_buffers_free()

void noodle_temp_buffers_free ( void )

Free Noodle-owned scratch buffers and detach external scratch buffers.

Free Noodle-owned scratch buffers and detach external scratch buffers.

External buffers installed with noodle_setup_temp_buffers() are detached but not freed.

◆ noodle_unpack_bn_params()

void noodle_unpack_bn_params ( const float * bn_params,
uint16_t N,
const float ** gamma,
const float ** beta,
const float ** mean,
const float ** var )

Split packed batch-normalization parameters into four arrays.

Parameters
bn_paramsPacked [gamma[N]][beta[N]][mean[N]][var[N]] values.
NNumber of elements per parameter array.
gammaReceives pointer to gamma values.
betaReceives pointer to beta values.
meanReceives pointer to mean values.
varReceives pointer to variance values.

◆ noodle_valid_max_pool()

uint16_t noodle_valid_max_pool ( float * inplace,
uint16_t W,
uint16_t C,
const Pool & pool )

Apply valid max pooling to a packed channel-first tensor in place.

Parameters
inplaceTensor in packed [C][W][W] order; compacted in place.
WInput width and height.
CNumber of channels.
poolPooling parameters.
Returns
Output width, or 0 for invalid parameters.

◆ noodle_write_raw()

size_t noodle_write_raw ( NDL_File & f,
const void * src,
size_t n )

Write raw bytes to a backend file handle.

Parameters
fOpen file handle.
srcSource buffer.
nNumber of bytes to write.
Returns
Number of bytes written, or 0 for the no-filesystem backend.