Skip to main content

Run.h File

Run push/pull runtime handle and diagnostics stats. More...

Included Headers

#include "pipeline/SessionOptions.h" #include <cstdint> #include <functional> #include <memory> #include <optional> #include <string> #include <vector>

Namespaces Index

namespacecv
namespacesimaai
namespaceneat

Classes Index

structRunAdvancedOptions
structRunOptions
structInputDropInfo
structInputStreamStats
structRunStats
structRunStageStats
structRunElementTimingStats
structRunElementFlowStats
structRunDiagSnapshot
structRunReportOptions
classRun

Runtime handle for pushing inputs and pulling outputs. More...

Description

Run push/pull runtime handle and diagnostics stats.

File Listing

The file content with the documentation metadata removed is:

1
6#pragma once
7
9
10#include <cstdint>
11#include <functional>
12#include <memory>
13#include <optional>
14#include <string>
15#include <vector>
16
17namespace cv {
18class Mat;
19} // namespace cv
20
21namespace simaai::neat {
22
23class InputStream;
24struct InputStreamOptions;
25
26enum class OverflowPolicy {
27 Block = 0,
30};
31
32enum class RunPreset {
36};
37
38enum class OutputMemory {
39 Auto = 0,
41 Owned,
42};
43
45 bool copy_input = false;
46 std::size_t max_input_bytes = 0;
47};
48
49struct RunOptions {
51 int queue_depth = 4;
54 bool enable_metrics = false;
56 std::function<void(const struct InputDropInfo&)> on_input_drop;
57};
58
61 std::string media_type;
62 std::string format;
63 int width = -1;
64 int height = -1;
65 int depth = -1;
66 int64_t frame_id = -1;
67 std::string stream_id;
68 std::string port_name;
69 std::string reason;
70};
71
73 std::uint64_t push_count = 0;
74 std::uint64_t push_failures = 0;
75 std::uint64_t pull_count = 0;
76 std::uint64_t poll_count = 0;
77 std::uint64_t dropped_frames = 0;
78 std::uint64_t renegotiations = 0;
79 std::uint64_t alloc_grows = 0;
80 std::uint64_t growth_blocked = 0;
81 std::uint64_t renegotiation_blocked = 0;
82 double avg_alloc_us = 0.0;
83 double avg_map_us = 0.0;
84 double avg_copy_us = 0.0;
85 double avg_push_us = 0.0;
86 double avg_pull_wait_us = 0.0;
87 double avg_decode_us = 0.0;
88};
89
90struct RunStats {
91 std::uint64_t inputs_enqueued = 0;
92 std::uint64_t inputs_dropped = 0;
93 std::uint64_t inputs_pushed = 0;
94 std::uint64_t outputs_ready = 0;
95 std::uint64_t outputs_pulled = 0;
96 std::uint64_t outputs_dropped = 0;
97 double avg_latency_ms = 0.0;
98 double min_latency_ms = 0.0;
99 double max_latency_ms = 0.0;
100};
101
103 std::string stage_name;
104 std::uint64_t samples = 0;
105 std::uint64_t total_us = 0;
106 std::uint64_t max_us = 0;
107};
108
110 std::string element_name;
111 std::uint64_t samples = 0;
112 std::uint64_t total_us = 0;
113 std::uint64_t max_us = 0;
114 std::uint64_t min_us = 0;
115 std::uint64_t missed_in = 0;
116 std::uint64_t missed_out = 0;
117};
118
120 std::string element_name;
121 std::uint64_t in_buffers = 0;
122 std::uint64_t out_buffers = 0;
123 std::uint64_t in_bytes = 0;
124 std::uint64_t out_bytes = 0;
125 std::uint64_t caps_changes = 0;
126};
127
129 std::vector<RunStageStats> stages;
130 std::vector<BoundaryFlowStats> boundaries;
131 std::vector<RunElementTimingStats> element_timings;
132 std::vector<RunElementFlowStats> element_flows;
133};
134
136 bool include_pipeline = true;
139 bool include_boundaries = true;
140 bool include_flow_stats = true;
142 bool include_next_cpu = false;
145 bool include_run_stats = true;
147 bool include_system_info = false;
148};
149
153class Run {
154public:
155 Run() = default;
156 Run(const Run&) = delete;
157 Run& operator=(const Run&) = delete;
158
159 Run(Run&&) noexcept;
160 Run& operator=(Run&&) noexcept;
161 ~Run();
162
163 explicit operator bool() const noexcept;
164 bool can_push() const;
165 bool can_pull() const;
166 bool running() const;
167
168 bool push(const cv::Mat& input);
169 bool try_push(const cv::Mat& input);
170 bool push(const simaai::neat::Tensor& input);
171 bool try_push(const simaai::neat::Tensor& input);
172 bool push(const Sample& msg);
173 bool try_push(const Sample& msg);
174 // Internal: pushes a GstBuffer held by a tensor ref to preserve plugin metadata.
175 bool push_holder(const std::shared_ptr<void>& holder);
176 bool try_push_holder(const std::shared_ptr<void>& holder);
178 PullStatus pull(int timeout_ms, Sample& out, PullError* err = nullptr);
179 std::optional<Sample> pull(int timeout_ms = -1);
180 std::optional<simaai::neat::Tensor> pull_tensor(int timeout_ms = -1);
181 simaai::neat::Tensor pull_tensor_or_throw(int timeout_ms = -1);
182 std::optional<simaai::neat::Tensor> pull_tensor_matching(const std::string& payload_tag,
183 int timeout_ms = -1);
184 Sample push_and_pull(const cv::Mat& input, int timeout_ms = -1);
185 Sample push_and_pull(const simaai::neat::Tensor& input, int timeout_ms = -1);
186 Sample push_and_pull_holder(const std::shared_ptr<void>& holder, int timeout_ms = -1);
187 Sample run(const cv::Mat& input, int timeout_ms = -1);
188 Sample run(const simaai::neat::Tensor& input, int timeout_ms = -1);
189 Sample run(const Sample& input, int timeout_ms = -1);
190 int warmup(const cv::Mat& input, int warm = -1, int timeout_ms = -1);
191
192 RunStats stats() const;
195 std::string report(const RunReportOptions& opt = {}) const;
196 std::string last_error() const;
197 std::string diagnostics_summary() const;
198
199 void stop();
200 void close();
201
202private:
203 struct State;
204 std::shared_ptr<State> state_;
205 bool owns_ref_ = false;
206
207 explicit Run(std::shared_ptr<State> state);
208 bool push_impl(const cv::Mat& input, bool block);
209 bool push_impl(const simaai::neat::Tensor& input, bool block);
210 bool push_holder_impl(const std::shared_ptr<void>& holder, bool block);
211 bool push_message_impl(const Sample& msg, bool block);
212 static Run create(InputStream stream, const RunOptions& opt,
213 const struct InputStreamOptions& stream_opt);
214 friend class Session;
215};
216
217} // namespace simaai::neat

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.1.