Developer World
Spresense SDK Library v3.2.0-ebc0364
runtime.h
Go to the documentation of this file.
1/****************************************************************************
2 * modules/include/dnnrt/runtime.h
3 *
4 * Copyright 2018 Sony 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 Corporation nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 *
33 ****************************************************************************/
34
39#ifndef __INCLUDE_DNNRT_RUNTIME_H
40# define __INCLUDE_DNNRT_RUNTIME_H
41
49# include <malloc.h>
50# include <asmp/types.h>
51# include <dnnrt/nnablart/network.h>
52
53# ifdef __cplusplus
54# define EXTERN extern "C"
55extern "C"
56{
57# else
58# define EXTERN extern
59# endif
60
61# define DNNRT_IMPLEMENT (0)
62
67typedef struct dnn_runtime
68{
69 void *impl_ctx;
71
76typedef struct dnn_config
77{
78
79 unsigned char cpu_num;
81
86typedef struct dnn_mallinfo
87{
88 cpuid_t cpu;
89 size_t total_bytes;
90 size_t used_bytes;
91 size_t largest_bytes;
93
96/********************************************************************************
97 * Public Function Prototypes
98 ********************************************************************************/
99
117
126int dnn_finalize(void);
127
141int dnn_runtime_initialize(dnn_runtime_t * rt, const nn_network_t * network);
142
153
167int dnn_runtime_forward(dnn_runtime_t * rt, const void *inputs[],
168 unsigned char input_num);
169
178
187int dnn_runtime_input_size(dnn_runtime_t * rt, unsigned char input_index);
188
198int dnn_runtime_input_ndim(dnn_runtime_t * rt, unsigned char input_index);
199
210int dnn_runtime_input_shape(dnn_runtime_t * rt, unsigned char input_index,
211 unsigned char dim_index);
212
223 unsigned char input_index);
224
233
242int dnn_runtime_output_size(dnn_runtime_t * rt, unsigned char output_index);
243
253int dnn_runtime_output_ndim(dnn_runtime_t * rt, unsigned char output_index);
254
265int dnn_runtime_output_shape(dnn_runtime_t * rt, unsigned char output_index,
266 unsigned char dim_index);
267
278 unsigned char output_index);
279
293void *dnn_runtime_output_buffer(dnn_runtime_t * rt, unsigned char output_index);
294
303
313int dnn_asmp_mallinfo(unsigned char array_length, dnn_mallinfo_t * info_array);
314
317# undef EXTERN
318# ifdef __cplusplus
319}
320# endif
321
324#endif /* __INCLUDE_DNNRT_RUNTIME_H */
int16_t cpuid_t
Definition: types.h:64
struct dnn_config dnn_config_t
struct dnn_mallinfo dnn_mallinfo_t
int dnn_runtime_input_shape(dnn_runtime_t *rt, unsigned char input_index, unsigned char dim_index)
int dnn_runtime_output_shape(dnn_runtime_t *rt, unsigned char output_index, unsigned char dim_index)
int dnn_runtime_input_num(dnn_runtime_t *rt)
int dnn_finalize(void)
int dnn_runtime_input_size(dnn_runtime_t *rt, unsigned char input_index)
nn_variable_t * dnn_runtime_input_variable(dnn_runtime_t *rt, unsigned char input_index)
int dnn_runtime_finalize(dnn_runtime_t *rt)
int dnn_asmp_mallinfo(unsigned char array_length, dnn_mallinfo_t *info_array)
nn_variable_t * dnn_runtime_output_variable(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_size(dnn_runtime_t *rt, unsigned char output_index)
int dnn_runtime_initialize(dnn_runtime_t *rt, const nn_network_t *network)
int dnn_initialize(dnn_config_t *config)
int dnn_nuttx_mallinfo(dnn_mallinfo_t *info)
int dnn_runtime_forward(dnn_runtime_t *rt, const void *inputs[], unsigned char input_num)
int dnn_runtime_input_ndim(dnn_runtime_t *rt, unsigned char input_index)
void * dnn_runtime_output_buffer(dnn_runtime_t *rt, unsigned char output_index)
int dnn_runtime_output_num(dnn_runtime_t *rt)
Definition: runtime.h:77
unsigned char cpu_num
Definition: runtime.h:79
Definition: runtime.h:87
Definition: runtime.h:68