Class Operator
Defined in File operator.hpp
Base Type
public holoscan::ComponentBase
(Class ComponentBase)
Derived Types
public holoscan::ops::AJASourceOp
(Class AJASourceOp)public holoscan::ops::AsyncPingRxOp
(Class AsyncPingRxOp)public holoscan::ops::AsyncPingTxOp
(Class AsyncPingTxOp)public holoscan::ops::BayerDemosaicOp
(Class BayerDemosaicOp)public holoscan::ops::FormatConverterOp
(Class FormatConverterOp)public holoscan::ops::ForwardOp
(Class ForwardOp)public holoscan::ops::GXFOperator
(Class GXFOperator)public holoscan::ops::HolovizOp
(Class HolovizOp)public holoscan::ops::InferenceOp
(Class InferenceOp)public holoscan::ops::InferenceProcessorOp
(Class InferenceProcessorOp)public holoscan::ops::PingRxOp
(Class PingRxOp)public holoscan::ops::PingTxOp
(Class PingTxOp)public holoscan::ops::SegmentationPostprocessorOp
(Class SegmentationPostprocessorOp)public holoscan::ops::V4L2VideoCaptureOp
(Class V4L2VideoCaptureOp)public holoscan::ops::VideoStreamRecorderOp
(Class VideoStreamRecorderOp)public holoscan::ops::VideoStreamReplayerOp
(Class VideoStreamReplayerOp)public holoscan::ops::VirtualOperator
(Class VirtualOperator)
- class Operator : public holoscan::ComponentBase
-
enum class OperatorType
Operator type used by the executor.
Values:
-
enumerator kNative
-
enumerator kGXF
-
enumerator kVirtual
-
enumerator kNative
-
template<typename ArgT, typename ...ArgsT, typename = std::enable_if_t<!std::is_base_of_v<holoscan::Operator, std::decay_t<ArgT>> && (std::is_same_v<holoscan::Arg, std::decay_t<ArgT>> || std::is_same_v<holoscan::ArgList, std::decay_t<ArgT>> || std::is_base_of_v<holoscan::Condition, typename holoscan::type_info<ArgT>::derived_type> || std::is_base_of_v<holoscan::Resource, typename holoscan::type_info<ArgT>::derived_type>)>>
inline explicit Operator(ArgT &&arg, ArgsT&&... args) Construct a new Operator object.
- Parameters
-
Operator() = default
-
~Operator() override = default
-
inline OperatorType operator_type() const
Get the operator type.
- Returns
-
inline Operator &name(const std::string &name)
Set the name of the operator.
- Parameters
- Returns
Set the operator spec.
- Parameters
- Returns
-
inline OperatorSpec *spec()
Get the operator spec.
- Returns
Get the shared pointer to the operator spec.
- Returns
Get a shared pointer to the Condition object.
- Parameters
- Returns
-
inline std::unordered_map<std::string, std::shared_ptr<Condition>> &conditions()
Get the conditions of the operator.
- Returns
Get a shared pointer to the Resource object.
- Parameters
- Returns
-
inline std::unordered_map<std::string, std::shared_ptr<Resource>> &resources()
Get the resources of the operator.
- Returns
Add a condition to the operator.
- Parameters
Add a condition to the operator.
- Parameters
Add a resource to the operator.
- Parameters
Add a resource to the operator.
- Parameters
-
inline virtual void setup(OperatorSpec &spec)
Define the operator specification.
- Parameters
-
bool is_root()
Returns whether the operator is a root operator based on its fragment’s graph.
- Returns
-
bool is_user_defined_root()
Returns whether the operator is a user-defined root operator i.e., the first operator added to the graph.
- Returns
-
bool is_leaf()
Returns whether the operator is a leaf operator based on its fragment’s graph.
- Returns
-
virtual void initialize() override
-
inline virtual void start()
-
inline virtual void stop()
-
inline virtual void compute(InputContext &op_input, OutputContext &op_output, ExecutionContext &context)
Implement the compute method.
This method is called by the runtime multiple times. The runtime calls this method until the operator is stopped.
- Parameters
-
virtual YAML::Node to_yaml_node() const override
Get a YAML representation of the operator.
- Returns
-
inline std::shared_ptr<nvidia::gxf::GraphEntity> graph_entity()
Get the GXF GraphEntity object corresponding to this operator.
- Returns
-
inline int64_t id() const
Get the identifier of the component.
By default, the identifier is set to -1. It is set to a valid value when the component is initialized.
With the default executor (GXFExecutor), the identifier is set to the GXF component ID.
- Returns
-
inline const std::string &name() const
Get the name of the component.
- Returns
-
inline void add_arg(const Arg &arg)
Add an argument to the component.
- Parameters
-
inline void add_arg(Arg &&arg)
Add an argument to the component.
- Parameters
-
inline void add_arg(const ArgList &arg)
Add a list of arguments to the component.
- Parameters
-
inline void add_arg(ArgList &&arg)
Add a list of arguments to the component.
- Parameters
-
template<typename typeT>
static inline void register_converter() Register the argument setter for the given type.
If the operator has an argument with a custom type, the argument setter must be registered using this method.
The argument setter is used to set the value of the argument from the YAML configuration.
This method can be called in the initialization phase of the operator (e.g.,
initialize()
). The example below shows how to register the argument setter for the custom type (Vec3
):It is assumed that
YAML::convert<T>::encode
andYAML::convert<T>::decode
are implemented for the given type. You need to specialize theYAML::convert<>
template class.For example, suppose that you had a
Vec3
class with the following members:You can define the
YAML::convert<Vec3>
as follows in a ‘.cpp’ file:Please refer to the yaml-cpp documentation for more details.
- Template Parameters
-
static std::pair<std::string, std::string> parse_port_name(const std::string &op_port_name)
-
template<typename typeT>
static inline void register_codec(const std::string &codec_name, bool overwrite = true) Register the codec for serialization/deserialization of a custom type.
If the operator has an argument with a custom type, the codec must be registered using this method.
For example, suppose we want to emit using the following custom struct type:
Then, we can define codec<Coordinate> as follows where the serialize and deserialize methods would be used for serialization and deserialization of this type, respectively.
In this case, since this is a simple struct with a static size, we can use the existing serialize_trivial_type and deserialize_trivial_type implementations.
Finally, to register this custom codec at runtime, we need to make the following call within the setup method of our Operator.
- Template Parameters
- Parameters
-
gxf_uid_t initialize_graph_entity(void *context, const std::string &entity_prefix = "")
This function creates a GraphEntity corresponding to the operator.
- Parameters
- Returns
-
virtual gxf_uid_t add_codelet_to_graph_entity()
Add this operator as the codelet in the GXF GraphEntity.
- Returns
-
void initialize_conditions()
-
void initialize_resources()
-
void update_params_from_args()
-
virtual void set_parameters()
-
MessageLabel get_consolidated_input_label()
This function returns a consolidated MessageLabel for all the input ports of an Operator. If there is no input port (root Operator), then a new MessageLabel with the current Operator and default receive timestamp is returned.
- Returns
-
inline void update_input_message_label(std::string input_name, MessageLabel m)
Update the input_message_labels map with the given MessageLabel a corresponding input_name.
- Parameters
-
inline void delete_input_message_label(std::string input_name)
Delete the input_message_labels map entry for the given input_name.
- Parameters
-
inline void reset_input_message_labels()
-
inline std::map<std::string, uint64_t> num_published_messages_map()
Get the number of published messages for each output port indexed by the output port name.
The function is utilized by the DFFTCollector to update the DataFlowTracker with the number of published messages for root operators.
- Returns
-
void update_published_messages(std::string output_name)
This function updates the number of published messages for a given output port.
- Parameters
-
virtual void reset_graph_entities()
-
void update_params_from_args(std::unordered_map<std::string, ParameterWrapper> ¶ms)
-
OperatorType operator_type_ = OperatorType::kNative
-
std::shared_ptr<OperatorSpec> spec_
-
std::unordered_map<std::string, std::shared_ptr<Condition>> conditions_
-
std::unordered_map<std::string, std::shared_ptr<Resource>> resources_
-
std::shared_ptr<nvidia::gxf::GraphEntity> graph_entity_
-
template<typename typeT>
static inline void register_argument_setter() Register the argument setter for the given type.
Please refer to the documentation of
register_converter()
for more details.- Template Parameters
- friend class AnnotatedDoubleBufferReceiver
- friend class AnnotatedDoubleBufferTransmitter
- friend class DFFTCollector
- friend class holoscan::gxf::GXFExecutor
- friend class Fragment
Base class for all operators.
An operator is the most basic unit of work in Holoscan SDK. An Operator receives streaming data at an input port, processes it, and publishes it to one of its output ports.
This class is the base class for all operators. It provides the basic functionality for all operators.
Subclassed by holoscan::ops::AJASourceOp, holoscan::ops::AsyncPingRxOp, holoscan::ops::AsyncPingTxOp, holoscan::ops::BayerDemosaicOp, holoscan::ops::FormatConverterOp, holoscan::ops::ForwardOp, holoscan::ops::GXFOperator, holoscan::ops::HolovizOp, holoscan::ops::InferenceOp, holoscan::ops::InferenceProcessorOp, holoscan::ops::PingRxOp, holoscan::ops::PingTxOp, holoscan::ops::SegmentationPostprocessorOp, holoscan::ops::V4L2VideoCaptureOp, holoscan::ops::VideoStreamRecorderOp, holoscan::ops::VideoStreamReplayerOp, holoscan::ops::VirtualOperator
Public Types
Public Functions
Public Static Functions
Protected Functions
Protected Attributes
Protected Static Functions
Friends