SSCMA-Micro CPP SDK  v2.0.0
SSCMA-Micro is a cross-platform machine learning inference framework designed for embedded devices.
ma_engine_base.h
Go to the documentation of this file.
1 #ifndef _MA_ENGINE_BASE_H_
2 #define _MA_ENGINE_BASE_H_
3 
4 #include <cstdint>
5 #include <forward_list>
6 #include <vector>
7 
8 #include "../ma_common.h"
9 
10 #if MA_USE_FILESYSTEM
11 #include <fstream>
12 #include <iostream>
13 #endif
14 
15 namespace ma::engine {
16 
17 class Engine {
18 public:
19  Engine() = default;
20  virtual ~Engine() = default;
21 
22  virtual ma_err_t init() = 0;
23  virtual ma_err_t init(size_t size) = 0;
24  virtual ma_err_t init(void* pool, size_t size) = 0;
25 
26  virtual ma_err_t run() = 0;
27 
28  virtual ma_err_t load(const void* model_data, size_t model_size) = 0;
29 #if MA_USE_FILESYSTEM
30  virtual ma_err_t load(const char* model_path) = 0;
31  virtual ma_err_t load(const std::string& model_path) = 0;
32 #endif
33 
34  virtual int32_t getInputSize() = 0;
35  virtual int32_t getOutputSize() = 0;
36 
37  virtual ma_tensor_t getInput(int32_t index) = 0;
38  virtual ma_tensor_t getOutput(int32_t index) = 0;
39  virtual ma_shape_t getInputShape(int32_t index) = 0;
40  virtual ma_shape_t getOutputShape(int32_t index) = 0;
41  virtual ma_quant_param_t getInputQuantParam(int32_t index) = 0;
42  virtual ma_quant_param_t getOutputQuantParam(int32_t index) = 0;
43 
44  virtual ma_err_t setInput(int32_t index, const ma_tensor_t& tensor) = 0;
45 
46 #if MA_USE_ENGINE_TENSOR_NAME
47  virtual int32_t getInputNum(const char* name) = 0;
48  virtual int32_t getOutputNum(const char* name) = 0;
49  // virtual ma_tensor_t getInput(const char* name) = 0;
50  // virtual ma_tensor_t getOutput(const char* name) = 0;
51  // virtual ma_shape_t getInputShape(const char* name) = 0;
52  // virtual ma_shape_t getOutputShape(const char* name) = 0;
53  // virtual ma_quant_param_t getInputQuantParam(const char* name) = 0;
54  // virtual ma_quant_param_t getOutputQuantParam(const char* name) = 0;
55 #endif
56 };
57 
58 } // namespace ma::engine
59 
60 #endif
Definition: ma_engine_base.h:17
virtual int32_t getInputSize()=0
virtual ma_err_t init(size_t size)=0
virtual ma_quant_param_t getOutputQuantParam(int32_t index)=0
virtual ~Engine()=default
virtual ma_quant_param_t getInputQuantParam(int32_t index)=0
virtual ma_shape_t getInputShape(int32_t index)=0
virtual ma_shape_t getOutputShape(int32_t index)=0
virtual ma_err_t setInput(int32_t index, const ma_tensor_t &tensor)=0
virtual int32_t getOutputSize()=0
virtual ma_tensor_t getInput(int32_t index)=0
virtual ma_err_t run()=0
virtual ma_err_t init(void *pool, size_t size)=0
virtual ma_err_t load(const void *model_data, size_t model_size)=0
virtual ma_err_t init()=0
virtual ma_tensor_t getOutput(int32_t index)=0
ma_err_t
Definition: ma_types.h:21
Definition: ma_engine_base.h:15
Definition: ma_types.h:44
Definition: ma_types.h:49
Definition: ma_types.h:74