Neuralyzer::Transforms::V2::TransformPipeline
Neuralyzer::Transforms::V2::TransformPipeline
Builder for chaining multiple transforms together. More…
#include <TransformPipeline.hpp>
Public Functions
| Name | |
|---|---|
| TransformPipeline() =default | |
| template <typename Params > TransformPipeline & |
addStep(std::string const & transform_name, Params params) Add a transform step to the pipeline. |
| TransformPipeline & | addStep(std::string const & transform_name) Add a transform step with no parameters. |
| TransformPipeline & | addStep(PipelineStep step) Add a pre-constructed pipeline step. |
| template <typename Params > TransformPipeline & |
addStepWithBindings(std::string const & transform_name, Params params, std::map< std::string, std::string > bindings) |
| TransformPipeline & | addPreReduction(std::string const & reduction_name, std::string const & output_key) |
| template <typename Params > TransformPipeline & |
addPreReduction(std::string const & reduction_name, std::string const & output_key, Params params) Add a pre-execution reduction with parameters. |
| TransformPipeline & | addPreReduction(ReductionStep step) Add a pre-constructed reduction step. |
| TransformPipeline & | addPreReductions(std::vector< ReductionStep > reductions) Add multiple pre-execution reductions at once. |
| bool | hasPreReductions() const Check if the pipeline has pre-execution reductions. |
| std::vector< ReductionStep > const & | getPreReductions() const Get the pre-execution reduction steps. |
| void | clearPreReductions() Clear all pre-execution reductions. |
| template <typename IntermediateElement ,typename Scalar ,typename Params > TransformPipeline & |
setRangeReduction(std::string const & reduction_name, Params params) |
| template <typename IntermediateElement ,typename Scalar > TransformPipeline & |
setRangeReduction(std::string const & reduction_name) Set a stateless terminal range reduction. |
| TransformPipeline & | setRangeReductionErased(std::string const & reduction_name, std::any params) Set a terminal range reduction with type-erased parameters. |
| bool | hasRangeReduction() const Check if the pipeline has a terminal range reduction. |
| std::optional< RangeReductionStep > const & | getRangeReduction() const Get the range reduction step (if set). |
| TransformPipeline | withBoundParameters(PipelineValueStore const & store) const Return a copy with all step and reduction parameter bindings applied. |
| void | clearRangeReduction() Clear the terminal range reduction. |
| template <typename InputContainer > DataTypeVariant |
execute(InputContainer const & input) const Execute pipeline and return variant result (Generalist). |
| template <typename InputContainer ,typename OutputContainer > std::shared_ptr< OutputContainer > |
executeOptimized(InputContainer const & input) const Execute pipeline with automatic fusion optimization (Dispatcher). |
| template <typename InputContainer ,typename OutputContainer > std::shared_ptr< OutputContainer > |
executeFused(InputContainer const & input) const Execute a multi-step element-level pipeline with full fusion (Specialist). |
| size_t | size() const Get the number of steps in the pipeline. |
| bool | empty() const Check if the pipeline is empty. |
| std::string const & | getStepName(size_t index) const Get information about a specific step. |
| PipelineStep const & | getStep(size_t index) const Get the step at a specific index. |
| bool | isElementWiseOnly() const Check if the pipeline contains only element-level transforms. |
| template <typename InputElement ,std::ranges::input_range View> auto |
executeFromView(View && view) const Execute pipeline on a generic view (View-Based Entry Point). |
| template <typename InputContainer > auto |
executeAsView(InputContainer const & input) const |
| template <typename InputContainer ,typename OutElement > auto |
executeAsViewTyped(InputContainer const & input) const |
Detailed Description
class Neuralyzer::Transforms::V2::TransformPipeline;Builder for chaining multiple transforms together.
This class enables composing a sequence of transforms that will be applied in order, with automatic container type transitions.
The pipeline is fully generic and works with any compatible transforms.
Example usage: ```cpp
auto pipeline = TransformPipeline() .addStep(“CalculateMaskArea”, MaskAreaParams{}) .addStep(“SumReduction”, SumReductionParams{});
// Execute with correct input/output types std::shared_ptr
## Public Functions Documentation
### function TransformPipeline
```cpp
TransformPipeline() =default
function addStep
template <typename Params >
inline TransformPipeline & addStep(
std::string const & transform_name,
Params params
)Add a transform step to the pipeline.
Parameters:
- transform_name Name of the registered transform
- params Parameters for the transform
Template Parameters:
- Params Parameter type for this transform
Return: Reference to this pipeline for chaining
function addStep
inline TransformPipeline & addStep(
std::string const & transform_name
)Add a transform step with no parameters.
function addStep
inline TransformPipeline & addStep(
PipelineStep step
)Add a pre-constructed pipeline step.
Parameters:
- step Pre-constructed pipeline step
Return: Reference to this pipeline for chaining
This is useful for loading pipelines from JSON where the step is constructed separately with type-erased parameters.
function addStepWithBindings
template <typename Params >
inline TransformPipeline & addStepWithBindings(
std::string const & transform_name,
Params params,
std::map< std::string, std::string > bindings
)function addPreReduction
inline TransformPipeline & addPreReduction(
std::string const & reduction_name,
std::string const & output_key
)function addPreReduction
template <typename Params >
inline TransformPipeline & addPreReduction(
std::string const & reduction_name,
std::string const & output_key,
Params params
)Add a pre-execution reduction with parameters.
Parameters:
- reduction_name Name of registered range reduction
- output_key Key to store result under
- params Parameters for the reduction
Template Parameters:
- Params Parameter type for the reduction
Return: Reference to this pipeline for chaining
function addPreReduction
inline TransformPipeline & addPreReduction(
ReductionStep step
)Add a pre-constructed reduction step.
Parameters:
- step Pre-constructed reduction step
Return: Reference to this pipeline for chaining
Useful for loading from JSON where the step is constructed separately.
function addPreReductions
inline TransformPipeline & addPreReductions(
std::vector< ReductionStep > reductions
)Add multiple pre-execution reductions at once.
Parameters:
- reductions Vector of reduction steps
Return: Reference to this pipeline for chaining
function hasPreReductions
inline bool hasPreReductions() constCheck if the pipeline has pre-execution reductions.
function getPreReductions
inline std::vector< ReductionStep > const & getPreReductions() constGet the pre-execution reduction steps.
function clearPreReductions
inline void clearPreReductions()Clear all pre-execution reductions.
function setRangeReduction
template <typename IntermediateElement ,
typename Scalar ,
typename Params >
inline TransformPipeline & setRangeReduction(
std::string const & reduction_name,
Params params
)function setRangeReduction
template <typename IntermediateElement ,
typename Scalar >
inline TransformPipeline & setRangeReduction(
std::string const & reduction_name
)Set a stateless terminal range reduction.
function setRangeReductionErased
inline TransformPipeline & setRangeReductionErased(
std::string const & reduction_name,
std::any params
)Set a terminal range reduction with type-erased parameters.
Parameters:
- reduction_name Name of the registered range reduction
- params Type-erased parameters (must match the reduction’s expected type)
Return: Reference to this pipeline for chaining
This is used when loading pipelines from JSON where parameter types are resolved at runtime via the registry. The input/output types will be determined from the reduction’s metadata.
function hasRangeReduction
inline bool hasRangeReduction() constCheck if the pipeline has a terminal range reduction.
function getRangeReduction
inline std::optional< RangeReductionStep > const & getRangeReduction() constGet the range reduction step (if set).
function withBoundParameters
TransformPipeline withBoundParameters(
PipelineValueStore const & store
) constReturn a copy with all step and reduction parameter bindings applied.
Parameters:
- store Value store used to resolve each
param_bindingsentry
Return: Bound pipeline copy; the original pipeline is not modified
function clearRangeReduction
inline void clearRangeReduction()Clear the terminal range reduction.
function execute
template <typename InputContainer >
DataTypeVariant execute(
InputContainer const & input
) constExecute pipeline and return variant result (Generalist).
See:
- executeOptimized For compile-time known types with automatic optimization
- executeFused For high-performance pure element-wise pipelines
Determines output container type at runtime based on pipeline steps and input raggedness. This is the primary entry point for runtime-composed pipelines (e.g. from UI) where the output type is not known at compile time.
Uses a buffered execution model that handles transitions between element-wise and time-grouped transforms.
function executeOptimized
template <typename InputContainer ,
typename OutputContainer >
inline std::shared_ptr< OutputContainer > executeOptimized(
InputContainer const & input
) constExecute pipeline with automatic fusion optimization (Dispatcher).
Parameters:
- input Input data
Template Parameters:
- InputContainer Input container type
- OutputContainer Output container type
See:
- executeFused The specialized implementation for pure element pipelines
- execute The general implementation handling time-grouped transforms
Return: Output container
Analyzes the pipeline structure and chooses the optimal execution strategy:
- Pure element chains: Fused single-pass execution (via executeFused)
- Chains with time-grouped: Materialized intermediate execution (via execute)
Use this when the output type is known at compile time.
function executeFused
template <typename InputContainer ,
typename OutputContainer >
inline std::shared_ptr< OutputContainer > executeFused(
InputContainer const & input
) constExecute a multi-step element-level pipeline with full fusion (Specialist).
Parameters:
- input Input data
Template Parameters:
- InputContainer Input container type
- OutputContainer Output container type
See:
- executeOptimized Automatic selection of this method
- executeAsView For lazy evaluation without materialization
Return: Output with composed transformation applied
For element→element→element pipelines (no time-grouped transforms), this composes all transforms into a single function and executes in one pass with zero intermediate allocations.
Example: Mask2D → skeletonize → fitLine → resample Results in: for (mask : masks) { output.add(resample(fitLine(skeletonize(mask)))); }
Performance:
- Single pass through input data
- No intermediate container allocations
- Intermediate values stay hot in CPU cache
- Type erasure overhead (~1-2 pointer dereferences per element per step)
Implementation: Uses runtime function composition with type-erased intermediate values. This allows arbitrary pipeline lengths determined at runtime (e.g., from UI).
function size
inline size_t size() constGet the number of steps in the pipeline.
function empty
inline bool empty() constCheck if the pipeline is empty.
function getStepName
inline std::string const & getStepName(
size_t index
) constGet information about a specific step.
function getStep
inline PipelineStep const & getStep(
size_t index
) constGet the step at a specific index.
function isElementWiseOnly
inline bool isElementWiseOnly() constCheck if the pipeline contains only element-level transforms.
Returns false if any step is a time-grouped transform.
function executeFromView
template <typename InputElement ,
std::ranges::input_range View>
inline auto executeFromView(
View && view
) constExecute pipeline on a generic view (View-Based Entry Point).
Parameters:
- view The input view
Template Parameters:
- InputElement The type of the data element in the view (e.g. Mask2D, tuple<Line2D, Point2D>)
- View The range type
Return: Lazy range view of (TimeFrameIndex, ElementVariant) pairs
Allows executing the pipeline on any range that yields (TimeFrameIndex, InputElement) pairs. This is essential for multi-input pipelines where the input is a zipped view (e.g. RaggedZipView).
function executeAsView
template <typename InputContainer >
inline auto executeAsView(
InputContainer const & input
) constfunction executeAsViewTyped
template <typename InputContainer ,
typename OutElement >
inline auto executeAsViewTyped(
InputContainer const & input
) constUpdated on 2026-11-13 at 20:25:41 +0000