#include <asmp/types.h>
#include "tensorflow/lite/c/common.h"
#include "tensorflow/lite/micro/spresense/debug_log_callback.h"
Go to the source code of this file.
|
int | tflm_initialize (tflm_config_t *config) |
|
int | tflm_finalize (void) |
|
int | tflm_runtime_initialize (tflm_runtime_t *rt, const void *network, int size) |
|
int | tflm_runtime_finalize (tflm_runtime_t *rt) |
|
int | tflm_runtime_forward (tflm_runtime_t *rt, const void *inputs[], unsigned char input_num) |
|
int | tflm_runtime_actual_arenasize (tflm_runtime_t *rt) |
|
int | tflm_runtime_input_num (tflm_runtime_t *rt) |
|
int | tflm_runtime_input_size (tflm_runtime_t *rt, unsigned char input_index) |
|
int | tflm_runtime_input_ndim (tflm_runtime_t *rt, unsigned char input_index) |
|
int | tflm_runtime_input_shape (tflm_runtime_t *rt, unsigned char input_index, unsigned char dim_index) |
|
TfLiteTensor * | tflm_runtime_input_variable (tflm_runtime_t *rt, unsigned char input_index) |
|
int | tflm_runtime_output_num (tflm_runtime_t *rt) |
|
int | tflm_runtime_output_size (tflm_runtime_t *rt, unsigned char output_index) |
|
int | tflm_runtime_output_ndim (tflm_runtime_t *rt, unsigned char output_index) |
|
int | tflm_runtime_output_shape (tflm_runtime_t *rt, unsigned char output_index, unsigned char dim_index) |
|
TfLiteTensor * | tflm_runtime_output_variable (tflm_runtime_t *rt, unsigned char output_index) |
|
void * | tflm_runtime_output_buffer (tflm_runtime_t *rt, unsigned char output_index) |
|
int | tflm_nuttx_mallinfo (tflm_mallinfo_t *info) |
|
int | tflm_asmp_mallinfo (unsigned char array_length, tflm_mallinfo_t *info_array) |
|
◆ tflm_config_t
structure to hold tflmrt runtime information
structure to configure tflmrt subsystem
◆ tflm_mallinfo_t
structure to obtain memory allocation information
◆ tflm_initialize()
Initialize the whole tflmrt subsystem
- Parameters
-
- Returns
- 0 on success, otherwise returns error code in errno_t.
- Note
- this function must be called before any tflm_runtime_t object is initialized.
◆ tflm_finalize()
int tflm_finalize |
( |
void |
| ) |
|
Finalize the whole tflmrt subsystem. This function frees all the resources allocated through tflm_initialize().
- Returns
- 0 on success, otherwise returns error code in errno_t.
- Note
- this function must be called after all the tflm_runtime_t is finalized
◆ tflm_runtime_initialize()
int tflm_runtime_initialize |
( |
tflm_runtime_t * |
rt, |
|
|
const void * |
network, |
|
|
int |
size |
|
) |
| |
Instantiate a neural network as a tflm_runtime_t object.
- Parameters
-
[in,out] | rt | tflmrt_runtime_t object |
[in] | network | pointer to a memory into which network is loaded |
[in] | size | tensor arena size |
- Returns
- 0 on success, otherwise returns error code in errno_t.
- Note
- This function binds tflm_runtime_t and network,
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 tflm_runtime_finalize().
◆ tflm_runtime_finalize()
Free all the memory allocated to a tflm_runtime_t object
- Parameters
-
[in,out] | rt | tflmrt_runtime_t object |
- Returns
- 0 on success, otherwise returns error code in errno_t.
- Note
- tflmrt are NOT involved in freeing nn_network_t.
◆ tflm_runtime_forward()
int tflm_runtime_forward |
( |
tflm_runtime_t * |
rt, |
|
|
const void * |
inputs[], |
|
|
unsigned char |
input_num |
|
) |
| |
Execute forward propagation after feeding input data.
- Parameters
-
[in,out] | rt | tflmrt_runtime_t object |
[in] | inputs | an array of pointers to input buffers |
[in] | input_num | length of inputs |
- Returns
- 0 on success, otherwise returns error code in errno_t.
- Note
- feed input data taking the following points into account:
- input_num equals to tflm_runtime_input_num()
- length of each input buffer(i.e. inputs[i]) equals to tflm_runtime_input_size(rt, i)
- internal representation of each input buffer(i.e. inputs[i]) can be obtained by tflm_runtime_input_variable(rt, i)
◆ tflm_runtime_actual_arenasize()
Return the size of tensorflow arena size.
- Parameters
-
[in,out] | rt | tflmrt_runtime_t object |
- Returns
- byes of actual arena memory size, otherwise -EINVAL.
◆ tflm_runtime_input_num()
Return the number of inputs which this network needs.
- Parameters
-
[in,out] | rt | tflmrt_runtime_t object |
- Returns
- number of inputs on success, otherwise -EINVAL.
◆ tflm_runtime_input_size()
int tflm_runtime_input_size |
( |
tflm_runtime_t * |
rt, |
|
|
unsigned char |
input_index |
|
) |
| |
Return the number of elements in a specified input.
- Parameters
-
[in,out] | rt | tflmrt_runtime_t object |
[in] | input_index | index to specify an input |
- Returns
- number of elements in the specified input on success, otherwise -EINVAL.
◆ tflm_runtime_input_ndim()
int tflm_runtime_input_ndim |
( |
tflm_runtime_t * |
rt, |
|
|
unsigned char |
input_index |
|
) |
| |
Return the number of a specified input's dimensions.
- Parameters
-
[in,out] | rt | tflmrt_runtime_t object |
[in] | input_index | index to specify an input |
- Returns
- number of the specified input's dimensions on success, otherwise -EINVAL.
◆ tflm_runtime_input_shape()
int tflm_runtime_input_shape |
( |
tflm_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] | rt | tflmrt_runtime_t object |
[in] | input_index | index to specify an input |
[in] | dim_index | index to specify a dimension |
- Returns
- number of elements in the specified dimension of the input on success, otherwise -EINVAL.
◆ tflm_runtime_input_variable()
TfLiteTensor * tflm_runtime_input_variable |
( |
tflm_runtime_t * |
rt, |
|
|
unsigned char |
input_index |
|
) |
| |
Get TfLiteTensor* corresponding to a specified input
- Parameters
-
[in,out] | rt | tflmrt_runtime_t object |
[in] | input_index | index to specify an input |
- Returns
- pointer to TfLiteTensor on success, otherwise NULL
◆ tflm_runtime_output_num()
Return the number of outputs which this network emits.
- Parameters
-
[in,out] | rt | tflmrt_runtime_t object |
- Returns
- number of outputs on success, otherwise -EINVAL.
◆ tflm_runtime_output_size()
int tflm_runtime_output_size |
( |
tflm_runtime_t * |
rt, |
|
|
unsigned char |
output_index |
|
) |
| |
Return the number of elements in a specified output.
- Parameters
-
[in,out] | rt | tflmrt_runtime_t object |
[in] | output_index | index to specify an output |
- Returns
- number of elements in the specified output on success, otherwise -EINVAL.
◆ tflm_runtime_output_ndim()
int tflm_runtime_output_ndim |
( |
tflm_runtime_t * |
rt, |
|
|
unsigned char |
output_index |
|
) |
| |
Return the number of a specified output's dimensions.
- Parameters
-
[in,out] | rt | tflmrt_runtime_t object |
[in] | output_index | index to specify an input |
- Returns
- number of the specified input's dimensions on success, otherwise -EINVAL.
◆ tflm_runtime_output_shape()
int tflm_runtime_output_shape |
( |
tflm_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] | rt | tflmrt_runtime_t object |
[in] | output_index | index to specify an output |
[in] | dim_index | index to specify a dimension |
- Returns
- number of elements in the specified dimension of the output on success, otherwise -EINVAL.
◆ tflm_runtime_output_variable()
TfLiteTensor * tflm_runtime_output_variable |
( |
tflm_runtime_t * |
rt, |
|
|
unsigned char |
output_index |
|
) |
| |
Get TfLiteTensor* corresponding to a specified output
- Parameters
-
[in,out] | rt | tflmrt_runtime_t object |
[in] | output_index | index to specify an output |
- Returns
- pointer to TfLiteTensor on success, otherwise NULL
◆ tflm_runtime_output_buffer()
void * tflm_runtime_output_buffer |
( |
tflm_runtime_t * |
rt, |
|
|
unsigned char |
output_index |
|
) |
| |
Return a pointer to a specified output
- Parameters
-
[in,out] | rt | tflmrt_runtime_t object |
[in] | output_index | index 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 tflm_runtime_output_num(rt)
- length of the output buffer equals to tflm_runtime_output_size(rt, output_index)
- internal representation of the output buffer can be obtained by tflm_runtime_output_variable(rt, output_index)
◆ tflm_nuttx_mallinfo()
Obtain information about memory allocation in the Nuttx-side heap
- Parameters
-
[out] | info | pointer to store memory allocation stats |
- Returns
- 0 on success. otherwise -EINVAL.
◆ tflm_asmp_mallinfo()
int tflm_asmp_mallinfo |
( |
unsigned char |
array_length, |
|
|
tflm_mallinfo_t * |
info_array |
|
) |
| |
Obtain information about memory allocation in the ASMP-side heap
- Parameters
-
[in] | array_length | Number of elements in info_array.
This value must be tflm_config_t::cpu_num |
[out] | info_array | Array to store memory allocation stats |
- Returns
- 0 on success. -EPERM if CONFIG_TFLM_RT_MPCOMM=n