13#include <spdlog/spdlog.h>
26 spdlog::debug(
"[OperationPipelineExecutor]: Constructed. Input set to Float(32), 3 dimensions. Backend: {}",
31 std::vector<Operations::OperationDescriptor>&& operations,
34 spdlog::debug(
"[OperationPipelineExecutor::init (Move)]: Initializing with {} operations.", operations.size());
36 m_operations = std::move(operations);
39 if (!m_operations.empty()) {
44 m_pipeline_params.clear();
52 m_operations = std::move(operations);
55 for (
const auto& desc : m_operations)
57 if (!desc.enabled)
continue;
59 auto it = m_pipeline_params.find(desc.id);
60 if (it != m_pipeline_params.end())
63 if (
auto val_res = desc.getParam<
float>(
"value")) {
64 it->second.set(val_res.value());
69 spdlog::warn(
"[OperationPipelineExecutor::updateRuntimeParams]: Param '{}' not found in cache. Structure changed? Call init().", desc.name);
76 Halide::Func current_stage(
"current_stage");
77 current_stage(x, y, c) = input(x, y, c);
79 m_pipeline_params.clear();
81 for (
const auto& desc : m_operations)
83 if (!desc.enabled)
continue;
86 spdlog::error(
"[OperationPipelineExecutor::applyOperations]: Factory is null.");
90 auto op_impl_expected { m_factory->
create(desc) };
91 if (!op_impl_expected)
continue;
93 auto op_impl { std::move(op_impl_expected.value()) };
98 auto& param_ref { m_pipeline_params[desc.id] };
99 if (
auto val_res = desc.getParam<
float>(
"value")) {
100 param_ref.set(val_res.value());
102 current_stage = fusion_logic->appendToFusedPipeline(current_stage, x, y, c, param_ref);
105 return current_stage;
122 spdlog::debug(
"[OperationPipelineExecutor::executeOnHalideBuffer]: Halide Target Architecture: {}",
129 catch (
const Halide::RuntimeError& e) {
130 spdlog::critical(
"[OperationPipelineExecutor::executeOnHalideBuffer]: Halide Runtime Error: {}", e.what());
133 catch (
const std::exception& e) {
134 spdlog::critical(
"[OperationPipelineExecutor::executeOnHalideBuffer]: Unexpected exception: {}", e.what());
Application-wide configuration singleton.
static AppConfig & instance()
Gets the singleton instance of AppConfig.
static const Halide::Target & getHalideTarget()
Gets the configured Halide Target object.
Interface for providing the Halide fusion logic of an operation.
Factory Pattern - creates operations from OperationDescriptor.
std::expected< std::unique_ptr< IOperation >, ErrorHandling::CoreError > create(const OperationDescriptor &descriptor) const
Create an operation instance from descriptor.
Base class for Halide executors providing shared 4-channel input parameter.
Halide::ImageParam m_input
The shared Halide Input Parameter.
virtual void buildOperationChain()=0
Builds the Halide function graph based on m_operations.
bool m_chain_built
Flag indicating if the pipeline has been successfully built and compiled.
Halide::Func applyOperations(const Halide::Func &input, const Halide::Var &x, const Halide::Var &y, const Halide::Var &c)
Applies all operations to the input function.
OperationPipelineExecutor()
Default Constructor.
void init(std::vector< Operations::OperationDescriptor > &&operations, const Operations::OperationFactory &factory)
Initializes the executor with a moved list of operations (Optimized).
bool executeOnHalideBuffer(Halide::Buffer< float > &input_buffer, Halide::Buffer< float > &output_buffer) override
Executes the compiled pipeline directly on a Halide buffer.
void updateRuntimeParams(std::vector< Operations::OperationDescriptor > &&operations)
Updates the runtime values of the cached parameters WITHOUT recompiling.
Halide::Pipeline m_pipeline
The compiled Halide pipeline object.
Interface for providing the Halide fusion logic of an operation.
Factory for creating operations (Dependency Injection)
Declaration of OperationPipelineExecutor (Fused Adjustment Pipeline).