holoscan::ops::OperatorRunner
holoscan::ops::OperatorRunner
A class to run an operator independently from the workflow.
This class provides methods to push entities to the operator’s input ports and pop entities from the operator’s output ports. It also provides a method to run the operator separately from the workflow.
This class uses the GXFWrapper to set up and run the operator. The start() and stop() methods are called automatically when the operator is started or stopped. It uses AsynchronousCondition (with AsynchronousEventState::WAIT) to block the operator execution (calling the compute() method) from the holoscan executor, allowing the operator to run independently from the workflow via the run() method.
Input data can be pushed to the operator’s input ports using the push_input() method before calling run(). Output data can be retrieved from the operator’s output ports using the pop_output() method after calling run().
Both push_input() and pop_output() methods support the templated DataT type, which can be:
- Primitive types (int, float, etc.)
- Custom classes/structs (must be copyable/movable)
- Smart pointers (std::shared_ptr, std::unique_ptr)
- Standard library containers (std::vector, std::string, etc.)
- std::any
- holoscan::gxf::Entity
- holoscan::TensorMap
Example types:
If the template type is not specified for pop_output() method, the method will return a holoscan::gxf::Entity.
Example usage:
This class is not thread-safe.
This is an experimental feature. The API may change in future releases.
Example
Constructors
OperatorRunner
Construct a new Operator Runner object.
Parameters
The operator to run.
Methods
op
Get the operator.
Returns: The shared pointer to the operator.
push_input
Overload 1
Overload 2
Single item (1)
Single item (2)
Push data to the specified input port of the operator.
This method takes a GXF entity and pushes it to the input port identified by port_name. The entity will be available to the operator during its next compute cycle.
Returns: A holoscan::expected containing either:void if successful A holoscan::RuntimeError if the input port is not found
Parameters
The name of the input port.
The entity to push to the input port.
run
Executes one compute cycle of the operator.
Internally, it calls the compute() method of the operator via the GXFWrapper’s tick() method.
pop_output
Overload 1
Pop data of a specified type from the output port
Retrieves and removes an entity from the specified output port.
This method retrieves and removes an entity from the output port identified by port_name. The entity is removed from the output port and returned.
Returns: The entity popped from the output port.
Parameters
The name of the output port.