Developer World
Spresense SDK Library v1.4.2-3df2e9d
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 <asmp/types.h>
50 # include <dnnrt/nnablart/network.h>
51 
52 # ifdef __cplusplus
53 # define EXTERN extern "C"
54 extern "C"
55 {
56 # else
57 # define EXTERN extern
58 # endif
59 
60 # define DNNRT_IMPLEMENT (0)
61 
66 typedef struct dnn_runtime
67 {
68  void *impl_ctx;
70 
75 typedef struct dnn_config
76 {
77 
78  unsigned char cpu_num;
79 } dnn_config_t;
80 
85 typedef struct dnn_mallinfo
86 {
87  cpuid_t cpu;
88  size_t total_bytes;
89  size_t used_bytes;
90  size_t largest_bytes;
92 
95 /********************************************************************************
96  * Public Function Prototypes
97  ********************************************************************************/
98 
115 int dnn_initialize(dnn_config_t * config);
116 
125 int dnn_finalize(void);
126 
140 int dnn_runtime_initialize(dnn_runtime_t * rt, const nn_network_t * network);
141 
152 
166 int dnn_runtime_forward(dnn_runtime_t * rt, const void *inputs[],
167  unsigned char input_num);
168 
177 
186 int dnn_runtime_input_size(dnn_runtime_t * rt, unsigned char input_index);
187 
197 int dnn_runtime_input_ndim(dnn_runtime_t * rt, unsigned char input_index);
198 
209 int dnn_runtime_input_shape(dnn_runtime_t * rt, unsigned char input_index,
210  unsigned char dim_index);
211 
221 nn_variable_t *dnn_runtime_input_variable(dnn_runtime_t * rt,
222  unsigned char input_index);
223 
232 
241 int dnn_runtime_output_size(dnn_runtime_t * rt, unsigned char output_index);
242 
252 int dnn_runtime_output_ndim(dnn_runtime_t * rt, unsigned char output_index);
253 
264 int dnn_runtime_output_shape(dnn_runtime_t * rt, unsigned char output_index,
265  unsigned char dim_index);
266 
276 nn_variable_t *dnn_runtime_output_variable(dnn_runtime_t * rt,
277  unsigned char output_index);
278 
292 void *dnn_runtime_output_buffer(dnn_runtime_t * rt, unsigned char output_index);
293 
302 
312 int dnn_asmp_mallinfo(unsigned char array_length, dnn_mallinfo_t * info_array);
313 
316 # undef EXTERN
317 # ifdef __cplusplus
318 }
319 # endif
320 
323 #endif /* __INCLUDE_DNNRT_RUNTIME_H */
int dnn_initialize(dnn_config_t *config)
int dnn_runtime_input_size(dnn_runtime_t *rt, unsigned char input_index)
struct dnn_config dnn_config_t
int dnn_runtime_input_num(dnn_runtime_t *rt)
int dnn_runtime_finalize(dnn_runtime_t *rt)
int16_t cpuid_t
Definition: types.h:64
unsigned char cpu_num
Definition: runtime.h:78
nn_variable_t * dnn_runtime_output_variable(dnn_runtime_t *rt, unsigned char output_index)
int dnn_asmp_mallinfo(unsigned char array_length, dnn_mallinfo_t *info_array)
int dnn_runtime_input_ndim(dnn_runtime_t *rt, unsigned char input_index)
struct dnn_mallinfo dnn_mallinfo_t
int dnn_nuttx_mallinfo(dnn_mallinfo_t *info)
int dnn_runtime_output_shape(dnn_runtime_t *rt, unsigned char output_index, unsigned char dim_index)
int dnn_runtime_output_ndim(dnn_runtime_t *rt, unsigned char output_index)
int dnn_runtime_forward(dnn_runtime_t *rt, const void *inputs[], unsigned char input_num)
int dnn_finalize(void)
nn_variable_t * dnn_runtime_input_variable(dnn_runtime_t *rt, unsigned char input_index)
Definition: runtime.h:75
int dnn_runtime_input_shape(dnn_runtime_t *rt, unsigned char input_index, unsigned char dim_index)
Definition: runtime.h:66
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:85
int dnn_runtime_initialize(dnn_runtime_t *rt, const nn_network_t *network)
int dnn_runtime_output_size(dnn_runtime_t *rt, unsigned char output_index)