explicit RequestPool(std::vector<InferenceEngine::InferRequest>&& requests);
void execute(Task&& t);
- void waitAndShutdown();
+ void waitAll();
private:
void callback(Task task, InferenceEngine::InferRequest& request, size_t id);
+ void setup();
QueueClass<size_t> m_idle_ids;
std::vector<InferenceEngine::InferRequest> m_requests;
// RequestPool implementation //////////////////////////////////////////////
cv::gimpl::ie::RequestPool::RequestPool(std::vector<InferenceEngine::InferRequest>&& requests)
: m_requests(std::move(requests)) {
- for (size_t i = 0; i < m_requests.size(); ++i) {
- m_idle_ids.push(i);
- }
+ setup();
}
+void cv::gimpl::ie::RequestPool::setup() {
+ for (size_t i = 0; i < m_requests.size(); ++i) {
+ m_idle_ids.push(i);
+ }
+}
+
void cv::gimpl::ie::RequestPool::execute(cv::gimpl::ie::RequestPool::Task&& t) {
size_t id = 0u;
m_idle_ids.pop(id);
}
// NB: Not thread-safe.
-void cv::gimpl::ie::RequestPool::waitAndShutdown() {
+void cv::gimpl::ie::RequestPool::waitAll() {
// NB: It will be blocked if at least one request is busy.
for (size_t i = 0; i < m_requests.size(); ++i) {
size_t id = 0u;
m_idle_ids.pop(id);
}
+ setup();
}
// GCPUExcecutable implementation //////////////////////////////////////////////
if (cv::util::holds_alternative<cv::gimpl::EndOfStream>(in_msg))
{
// (3) Wait until all passed task are done.
- m_reqPool->waitAndShutdown();
+ m_reqPool->waitAll();
out.post(cv::gimpl::EndOfStream{});
return;
}
// (5) In non-streaming mode need to wait until the all tasks are done
// FIXME: Is there more graceful way to handle this case ?
if (!m_gm.metadata().contains<Streaming>()) {
- m_reqPool->waitAndShutdown();
+ m_reqPool->waitAll();
}
}
// Validate
validate();
}
+
+TEST_F(ROIList, CallInferMultipleTimes)
+{
+ cv::GArray<cv::Rect> rr;
+ cv::GMat in;
+ cv::GArray<cv::GMat> age, gender;
+ std::tie(age, gender) = cv::gapi::infer<AgeGender>(rr, in);
+ cv::GComputation comp(cv::GIn(in, rr), cv::GOut(age, gender));
+
+ auto pp = cv::gapi::ie::Params<AgeGender> {
+ params.model_path, params.weights_path, params.device_id
+ }.cfgOutputLayers({ "age_conv3", "prob" });
+
+ auto cc = comp.compile(cv::descr_of(cv::gin(m_in_mat, m_roi_list)),
+ cv::compile_args(cv::gapi::networks(pp)));
+
+ for (int i = 0; i < 10; ++i) {
+ cc(cv::gin(m_in_mat, m_roi_list), cv::gout(m_out_gapi_ages, m_out_gapi_genders));
+ }
+
+ validate();
+}
+
} // namespace opencv_test
#endif // HAVE_INF_ENGINE