nndeploy C++ API  0.2.0
nndeploy C++ API
executor.h
Go to the documentation of this file.
1 
2 #ifndef _NNDEPLOY_DAG_EXECUTOR_H_
3 #define _NNDEPLOY_DAG_EXECUTOR_H_
4 
5 #include "nndeploy/base/any.h"
6 #include "nndeploy/base/common.h"
8 #include "nndeploy/base/log.h"
9 #include "nndeploy/base/macro.h"
10 #include "nndeploy/base/object.h"
11 #include "nndeploy/base/status.h"
12 #include "nndeploy/base/string.h"
13 #include "nndeploy/dag/edge.h"
14 #include "nndeploy/dag/node.h"
15 #include "nndeploy/dag/util.h"
16 
17 namespace nndeploy {
18 namespace dag {
19 
21  public:
22  Executor() {};
23  virtual ~Executor() {
24  if (!is_external_stream_ && stream_ != nullptr) {
25  device::destroyStream(stream_);
26  stream_ = nullptr;
27  }
28  };
29 
30  void setStream(device::Stream *stream) {
31  if (stream_ != nullptr) {
32  device::destroyStream(stream_);
33  }
34  stream_ = stream;
35  is_external_stream_ = true;
36  }
37  device::Stream *getStream() { return stream_; }
38 
39  virtual base::Status init(std::vector<EdgeWrapper *> &edge_repository,
40  std::vector<NodeWrapper *> &node_repository) = 0;
41  virtual base::Status deinit() = 0;
42 
43  virtual base::Status run() = 0;
44  virtual bool synchronize() = 0;
45  virtual bool interrupt() = 0;
46 
47  protected:
48  // must be set by user
49  bool is_external_stream_ = false;
50  device::Stream *stream_ = nullptr;
51 };
52 
53 } // namespace dag
54 } // namespace nndeploy
55 
56 #endif
virtual base::Status run()=0
void setStream(device::Stream *stream)
Definition: executor.h:30
virtual bool interrupt()=0
virtual base::Status init(std::vector< EdgeWrapper * > &edge_repository, std::vector< NodeWrapper * > &node_repository)=0
virtual base::Status deinit()=0
device::Stream * getStream()
Definition: executor.h:37
virtual bool synchronize()=0
#define NNDEPLOY_CC_API
api
Definition: macro.h:29
base::Status destroyStream(Stream *stream)
销毁流