Developer World
Spresense SDK Library v3.3.0-375c679
runtime.h
Go to the documentation of this file.
1/****************************************************************************
2 * modules/include/tflmrt/runtime.h
3 *
4 * Copyright 2021 Sony Semiconductor Solutions Corporation
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 * 3. Neither the name of Sony Semiconductor Solutions Corporation nor
17 * the names of its contributors may be used to endorse or promote
18 * products derived from this software without specific prior written
19 * permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *
34 ****************************************************************************/
35
40#ifndef __MODULES_INCLUDE_TFLMRT_RUNTIME_H
41#define __MODULES_INCLUDE_TFLMRT_RUNTIME_H
42
43#ifdef __cplusplus
44extern "C" {
45#endif /* __cplusplus */
46
47/****************************************************************************
48 * Pre-processor Definitions
49 ****************************************************************************/
50
51#define TF_LITE_STATIC_MEMORY
52
53/****************************************************************************
54 * Included Files
55 ****************************************************************************/
56
57#include <asmp/types.h>
58
59#include "tensorflow/lite/c/common.h"
60#include "tensorflow/lite/micro/spresense/debug_log_callback.h"
61
62/****************************************************************************
63 * Public Types
64 ****************************************************************************/
65
71typedef struct tflm_runtime
72{
73 void *impl_ctx;
75
81typedef struct tflm_config
82{
83 unsigned char cpu_num;
85
91typedef struct tflm_mallinfo
92{
93 cpuid_t cpu;
94 size_t total_bytes;
95 size_t used_bytes;
96 size_t largest_bytes;
98
99/****************************************************************************
100 * Public Function Prototypes
101 ****************************************************************************/
102
118
130
148 const void *network,
149 int size);
150
162
179int tflm_runtime_forward(tflm_runtime_t *rt, const void *inputs[],
180 unsigned char input_num);
181
191
201
212int tflm_runtime_input_size(tflm_runtime_t *rt, unsigned char input_index);
213
224int tflm_runtime_input_ndim(tflm_runtime_t *rt, unsigned char input_index);
225
237int tflm_runtime_input_shape(tflm_runtime_t *rt, unsigned char input_index,
238 unsigned char dim_index);
239
251 unsigned char input_index);
252
262
273int tflm_runtime_output_size(tflm_runtime_t *rt, unsigned char output_index);
274
285int tflm_runtime_output_ndim(tflm_runtime_t *rt, unsigned char output_index);
286
298int tflm_runtime_output_shape(tflm_runtime_t *rt, unsigned char output_index,
299 unsigned char dim_index);
300
312 unsigned char output_index);
313
330 unsigned char output_index);
331
341
352int tflm_asmp_mallinfo(unsigned char array_length,
353 tflm_mallinfo_t *info_array);
354
355#ifdef __cplusplus
356}
357#endif /* __cplusplus */
358
359#endif /* __MODULES_INCLUDE_TFLMRT_RUNTIME_H */
int16_t cpuid_t
Definition: types.h:64
Definition: runtime.h:82
unsigned char cpu_num
Definition: runtime.h:83
Definition: runtime.h:92
Definition: runtime.h:72
int tflm_runtime_output_size(tflm_runtime_t *rt, unsigned char output_index)
TfLiteTensor * tflm_runtime_output_variable(tflm_runtime_t *rt, unsigned char output_index)
int tflm_initialize(tflm_config_t *config)
int tflm_runtime_output_num(tflm_runtime_t *rt)
int tflm_runtime_input_size(tflm_runtime_t *rt, unsigned char input_index)
int tflm_runtime_initialize(tflm_runtime_t *rt, const void *network, int size)
int tflm_nuttx_mallinfo(tflm_mallinfo_t *info)
struct tflm_mallinfo tflm_mallinfo_t
int tflm_runtime_input_num(tflm_runtime_t *rt)
TfLiteTensor * tflm_runtime_input_variable(tflm_runtime_t *rt, unsigned char input_index)
int tflm_runtime_forward(tflm_runtime_t *rt, const void *inputs[], unsigned char input_num)
int tflm_runtime_input_shape(tflm_runtime_t *rt, unsigned char input_index, unsigned char dim_index)
int tflm_runtime_output_shape(tflm_runtime_t *rt, unsigned char output_index, unsigned char dim_index)
void * tflm_runtime_output_buffer(tflm_runtime_t *rt, unsigned char output_index)
int tflm_finalize(void)
int tflm_runtime_output_ndim(tflm_runtime_t *rt, unsigned char output_index)
struct tflm_config tflm_config_t
int tflm_asmp_mallinfo(unsigned char array_length, tflm_mallinfo_t *info_array)
int tflm_runtime_actual_arenasize(tflm_runtime_t *rt)
int tflm_runtime_finalize(tflm_runtime_t *rt)
int tflm_runtime_input_ndim(tflm_runtime_t *rt, unsigned char input_index)