mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge pull request #21660 from TolyaTalamanov:at/handle-exception-in-streamingexecutor
[G-API] Handle exceptions in streaming executor * Handle exceptions in streaming executor * Rethrow exception in non-streaming executor * Clean up * Put more tests * Handle exceptions in IE backend * Handle exception in IE callbacks * Handle exception in GExecutor * Handle all exceptions in IE backend * Not only (std::exception& e) * Fix comments to review * Handle input exception in generic way * Fix comment * Clean up * Apply review comments * Put more comments * Fix alignment * Move test outside of HAVE_NGRAPH * Fix compilation
This commit is contained in:
committed by
GitHub
parent
78bc11465b
commit
d98e07c3d3
@@ -412,7 +412,17 @@ void GIslandExecutable::run(GIslandExecutable::IInput &in, GIslandExecutable::IO
|
||||
out_objs.emplace_back(ade::util::value(it),
|
||||
out.get(ade::util::checked_cast<int>(ade::util::index(it))));
|
||||
}
|
||||
run(std::move(in_objs), std::move(out_objs));
|
||||
|
||||
try {
|
||||
run(std::move(in_objs), std::move(out_objs));
|
||||
} catch (...) {
|
||||
auto eptr = std::current_exception();
|
||||
for (auto &&it: out_objs)
|
||||
{
|
||||
out.post(std::move(it.second), eptr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Propagate in-graph meta down to the graph
|
||||
// Note: this is not a complete implementation! Mainly this is a stub
|
||||
|
||||
@@ -161,7 +161,12 @@ public:
|
||||
const std::vector<cv::gimpl::RcDesc> &desc() const { return d; }
|
||||
};
|
||||
struct EndOfStream {};
|
||||
using StreamMsg = cv::util::variant<EndOfStream, cv::GRunArgs>;
|
||||
|
||||
struct Exception {
|
||||
std::exception_ptr eptr;
|
||||
};
|
||||
|
||||
using StreamMsg = cv::util::variant<EndOfStream, cv::GRunArgs, Exception>;
|
||||
struct GIslandExecutable::IInput: public GIslandExecutable::IODesc {
|
||||
virtual ~IInput() = default;
|
||||
virtual StreamMsg get() = 0; // Get a new input vector (blocking)
|
||||
@@ -169,9 +174,11 @@ struct GIslandExecutable::IInput: public GIslandExecutable::IODesc {
|
||||
};
|
||||
struct GIslandExecutable::IOutput: public GIslandExecutable::IODesc {
|
||||
virtual ~IOutput() = default;
|
||||
virtual GRunArgP get(int idx) = 0; // Allocate (wrap) a new data object for output idx
|
||||
virtual void post(GRunArgP&&) = 0; // Release the object back to the framework (mark available)
|
||||
virtual void post(EndOfStream&&) = 0; // Post end-of-stream marker back to the framework
|
||||
virtual GRunArgP get(int idx) = 0; // Allocate (wrap) a new data object for output idx
|
||||
virtual void post(GRunArgP&&, const std::exception_ptr& = {}) = 0; // Release the object back to the framework (mark available)
|
||||
virtual void post(EndOfStream&&) = 0; // Post end-of-stream marker back to the framework
|
||||
virtual void post(Exception&&) = 0;
|
||||
|
||||
|
||||
// Assign accumulated metadata to the given output object.
|
||||
// This method can only be called after get() and before post().
|
||||
|
||||
Reference in New Issue
Block a user