nndeploy C++ API  0.2.0
nndeploy C++ API
graph_runner.h
Go to the documentation of this file.
1 #ifndef _NNDEPLOY_DAG_GRAPH_RUNNER_H_
2 #define _NNDEPLOY_DAG_GRAPH_RUNNER_H_
3 
4 #include <map>
5 #include <memory>
6 #include <string>
7 #include <vector>
8 
9 #include "nndeploy/base/common.h"
10 #include "nndeploy/base/status.h"
11 #include "nndeploy/dag/graph.h"
12 
13 namespace nndeploy {
14 namespace dag {
15 
18  std::map<std::string, float> time_profiler_map;
19  std::map<std::string, std::shared_ptr<RunStatus>> run_status_map;
20  std::vector<base::Any> results;
21 };
22 
29  public:
31  virtual ~GraphRunner();
32 
43  std::shared_ptr<GraphRunnerResult> run(const std::string& graph_json_str,
44  const std::string& name = "graph_runner",
45  const std::string& task_id = "task_id");
46 
47  void set_json_file(bool is_json_file);
48  void set_dump(bool is_dump);
49  void set_time_profile(bool is_time_profile);
50  void set_debug(bool is_debug);
52  void set_loop_max_flag(bool is_loop_max_flag);
53  void set_node_value(const std::string& node_name, const std::string& key,
54  const std::string& value);
56  std::map<std::string, std::map<std::string, std::string>> node_value_map);
57 
58  protected:
66  base::Status buildGraph(const std::string& graph_json_str,
67  const std::string& name);
68 
69  private:
70  // 禁用拷贝构造和赋值
71  GraphRunner(const GraphRunner&) = delete;
72  GraphRunner& operator=(const GraphRunner&) = delete;
73 
74  private:
75  std::shared_ptr<Graph> graph_;
76  bool is_json_file_ = true;
77  std::string name_;
78  std::string task_id_;
79  bool is_dump_ = true;
80  bool is_time_profile_ = true;
81  bool is_debug_ = false;
83  bool is_loop_max_flag_ = true;
84  std::map<std::string, std::map<std::string, std::string>> node_value_map_;
85 };
86 
87 } // namespace dag
88 } // namespace nndeploy
89 
90 #endif // _NNDEPLOY_DAG_GRAPH_RUNNER_H_
GraphRunner类,用于运行图计算
Definition: graph_runner.h:28
void set_dump(bool is_dump)
void set_node_value(const std::string &node_name, const std::string &key, const std::string &value)
void set_node_value(std::map< std::string, std::map< std::string, std::string >> node_value_map)
void set_time_profile(bool is_time_profile)
void set_debug(bool is_debug)
void set_parallel_type(base::ParallelType parallel_type)
std::shared_ptr< GraphRunnerResult > run(const std::string &graph_json_str, const std::string &name="graph_runner", const std::string &task_id="task_id")
运行图计算
void set_loop_max_flag(bool is_loop_max_flag)
void set_json_file(bool is_json_file)
base::Status buildGraph(const std::string &graph_json_str, const std::string &name)
构建图对象
#define NNDEPLOY_CC_API
api
Definition: macro.h:29
@ kParallelTypeNone
Definition: common.h:354
std::map< std::string, std::shared_ptr< RunStatus > > run_status_map
Definition: graph_runner.h:19
std::map< std::string, float > time_profiler_map
Definition: graph_runner.h:18
std::vector< base::Any > results
Definition: graph_runner.h:20