12#include <ove/storage.h>
14#ifdef CONFIG_OVE_INFER
29template <
size_t ArenaSize = 0>
38 explicit Model(
const struct ove_model_config &cfg) {
39#ifdef CONFIG_OVE_ZERO_HEAP
40 int err = ove_model_init(&handle_, &storage_, arena_, &cfg);
42 int err = ove_model_create(&handle_, &cfg);
44 OVE_STATIC_INIT_ASSERT(err == OVE_OK);
50#ifdef CONFIG_OVE_ZERO_HEAP
51 ove_model_deinit(handle_);
53 ove_model_destroy(handle_);
57 Model(
const Model &) =
delete;
58 Model &operator=(
const Model &) =
delete;
60#ifdef CONFIG_OVE_ZERO_HEAP
61 Model(Model &&) =
delete;
62 Model &operator=(Model &&) =
delete;
64 Model(Model &&other) noexcept : handle_(other.handle_) {
65 other.handle_ =
nullptr;
67 Model &operator=(Model &&other)
noexcept {
70 ove_model_destroy(handle_);
71 handle_ = other.handle_;
72 other.handle_ =
nullptr;
79 [[nodiscard]]
int invoke() {
return ove_model_invoke(handle_); }
83 T *input_data(
unsigned int index = 0) {
84 struct ove_tensor_info info;
85 if (ove_model_input(handle_, index, &info) != OVE_OK)
87 return static_cast<T *
>(info.data);
92 const T *output_data(
unsigned int index = 0)
const {
93 struct ove_tensor_info info;
94 if (ove_model_output(handle_, index, &info) != OVE_OK)
96 return static_cast<const T *
>(info.data);
100 int input(
unsigned int index,
struct ove_tensor_info &info)
const {
101 return ove_model_input(handle_, index, &info);
105 int output(
unsigned int index,
struct ove_tensor_info &info)
const {
106 return ove_model_output(handle_, index, &info);
110 uint64_t last_inference_us()
const {
111 return ove_model_last_inference_us(handle_);
115 ove_model_t handle()
const {
return handle_; }
118 ove_model_t handle_ =
nullptr;
119#ifdef CONFIG_OVE_ZERO_HEAP
120 ove_model_storage_t storage_ = {};
121 alignas(16) uint8_t arena_[ArenaSize] = {};
Top-level namespace for all oveRTOS C++ abstractions.
Definition app.hpp:19