Skip to main content

graphs Namespace

Definition

namespace simaai::neat::graphs { ... }

Namespaces Index

namespacedetail

Functions Index

GraphBranch (std::string input, std::vector< std::string > outputs)

Build a reusable Graph that branches one named input to several named outputs. More...

GraphCombine (std::vector< std::string > inputs, std::string output, CombinePolicy policy=CombinePolicy::ByFrame)

Build a reusable Graph that combines several named inputs into one named output. More...

Functions

Branch()

Graph simaai::neat::graphs::Branch (std::string input, std::vector< std::string > outputs)
inline

Build a reusable Graph that branches one named input to several named outputs.

Example:

 Graph branch = graphs::Branch("image", {"preview", "model"});

Conceptually:

 image -> preview
  -> model

The returned object is a normal public Graph containing one Input(input), one Output(name) per requested output, and endpoint connect(input, output) edges. At build time the compiler lowers this to the appropriate internal branch/fan-out runtime machinery while preserving the public endpoint names for Run::pull(name), diagnostics, and visualization.

Definition at line 62 of file Fragments.h.

62inline Graph Branch(std::string input, std::vector<std::string> outputs) {
63 if (outputs.empty()) {
64 throw std::runtime_error("graphs::Branch: at least one output endpoint is required");
65 }
66
67 std::unordered_set<std::string> used;
68 detail::require_unique_endpoint_name(&used, input, "graphs::Branch");
69 for (const auto& output : outputs) {
70 detail::require_unique_endpoint_name(&used, output, "graphs::Branch");
71 }
72
73 Graph g(input);
74 g.add(nodes::Input(input));
75 for (const auto& output : outputs) {
76 g.add(nodes::Output(output));
77 }
78 for (const auto& output : outputs) {
79 g.connect(input, output);
80 }
81 return g;
82}

Combine()

Graph simaai::neat::graphs::Combine (std::vector< std::string > inputs, std::string output, CombinePolicy policy=CombinePolicy::ByFrame)
inline

Build a reusable Graph that combines several named inputs into one named output.

Example:

 Graph join = graphs::Combine({"left", "right"}, "pair", CombinePolicy::ByFrame);

policy defines how samples from the named inputs are matched:

The helper only constructs public Graph topology. The compiler is responsible for lowering the multi-producer output to the internal combine stage for ByFrame / ByPts.

Definition at line 102 of file Fragments.h.

102inline Graph Combine(std::vector<std::string> inputs, std::string output,
104 if (inputs.empty()) {
105 throw std::runtime_error("graphs::Combine: at least one input endpoint is required");
106 }
107
108 std::unordered_set<std::string> used;
109 for (const auto& input : inputs) {
110 detail::require_unique_endpoint_name(&used, input, "graphs::Combine");
111 }
112 detail::require_unique_endpoint_name(&used, output, "graphs::Combine");
113
114 Graph g(output);
115 for (const auto& input : inputs) {
116 g.add(nodes::Input(input));
117 }
118 OutputOptions opt;
119 opt.combine_policy = policy;
120 g.add(nodes::Output(output, opt));
121 for (const auto& input : inputs) {
122 g.connect(input, output);
123 }
124 return g;
125}

The documentation for this namespace was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.