oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
infer.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 Kamil Lulko <kamil.lulko@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 *
6 * This file is part of oveRTOS.
7 */
8
31#ifndef OVE_INFER_H
32#define OVE_INFER_H
33
34#include "ove/types.h"
35#include "ove_config.h"
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41#include "ove/storage.h"
42
50 OVE_TENSOR_FLOAT32 = 0,
51 OVE_TENSOR_INT8 = 1,
52 OVE_TENSOR_UINT8 = 2,
53 OVE_TENSOR_INT16 = 3,
54 OVE_TENSOR_INT32 = 4,
55};
56
65 void *data;
66 size_t size;
68 unsigned int ndims;
69 int dims[5];
70};
71
89 const void *model_data;
90 size_t model_size;
91 size_t arena_size;
92};
93
94#ifdef CONFIG_OVE_INFER
95
112int ove_model_init(ove_model_t *model, ove_model_storage_t *storage, void *arena,
113 const struct ove_model_config *cfg);
114
125
126/* _create / _destroy — heap-gated */
127#ifdef OVE_HEAP_INFER
128
142int ove_model_create(ove_model_t *model, const struct ove_model_config *cfg);
143
152
153#endif /* OVE_HEAP_INFER */
154
167
182int ove_model_input(ove_model_t model, unsigned int index, struct ove_tensor_info *info);
183
198int ove_model_output(ove_model_t model, unsigned int index, struct ove_tensor_info *info);
199
210
211#else /* !CONFIG_OVE_INFER */
212
214/* No _init/_deinit stubs here: OVE_MODEL_DEFINE_STATIC is itself gated by
215 * #ifdef CONFIG_OVE_INFER in storage.h, so callers can't reach _init when
216 * the subsystem is off — and ove_model_storage_t isn't declared either. */
217static inline int ove_model_create(ove_model_t *m, const struct ove_model_config *c)
218{
219 (void)m;
220 (void)c;
222}
223static inline void ove_model_destroy(ove_model_t m)
224{
225 (void)m;
226}
227static inline int ove_model_invoke(ove_model_t m)
228{
229 (void)m;
231}
232static inline int ove_model_input(ove_model_t m, unsigned int i, struct ove_tensor_info *t)
233{
234 (void)m;
235 (void)i;
236 (void)t;
238}
239static inline int ove_model_output(ove_model_t m, unsigned int i, struct ove_tensor_info *t)
240{
241 (void)m;
242 (void)i;
243 (void)t;
245}
246static inline uint64_t ove_model_last_inference_us(ove_model_t m)
247{
248 (void)m;
249 return 0;
250}
253#endif /* CONFIG_OVE_INFER */
254
255#ifdef __cplusplus
256}
257#endif
258
259#endif /* OVE_INFER_H */
260
int ove_model_invoke(ove_model_t model)
Run inference on the currently populated input tensor(s).
ove_tensor_type
Tensor element types.
Definition infer.h:49
void ove_model_deinit(ove_model_t model)
Release resources held by a model initialised with ove_model_init().
int ove_model_output(ove_model_t model, unsigned int index, struct ove_tensor_info *info)
Get a descriptor for an output tensor.
int ove_model_input(ove_model_t model, unsigned int index, struct ove_tensor_info *info)
Get a descriptor for an input tensor.
uint64_t ove_model_last_inference_us(ove_model_t model)
Return inference time of the last ove_model_invoke() in microseconds.
int ove_model_init(ove_model_t *model, ove_model_storage_t *storage, void *arena, const struct ove_model_config *cfg)
Initialise a model using caller-supplied storage and arena.
void ove_model_destroy(ove_model_t model)
Destroy and free a model allocated with ove_model_create().
int ove_model_create(ove_model_t *model, const struct ove_model_config *cfg)
Allocate and initialise a model from the heap.
struct ove_model * ove_model_t
Opaque handle for an ML inference model session.
Definition types.h:244
@ OVE_ERR_NOT_SUPPORTED
Definition types.h:98
Configuration for an ML inference session.
Definition infer.h:88
size_t model_size
Definition infer.h:90
const void * model_data
Definition infer.h:89
size_t arena_size
Definition infer.h:91
Tensor descriptor returned by ove_model_input() / ove_model_output().
Definition infer.h:64
unsigned int ndims
Definition infer.h:68
void * data
Definition infer.h:65
int dims[5]
Definition infer.h:69
size_t size
Definition infer.h:66
enum ove_tensor_type type
Definition infer.h:67