SSCMA-Micro CPP SDK  v2.0.0
SSCMA-Micro is a cross-platform machine learning inference framework designed for embedded devices.
ma_model_base.h
Go to the documentation of this file.
1 #ifndef _MA_MODEL_BASE_H_
2 #define _MA_MODEL_BASE_H_
3 
4 #include <cstdarg>
5 #include <functional>
6 #include <string>
7 
8 #include "../engine/ma_engine.h"
9 #include "../ma_common.h"
10 
11 namespace ma {
12 
13 using namespace ma::engine;
14 class Model {
15 private:
16  ma_perf_t perf_;
17  std::function<void(void*)> p_preprocess_done_;
18  std::function<void(void*)> p_postprocess_done_;
19  std::function<void(void*)> p_underlying_run_done_;
20  void* p_user_ctx_;
21  uint16_t m_type_;
22 
23 protected:
25  const char* p_name_;
26  virtual ma_err_t preprocess() = 0;
27  virtual ma_err_t postprocess() = 0;
28  ma_err_t underlyingRun();
29 
30 public:
31  Model(Engine* engine, const char* name, uint16_t type);
32  virtual ~Model();
33  const ma_perf_t getPerf() const;
34  const char* getName() const;
35  ma_model_type_t getType() const;
36  ma_input_type_t getInputType() const;
37  ma_output_type_t getOutputType() const;
38  virtual const void* getInput() = 0;
39  virtual ma_err_t setConfig(ma_model_cfg_opt_t opt, ...) = 0;
40  virtual ma_err_t getConfig(ma_model_cfg_opt_t opt, ...) = 0;
41  void setPreprocessDone(std::function<void(void*)> func);
42  void setPostprocessDone(std::function<void(void*)> func);
43  void setRunDone(std::function<void(void*)> func);
44  void setUserCtx(void* ctx);
45 };
46 } // namespace ma
47 
48 #endif /* _MA_ALGO_H_ */
Definition: ma_model_base.h:14
Engine * p_engine_
Definition: ma_model_base.h:24
virtual ma_err_t preprocess()=0
virtual ma_err_t postprocess()=0
const char * p_name_
Definition: ma_model_base.h:25
virtual ma_err_t setConfig(ma_model_cfg_opt_t opt,...)=0
virtual ma_err_t getConfig(ma_model_cfg_opt_t opt,...)=0
virtual const void * getInput()=0
Definition: ma_engine_base.h:17
ma_model_type_t
Definition: ma_types.h:274
ma_err_t
Definition: ma_types.h:21
ma_model_cfg_opt_t
Definition: ma_types.h:229
ma_output_type_t
Definition: ma_types.h:264
ma_input_type_t
Definition: ma_types.h:258
Definition: ma_engine_base.h:15
Definition: ma_cv.cpp:7
Definition: ma_types.h:138