21template <ComputeData InputType = std::vector<Kakshya::DataVariant>, ComputeData OutputType = InputType>
64 if (dep->validate_input(
input)) {
98 virtual void set_parameter(
const std::string& name, std::any value) = 0;
105 [[nodiscard]]
virtual std::any
get_parameter(
const std::string& name)
const = 0;
123 [[nodiscard]]
virtual std::string
get_name()
const {
return "ComputeOperation"; }
218 switch (context.
mode) {
241 return std::async(std::launch::async, [
this,
input]() {
267 std::any any_data = metadata;
271 auto result = safe_any_cast<output_type>(reconstructed);
273 return *result.value;
279 "Reconstruction callback type mismatch: {}",
281 return OperationHelper::reconstruct_from_double<output_type>(result_data, metadata);
284 return OperationHelper::reconstruct_from_double<output_type>(result_data, metadata);
301 std::any result_any = &result;
316 if constexpr (std::is_same_v<InputType, Kakshya::Region>) {
320 "InputType 'Region' is an expressive marker, not a data holder. Operations will process coordinate data rather than signal data. Consider using DataVariant or SignalSourceContainer for signal processing.");
321 }
else if constexpr (std::is_same_v<InputType, Kakshya::RegionGroup>) {
325 "InputType 'RegionGroup' is an expressive marker, not a data holder. Operations will process coordinate data rather than signal data. Consider using DataVariant or SignalSourceContainer for signal processing.");
326 }
else if constexpr (std::is_same_v<InputType, std::vector<Kakshya::RegionSegment>>) {
330 "InputType 'RegionSegments' are expressive markers, not primary data holders. Operations will attempt to extract data from segment metadata. Consider using DataVariant or SignalSourceContainer for direct signal processing.");
333 if constexpr (std::is_same_v<OutputType, Kakshya::Region>) {
337 "OutputType 'Region' is an expressive marker, not a data holder. Operations will create spatial/temporal markers with results as metadata.");
338 }
else if constexpr (std::is_same_v<OutputType, Kakshya::RegionGroup>) {
342 "OutputType 'RegionGroup' is an expressive marker, not a data holder. Operations will organize results into spatial/temporal groups.");
343 }
else if constexpr (std::is_same_v<OutputType, std::vector<Kakshya::RegionSegment>>) {
347 "OutputType 'RegionSegments' is an expressive marker, not a data holder. Operations will create segments with results in metadata. Consider using DataVariant or SignalSourceContainer for direct signal processing.");
#define MF_INFO(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
Core::GlobalInputConfig input
Local execution orchestrator for computational operations.
std::shared_ptr< GpuExecutionContext< InputType, OutputType > > m_gpu_backend
void set_last_execution_context(const ExecutionContext &ctx)
virtual void set_parameter(const std::string &name, std::any value)=0
Sets a named parameter that configures the operation's behavior.
const ExecutionContext & get_last_execution_context() const
virtual ~ComputeOperation()=default
Virtual destructor for proper cleanup of derived classes.
void set_reconstruction_callback(const ReconstructionCallback &callback)
virtual void set_container_for_regions(const std::shared_ptr< Kakshya::SignalSourceContainer > &container)
output_type apply_hooks(const input_type &input, const ExecutionContext &context)
void set_pre_execution_hook(const OperationHookCallback &hook)
virtual std::any get_parameter(const std::string &name) const =0
Retrieves a parameter's current value.
output_type apply_operation(const input_type &input)
Public synchronous execution interface.
void set_gpu_backend(std::shared_ptr< GpuExecutionContext< InputType, OutputType > > backend)
Attach a GPU execution backend.
void validate_operation_data_types() const
Validate input/output types and warn about marker types.
OutputType apply_to_data(const InputType &data)
Convenience overload that extracts just the data from result.
void set_post_execution_hook(const OperationHookCallback &hook)
ExecutionContext m_last_execution_context
virtual OperationType get_operation_type() const =0
Returns the category of this operation for grammar and registry discovery.
virtual output_type apply_operation_internal(const input_type &input, const ExecutionContext &context)
Internal execution method - ComputeMatrix can access this.
output_type operator()(const InputType &data)
Convenience overload for direct data processing (backward compatibility)
virtual output_type operation_function(const input_type &input)=0
Executes the computational transformation on the input data.
virtual bool validate_input(const input_type &) const
Validates if the input data meets the operation's requirements.
output_type apply_operation_with_dependencies(const input_type &input)
Applies the operation with dependencies resolved.
virtual output_type apply_operation_chained(const input_type &input, const ExecutionContext &ctx)
Optional chain-aware implementation - default delegates to operation_function.
bool has_gpu_backend() const
std::shared_ptr< Kakshya::SignalSourceContainer > m_container
virtual const std::shared_ptr< Kakshya::SignalSourceContainer > & get_container_for_regions() const
std::vector< std::shared_ptr< ComputeOperation > > m_dependencies
virtual std::string get_name() const
Get operation name for debugging/introspection.
const auto & get_dependencies() const
output_type convert_result(std::vector< std::vector< double > > &result_data, DataStructureInfo &metadata)
Convert processed double data back to OutputType using metadata and optional callback.
ComputeOperation()
Constructor with data type validation warnings.
virtual std::future< output_type > apply_operation_async(const input_type &input)
Optional async implementation - default delegates to operation_function.
virtual std::map< std::string, std::any > get_all_parameters() const
Retrieves all parameters and their values.
void add_dependency(std::shared_ptr< ComputeOperation > dep)
output_type execute(const input_type &input)
OpUnit interface - operations can act as units in dependency graphs.
virtual output_type apply_operation_parallel(const input_type &input, const ExecutionContext &ctx)
Optional parallel-aware implementation - default delegates to operation_function.
Base interface for all computational operations in the processing pipeline.
Type-parameterised shell over GpuDispatchCore.
@ ComputeMatrix
Compute operations (Yantra - algorithms, matrices, DSP)
@ Runtime
General runtime operations (default fallback)
@ Yantra
DSP algorithms, computational units, matrix operations, Grammar.
std::function< void(std::any &)> OperationHookCallback
Callback type for pre/post operation hooks.
OperationType
Operation categories for organization and discovery.
@ SYNC
Synchronous execution.
@ CHAINED
Part of a sequential chain.
@ DEPENDENCY
Part of dependency graph.
@ ASYNC
Asynchronous execution.
@ PARALLEL
Parallel with other operations.
std::function< std::any(std::vector< std::vector< double > > &, std::any &)> ReconstructionCallback
Callback type for custom reconstruction logic.
Metadata about data structure for reconstruction.
Input/Output container for computation pipeline data flow with structure preservation.
ExecutionMode mode
Execution mode controlling scheduling behavior.
OperationHookCallback pre_execution_hook
Optional callback invoked before operation execution.
ReconstructionCallback reconstruction_callback
Optional callback used for custom reconstruction of results.
OperationHookCallback post_execution_hook
Optional callback invoked after operation execution.
Context information controlling how a compute operation executes.