SPRAAK
|
Data Structures | |
struct | SprNN |
Typedefs | |
typedef struct SprNNStreamO_t | SprNNStreamO |
typedef struct SprNNStreamC_t | SprNNStreamC |
close an open stream More... | |
typedef struct SprNNIOEl_t | SprNNIOEl |
typedef struct SprNNI_t | SprNNI |
NN interface. More... | |
typedef void *(* | SprNNDataIn )(void *restrict layer_val, void *restrict src, int Nel) |
function point to handle the input data More... | |
typedef void *(* | SprNNDataOut )(void *restrict dst, const void *restrict layer_val, int Nel) |
function point to handle the output data More... | |
Enumerations | |
enum | { SPR_NN_EVAL, SPR_NN_TRAIN, SPR_NN_NOVECTOR, SPR_NN_NOSCALAR, SPR_NN_PARALLEL, SPR_NN_ASYNC, SPR_NN_TRAIN2, SPR_NN_NOWARN } |
Functions | |
int | spr_nn_dump (SprStream *fd, const SprNN *restrict nn) |
SprNN * | spr_nn_free (SprNN *nn) |
SprNN * | spr_nn_init (SprStream *fd, const char *fname, int flags, SprVarlist *vars) |
void * | spr_nn_data_in_memcpy (void *restrict layer_val, void *restrict src, int Nel) |
a standard implementation to handle the input data More... | |
void * | spr_nn_data_out_memcpy (void *restrict dst, const void *restrict layer_val, int Nel) |
a standard implementation to handle the output data More... | |
void * | spr_nn_data_out_null (void *restrict dst, const void *restrict layer_val, int Nel) |
ignore the output data (flush the system) More... | |
int | spr_nni_feed_input (SprNNI *restrict nni, void *restrict data, SprNNDataIn func_get) |
int | spr_nni_read_output (SprNNI *restrict nni, int block, void *restrict data, SprNNDataOut func_put) |
SprNNI * | spr_nni_free (SprNNI *restrict nni) |
SprNNI * | spr_nn_interface (SprNN *restrict nn, int flags, int MT) |
typedef struct SprNNStreamO_t SprNNStreamO |
open a file for streaming the data to the read functions or for writing back the trained parameters
typedef struct SprNNStreamC_t SprNNStreamC |
close an open stream
typedef struct SprNNIOEl_t SprNNIOEl |
connect and stream open/close elements are stored in one IO list
typedef struct SprNNI_t SprNNI |
NN interface.
typedef void*(* SprNNDataIn)(void *restrict layer_val,void *restrict src,int Nel) |
function point to handle the input data
typedef void*(* SprNNDataOut)(void *restrict dst,const void *restrict layer_val,int Nel) |
function point to handle the output data
anonymous enum |
SprNN* spr_nn_init | ( | SprStream * | fd, |
const char * | fname, | ||
int | flags, | ||
SprVarlist * | vars | ||
) |
Read a configuration from an open stream fd, or from the file with name fname (if fd equals NULL), or using spr_ssp_next_line() using fd as 'line_array' (if the bit flag SPR_NN_SSP_READ is set). The configuration defined the topology (number of layers, connections, ...) and the sources (files, ...) from which the parameters must be read. Before anything can be done with the NN, an interface has to be opened. The flags flags (and optionally some extra flags in string format) can limit the type of interfaces (vector, scalar, eval, train, ...) that can be opened, which allows more agressive fine-tuning of the parameter storage. The argument vars can be used to pass existing variables to this routine, e.g. specifying the size of the NN. Use NULL to indicate that no exiting variables are to be passed to the NN initialisation.
void* spr_nn_data_in_memcpy | ( | void *restrict | layer_val, |
void *restrict | src, | ||
int | Nel | ||
) |
a standard implementation to handle the input data
Copy Nel floating point values from src to layer_val.
layer_val | destination for the requested data (node values of some input layer) |
src | the source pointer, points to where in memory the input data can be read from |
Nel | number of elements requested |
void* spr_nn_data_out_memcpy | ( | void *restrict | dst, |
const void *restrict | layer_val, | ||
int | Nel | ||
) |
a standard implementation to handle the output data
Copy Nel floating point values from layer_val to dst.
dst | the destination pointer, points to where in memory the output data must be written to |
layer_val | the data (node values of some input layer) that must be written |
Nel | number of elements to write |
void* spr_nn_data_out_null | ( | void *restrict | dst, |
const void *restrict | layer_val, | ||
int | Nel | ||
) |
ignore the output data (flush the system)
Ignore the output data.
int spr_nni_feed_input | ( | SprNNI *restrict | nni, |
void *restrict | data, | ||
SprNNDataIn | func_get | ||
) |
Copy the input data referred to be data to the input(s) of the NN and execute the 'fwd' routine in nni if a full set of frames is collected (SPR_NN_N_PARALLEL in the case of parallel evaluation of frames, 1 frame otherwise). The function func_get known how to handle the data pointer (which may be a memory pointer, a stream, ...). If data equals NULL, any pending non full set of frames is closed and processed by the 'fwd' routine in nni.
nni | NN interface |
data | the input data (func_get known how to get the data) |
func_get | function that get/copies the input data to the input layers |
int spr_nni_read_output | ( | SprNNI *restrict | nni, |
int | block, | ||
void *restrict | data, | ||
SprNNDataOut | func_put | ||
) |
Check if output is available (block==0), and if no output is available either wait till output is available (block!=0) or until at least one input slot is available. If output is available, copy the next frame of the NN to wherever data points (memory, stream, ...) using func_put.
nni | NN interface |
block | wait till output is available |
data | where to write the output data (func_put known how to write the data) |
func_put | function that put/copies the output layer data to wherever data points |
Free the resources (memory, threads) associated with the NN interface nni.
nni | NN interface |
Make an interface toward the NN for evaluation (bit flag SPR_NN_EVAL set in <flags) and/or for training (bit flag SPR_NN_TRAIN set in flags). Configure for MT worker threads (use MT==0 for single threaded use).
Other relevant bit flags are: