Developer World
Spresense SDK Library v3.2.0-ebc0364
Functions
Collaboration diagram for Functions:

Functions

int dnn_initialize (dnn_config_t *config)
 
int dnn_finalize (void)
 
int dnn_runtime_initialize (dnn_runtime_t *rt, const nn_network_t *network)
 
int dnn_runtime_finalize (dnn_runtime_t *rt)
 
int dnn_runtime_forward (dnn_runtime_t *rt, const void *inputs[], unsigned char input_num)
 
int dnn_runtime_input_num (dnn_runtime_t *rt)
 
int dnn_runtime_input_size (dnn_runtime_t *rt, unsigned char input_index)
 
int dnn_runtime_input_ndim (dnn_runtime_t *rt, unsigned char input_index)
 
int dnn_runtime_input_shape (dnn_runtime_t *rt, unsigned char input_index, unsigned char dim_index)
 
nn_variable_t * dnn_runtime_input_variable (dnn_runtime_t *rt, unsigned char input_index)
 
int dnn_runtime_output_num (dnn_runtime_t *rt)
 
int dnn_runtime_output_size (dnn_runtime_t *rt, unsigned char output_index)
 
int dnn_runtime_output_ndim (dnn_runtime_t *rt, unsigned char output_index)
 
int dnn_runtime_output_shape (dnn_runtime_t *rt, unsigned char output_index, unsigned char dim_index)
 
nn_variable_t * dnn_runtime_output_variable (dnn_runtime_t *rt, unsigned char output_index)
 
void * dnn_runtime_output_buffer (dnn_runtime_t *rt, unsigned char output_index)
 
int dnn_nuttx_mallinfo (dnn_mallinfo_t *info)
 
int dnn_asmp_mallinfo (unsigned char array_length, dnn_mallinfo_t *info_array)
 

Detailed Description

Function Documentation

◆ dnn_initialize()

int dnn_initialize ( dnn_config_t config)

Initialize the whole dnnrt subsystem

Parameters
[in]configconfiguration of multicore processing.
If CONFIG_DNN_RT_MP=y, dnn_config_t::cpu_num must be 1 or more,
otherwise dnn_config_t::cpu_num must be 1.
Returns
0 on success, otherwise returns error code in errno_t.
Note
this function must be called before any dnn_runtime_t object is initialized.

◆ dnn_finalize()

int dnn_finalize ( void  )

Finalize the whole dnnrt subsystem. This function frees all the resources allocated through dnn_initialize().

Returns
0 on success, otherwise returns error code in errno_t.
Note
this function must be called after all the dnn_runtime_t is finalized

◆ dnn_runtime_initialize()

int dnn_runtime_initialize ( dnn_runtime_t rt,
const nn_network_t *  network 
)

Instantiate a neural network defined by nn_network_t as a dnn_runtime_t object.

Parameters
[in,out]rtdnnrt_runtime_t object
[in]networkpointer to a memory into which .nnb file is loaded
Returns
0 on success, otherwise returns error code in rt_return_value_t or errno_t.
Note
This function binds dnn_runtime_t and nn_network_t,
so applications don't have to give the network object to the other functions except this.
However, the runtime holds reference to the network object.
Applications must NOT free it until dnn_runtime_finalize().

◆ dnn_runtime_finalize()

int dnn_runtime_finalize ( dnn_runtime_t rt)

Free all the memory allocated to a dnn_runtime_t object

Parameters
[in,out]rtdnnrt_runtime_t object
Returns
0 on success, otherwise returns error code in rt_return_value_t or errno_t.
Note
dnnrt are NOT involved in freeing nn_network_t.

◆ dnn_runtime_forward()

int dnn_runtime_forward ( dnn_runtime_t rt,
const void *  inputs[],
unsigned char  input_num 
)

Execute forward propagation after feeding input data.

Parameters
[in,out]rtdnnrt_runtime_t object
[in]inputsan array of pointers to input buffers
[in]input_numlength of inputs
Returns
0 on success, otherwise returns error code in rt_return_value_t or errno_t.
Note
feed input data taking the following points into account:
  • input_num equals to dnn_runtime_input_num()
  • length of each input buffer(i.e. inputs[i]) equals to dnn_runtime_input_size(rt, i)
  • internal representation of each input buffer(i.e. inputs[i]) can be obtained by dnn_runtime_input_variable(rt, i)

◆ dnn_runtime_input_num()

int dnn_runtime_input_num ( dnn_runtime_t rt)

Return the number of inputs which this network needs.

Parameters
[in,out]rtdnnrt_runtime_t object
Returns
number of inputs on success, otherwise -EINVAL.

◆ dnn_runtime_input_size()

int dnn_runtime_input_size ( dnn_runtime_t rt,
unsigned char  input_index 
)

Return the number of elements in a specified input.

Parameters
[in,out]rtdnnrt_runtime_t object
[in]input_indexindex to specify an input
Returns
number of elements in the specified input on success, otherwise -EINVAL.

◆ dnn_runtime_input_ndim()

int dnn_runtime_input_ndim ( dnn_runtime_t rt,
unsigned char  input_index 
)

Return the number of a specified input's dimensions.

Parameters
[in,out]rtdnnrt_runtime_t object
[in]input_indexindex to specify an input
Returns
number of the specified input's dimensions on success, otherwise -EINVAL.

◆ dnn_runtime_input_shape()

int dnn_runtime_input_shape ( dnn_runtime_t rt,
unsigned char  input_index,
unsigned char  dim_index 
)

Return the number of elements in a specified dimension of an input.

Parameters
[in,out]rtdnnrt_runtime_t object
[in]input_indexindex to specify an input
[in]dim_indexindex to specify a dimension
Returns
number of elements in the specified dimension of the input on success, otherwise -EINVAL.

◆ dnn_runtime_input_variable()

nn_variable_t * dnn_runtime_input_variable ( dnn_runtime_t rt,
unsigned char  input_index 
)

Get nn_variable_t* corresponding to a specified input

Parameters
[in,out]rtdnnrt_runtime_t object
[in]input_indexindex to specify an input
Returns
pointer to nn_variable_t in nn_network_t on success, otherwise NULL

◆ dnn_runtime_output_num()

int dnn_runtime_output_num ( dnn_runtime_t rt)

Return the number of outputs which this network emits.

Parameters
[in,out]rtdnnrt_runtime_t object
Returns
number of outputs on success, otherwise -EINVAL.

◆ dnn_runtime_output_size()

int dnn_runtime_output_size ( dnn_runtime_t rt,
unsigned char  output_index 
)

Return the number of elements in a specified output.

Parameters
[in,out]rtdnnrt_runtime_t object
[in]output_indexindex to specify an output
Returns
number of elements in the specified output on success, otherwise -EINVAL.

◆ dnn_runtime_output_ndim()

int dnn_runtime_output_ndim ( dnn_runtime_t rt,
unsigned char  output_index 
)

Return the number of a specified output's dimensions.

Parameters
[in,out]rtdnnrt_runtime_t object
[in]output_indexindex to specify an input
Returns
number of the specified input's dimensions on success, otherwise -EINVAL.

◆ dnn_runtime_output_shape()

int dnn_runtime_output_shape ( dnn_runtime_t rt,
unsigned char  output_index,
unsigned char  dim_index 
)

Return the number of elements in a specified dimension of an output.

Parameters
[in,out]rtdnnrt_runtime_t object
[in]output_indexindex to specify an output
[in]dim_indexindex to specify a dimension
Returns
number of elements in the specified dimension of the output on success, otherwise -EINVAL.

◆ dnn_runtime_output_variable()

nn_variable_t * dnn_runtime_output_variable ( dnn_runtime_t rt,
unsigned char  output_index 
)

Get nn_variable_t* corresponding to a specified output

Parameters
[in,out]rtdnnrt_runtime_t object
[in]output_indexindex to specify an output
Returns
pointer to nn_variable_t in nn_network_t on success, otherwise NULL

◆ dnn_runtime_output_buffer()

void * dnn_runtime_output_buffer ( dnn_runtime_t rt,
unsigned char  output_index 
)

Return a pointer to a specified output

Parameters
[in,out]rtdnnrt_runtime_t object
[in]output_indexindex to specify an output
Returns
pointer to corresponding the output buffer if output_index is valid, otherwise NULL.
Note
read output data taking the following points into account:
  • output_index must be less than dnn_runtime_output_num(rt)
  • length of the output buffer equals to dnn_runtime_output_size(rt, output_index)
  • internal representation of the output buffer can be obtained by dnn_runtime_output_variable(rt, output_index)

◆ dnn_nuttx_mallinfo()

int dnn_nuttx_mallinfo ( dnn_mallinfo_t info)

Obtain information about memory allocation in the Nuttx-side heap

Parameters
[out]infopointer to store memory allocation stats
Returns
0 on success. otherwise -EINVAL.

◆ dnn_asmp_mallinfo()

int dnn_asmp_mallinfo ( unsigned char  array_length,
dnn_mallinfo_t info_array 
)

Obtain information about memory allocation in the ASMP-side heap

Parameters
[in]array_lengthNumber of elements in info_array.
This value must be dnn_config_t::cpu_num
[out]info_arrayArray to store memory allocation stats
Returns
0 on success. -EPERM if CONFIG_DNN_RT_MP=n