Execute the pipeline with grammar rule application.
The pipeline provides comprehensive error handling with operation-specific error messages that include the operation name for debugging.
155 {})
156 {
158 ExecutionContext current_context = context;
159
160 if (
auto best_rule =
m_grammar->find_best_match(current_data, current_context)) {
161 if (
auto rule_result =
m_grammar->execute_rule(best_rule->name, current_data, current_context)) {
162 auto cast_result = safe_any_cast<input_type>(*rule_result);
163
164 if (cast_result) {
165 current_data = *cast_result.value;
166 } else {
170 "Grammar rule '{}' returned incompatible type: {}",
171 best_rule->name,
172 cast_result.error);
173 }
174 }
175 }
176
178 try {
179 auto result = operation->apply_operation(current_data);
180 current_data = result;
181 } catch (const std::exception& e) {
184 "Pipeline operation '{}' failed: {}", name, e.what());
185 }
186 }
187
188 if constexpr (std::is_same_v<InputType, OutputType>) {
189 return current_data;
190 } else {
192 return result;
193 }
194 }
#define MF_ERROR(comp, ctx,...)
Datum< InputType > input_type
Datum< OutputType > output_type
std::vector< std::pair< std::shared_ptr< ComputeOperation< InputType, OutputType > >, std::string > > m_operations
Operations and their names in execution order.
std::shared_ptr< ComputationGrammar > m_grammar
Grammar instance for rule-based operation selection.
@ Runtime
General runtime operations (default fallback)
void error_rethrow(Component component, Context context, std::source_location location=std::source_location::current(), std::string_view additional_context="")
Catch and log an exception, then rethrow it.
@ Yantra
DSP algorithms, computational units, matrix operations, Grammar.