SSCMA-Micro CPP SDK  v2.0.0
SSCMA-Micro is a cross-platform machine learning inference framework designed for embedded devices.
ma_engine_halio.h
Go to the documentation of this file.
1 #ifndef _MA_ENGINE_HALIO_H_
2 #define _MA_ENGINE_HALIO_H_
3 
4 #include "../ma_common.h"
5 
6 #if MA_USE_ENGINE_HALIO
7 
8 #include "ma_engine.h"
9 
10 #include <cstddef>
11 #include <cstdint>
12 #include <functional>
13 #include <memory>
14 #include <string>
15 #include <unordered_map>
16 
17 #include <hailo/hailort.hpp>
18 
19 namespace ma::engine {
20 
21 using namespace std;
22 using namespace hailort;
23 
24 class EngineHalio final : public Engine {
25 public:
26  using ExternalHandler = function<ma_err_t(int, void*, size_t)>;
27 
28  EngineHalio();
29  ~EngineHalio() override;
30 
31  ma_err_t init() override;
32  ma_err_t init(size_t size) override;
33  ma_err_t init(void* pool, size_t size) override;
34 
35  ma_err_t run() override;
36 
37  ma_err_t load(const void* model_data, size_t model_size) override;
38 #if MA_USE_FILESYSTEM
39  ma_err_t load(const char* model_path) override;
40  ma_err_t load(const std::string& model_path) override;
41 #endif
42 
43  int32_t getInputSize() override;
44  int32_t getOutputSize() override;
45  ma_tensor_t getInput(int32_t index) override;
46  ma_tensor_t getOutput(int32_t index) override;
47  ma_shape_t getInputShape(int32_t index) override;
48  ma_shape_t getOutputShape(int32_t index) override;
49  ma_quant_param_t getInputQuantParam(int32_t index) override;
50  ma_quant_param_t getOutputQuantParam(int32_t index) override;
51 
52  ma_err_t setInput(int32_t index, const ma_tensor_t& tensor) override;
53 
54 private:
55  unique_ptr<VDevice> _vdevice;
56  shared_ptr<InferModel> _model;
57  shared_ptr<ConfiguredInferModel> _configured_model;
58  shared_ptr<ConfiguredInferModel::Bindings> _bindings;
59 
60  unordered_map<string, shared_ptr<ma_tensor_t>> _io_buffers;
61  unordered_map<string, shared_ptr<ExternalHandler>> _external_handlers;
62 
63  vector<shared_ptr<ma_tensor_t>> _input_tensors;
64  vector<shared_ptr<ma_tensor_t>> _output_tensors;
65 };
66 
67 } // namespace ma::engine
68 
69 #endif
70 
71 #endif
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