Noodle
Loading...
Searching...
No Matches
noodle_internal.h File Reference

Private declarations shared by Noodle implementation files. More...

#include "noodle.h"
#include <math.h>
#include <float.h>
#include <stdint.h>
#include <stdlib.h>
Include dependency graph for noodle_internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

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

Variables

SdFat NOODLE_FS
 SdFat filesystem object used by the SdFat backend.
NDL_File fw
 Shared weight file handle used by streaming layer implementations.
NDL_File fb
 Shared bias file handle used by streaming layer implementations.
NDL_File fo
 Shared output file handle used by streaming layer implementations.
NDL_File fi
 Shared input file handle used by streaming layer implementations.
void * temp_buff1
 Global input scratch buffer, either Noodle-owned or caller-owned.
void * temp_buff2
 Global accumulation scratch buffer, either Noodle-owned or caller-owned.

Detailed Description

Private declarations shared by Noodle implementation files.

Application code should include noodle.h. This header exists so the split implementation files can share global file handles, scratch-buffer helpers, low-level math kernels, and raw-pointer layer implementations behind the public NoodleBuffer API.

Variable Documentation

◆ fb

NDL_File fb
extern

Shared bias file handle used by streaming layer implementations.

◆ fi

NDL_File fi
extern

Shared input file handle used by streaming layer implementations.

◆ fo

NDL_File fo
extern

Shared output file handle used by streaming layer implementations.

◆ fw

NDL_File fw
extern

Shared weight file handle used by streaming layer implementations.

◆ NOODLE_FS

SdFat NOODLE_FS
extern

SdFat filesystem object used by the SdFat backend.

◆ temp_buff1

void* temp_buff1
extern

Global input scratch buffer, either Noodle-owned or caller-owned.

◆ temp_buff2

void* temp_buff2
extern

Global accumulation scratch buffer, either Noodle-owned or caller-owned.