Noodle
Loading...
Searching...
No Matches
Internal helpers

File and File-System Utilities

void noodle_delete_file (const char *fn)
 Delete a file if it exists.
 

Scalar I/O helpers

void noodle_write_float (NDL_File &f, float d)
 
float noodle_read_float (NDL_File &f)
 Read a float up to the next newline.
 
byte noodle_read_byte (NDL_File &f)
 Read a byte value fron an opened file handler and store as an integer text line.
 
void noodle_write_byte (NDL_File &f, byte d)
 Write a byte value as an integer text line to an opend file.
 

Memory utilities

void noodle_reset_buffer (float *buffer, uint16_t n)
 Fill buffer with zeros (n floats).
 
float * noodle_slice (float *flat, size_t W, size_t z)
 
void noodle_array_to_file (float *array, NDL_File &fo, uint16_t n)
 Write an array of n floats to fo (an opened file handler), one value per line. No file open and close operations.
 
void noodle_grid_to_file (byte *grid, NDL_File &fo, uint16_t n)
 Write an n byte grid to fo (opened file handler) as bytes, row-major. No file open and close operations.
 
void noodle_grid_to_file (float *grid, NDL_File &fo, uint16_t n)
 Write an n float grid to fo (an opened file handler), row-major.
 
void noodle_grid_from_file (NDL_File &fi, float *buffer, uint16_t K)
 

Internal Helpers for Pooling

uint16_t noodle_do_pooling (const float *input, uint16_t W, uint16_t K, uint16_t S, const char *fn)
 2D pooling over a V×V map, writing results to a file (one float per line).Pooling mode (MAX or MEAN) is selected via NOODLE_POOL_MODE at compile time. This layer uses valid pooling. NO PADDING IS APPLIED!
 
uint16_t noodle_do_pooling1d (float *input, uint16_t W, uint16_t K, uint16_t S, const char *fn)
 
uint16_t noodle_do_pooling (const float *input, uint16_t W, uint16_t K, uint16_t S, NDL_File &fo)
 
uint16_t noodle_do_pooling (const float *input, uint16_t W, uint16_t K, uint16_t S, float *output)
 
uint16_t noodle_do_pooling1d (float *input, uint16_t W, uint16_t K, uint16_t S, NDL_File &fo)
 

Internal Helpers for Convolution

uint16_t noodle_do_conv1d (float *input, float *kernel, uint16_t W, uint16_t K, float *output, uint16_t P, uint16_t S)
 
uint16_t noodle_do_conv (byte *grid, const float *kernel, uint16_t K, uint16_t W, float *output, uint16_t P, uint16_t S)
 2D valid/same convolution with zero padding and stride, accumulating into output.Output spatial size is V = (W - K + 2P)/S + 1.
 
uint16_t noodle_do_bias (float *output, float bias, uint16_t n)
 
uint16_t noodle_do_bias_act (float *output, float bias, uint16_t n, Activation act)
 Add bias to each element of a V×V map (in-place) and optionally apply activation.
 
float noodle_get_padded_x (byte *grid, int16_t i, int16_t j, int16_t W, int16_t P)
 Get padded input sample from a byte grid with zero padding.Noodle uses symmetric, stride-independent padding for all convolutions.
 
float noodle_get_padded_x (float *grid, int16_t i, int16_t j, int16_t W, int16_t P)
 Get padded input sample from a float grid with zero padding.
 
uint16_t noodle_do_conv (float *grid, const float *kernel, uint16_t K, uint16_t W, float *output, uint16_t P, uint16_t S)
 

2D Depth-wise Convolution

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

Detailed Description

Internal helpers and implementation details. Not intended for direct application use.

Function Documentation

◆ noodle_array_to_file()

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

Write an array of n floats to fo (an opened file handler), one value per line. No file open and close operations.

◆ noodle_delete_file()

void noodle_delete_file ( const char *  fn)

Delete a file if it exists.

◆ noodle_do_bias()

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

Add a scalar bias to each element of a V×V map in-place and apply ReLU.

Convenience legacy helper used by file-streamed conv paths.

Parameters
outputAccumulator buffer of size V×V (float).
biasScalar to add to each element.
nV (output width/height).
Returns
V.

◆ noodle_do_bias_act()

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

Add bias to each element of a V×V map (in-place) and optionally apply activation.

Parameters
outputAccumulator buffer of size V×V (float).
biasScalar to add to each element.
nV (output width/height).
actActivation to apply (ACT_NONE or ACT_RELU).
Returns
V.

◆ 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 
)

2D valid/same convolution with zero padding and stride, accumulating into output.Output spatial size is V = (W - K + 2P)/S + 1.

Parameters
gridInput grid (bytes interpreted as values 0..255).
kernelK×K float kernel.
K,W,P,SSee common semantics.
outputAccumulator buffer of size at least V×V (float).
Returns
V, the output width/height.

◆ 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 
)

◆ 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 
)

1D convolution with zero padding/stride, accumulating into output. Output length is V = (W - K + 2P)/S + 1.

◆ 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 
)

2D pooling over a V×V map, writing results to a file (one float per line).Pooling mode (MAX or MEAN) is selected via NOODLE_POOL_MODE at compile time. This layer uses valid pooling. NO PADDING IS APPLIED!

Parameters
inputInput V×V map (float).
WV (input width/height).
KPool kernel size (M).
SPool stride (T).
fnOutput filename template (receives O where applicable).
Returns
V_out = (V - K)/S + 1.

◆ noodle_do_pooling() [2/3]

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

◆ 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 
)

◆ noodle_do_pooling1d() [1/2]

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

1D MAX pooling (file output). Writes V_out values (one per line) to fn.

Parameters
inputInput length-V vector (float).
WV (input length).
KPool kernel size.
SPool stride.
fnOutput filename (per-O when called in loops).
Returns
V_out = (V - K)/S + 1.

◆ noodle_do_pooling1d() [2/2]

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

◆ noodle_get_padded_x() [1/2]

float noodle_get_padded_x ( byte grid,
int16_t  i,
int16_t  j,
int16_t  W,
int16_t  P 
)

Get padded input sample from a byte grid with zero padding.Noodle uses symmetric, stride-independent padding for all convolutions.

Parameters
gridInput W bytes.
i,jPadded coordinates in [0, W+2P).
W,PSee common semantics.
Returns
Grid value as float, or 0 outside bounds.

◆ noodle_get_padded_x() [2/2]

float noodle_get_padded_x ( float *  grid,
int16_t  i,
int16_t  j,
int16_t  W,
int16_t  P 
)

Get padded input sample from a float grid with zero padding.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ noodle_grid_from_file()

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

Read an K × K grid (stored as float) from an opened file handler fi into buffer.

◆ noodle_grid_to_file() [1/2]

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

Write an n byte grid to fo (opened file handler) as bytes, row-major. No file open and close operations.

◆ noodle_grid_to_file() [2/2]

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

Write an n float grid to fo (an opened file handler), row-major.

◆ noodle_read_byte()

byte noodle_read_byte ( NDL_File &  f)

Read a byte value fron an opened file handler and store as an integer text line.

◆ noodle_read_float()

float noodle_read_float ( NDL_File &  f)

Read a float up to the next newline.

◆ noodle_reset_buffer()

void noodle_reset_buffer ( float *  buffer,
uint16_t  n 
)

Fill buffer with zeros (n floats).

◆ noodle_slice()

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

Slice a stacked [Z, W, W] tensor laid out as contiguous planes.

Parameters
flatPointer to base of the contiguous array.
WWidth/height of each 2D plane.
zPlane index to slice.
Returns
Pointer to the start of plane z (no bounds checks).

◆ noodle_unpack_bn_params()

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

Unpack batch normalization parameters from a flat array.

Parameters
bn_paramsPointer to the packed batch normalization parameters.
CNumber of channels.
gammaOutput pointer to the per-channel scale parameters.
betaOutput pointer to the per-channel shift parameters.
meanOutput pointer to the per-channel mean parameters.
varOutput pointer to the per-channel variance parameters.

◆ noodle_write_byte()

void noodle_write_byte ( NDL_File &  f,
byte  d 
)

Write a byte value as an integer text line to an opend file.

◆ noodle_write_float()

void noodle_write_float ( NDL_File &  f,
float  d 
)

Write a float followed by a newline (human-readable).