84{
85 if (!_initialized.load())
86 {
87 throw std::runtime_error("Pipeline is not initialized");
88 }
89
90 if (_models.empty())
91 {
92 throw std::runtime_error("No models in pipeline");
93 }
94
95 _executing = true;
96
97 try
98 {
99 auto current_inputs =
inputs;
100 auto current_outputs = outputs;
101
102 for (size_t i = 0; i < _models.size(); ++i)
103 {
104 auto &
model = _models[i];
105 if (!model || !
model->isPrepared())
106 {
107 throw std::runtime_error("Model at index " + std::to_string(i) + " is not prepared");
108 }
109
110
111 model->waitForBufferReady();
112
113
114 model->run(current_inputs, current_outputs);
115
116
117 if (i < _models.size() - 1)
118 {
119 current_inputs.clear();
120 for (const auto &output : current_outputs)
121 {
122 current_inputs.push_back(const_cast<IPortableTensor *>(output));
123 }
124 }
125
126
127 if (_use_buffer_sharing)
128 {
129 if (
auto next =
model->getNextModel())
130 {
131 next->startAsyncBufferFill();
132 }
133 }
134 }
135 }
136 catch (...)
137 {
138 _executing = false;
139 throw;
140 }
141
142 _executing = false;
143}