For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
  • Introduction
    • Overview
    • Relevant Technologies
    • Getting Started
  • Setup
    • SDK Installation
    • Additional Setup
    • Third Party Hardware Setup
  • Using the SDK
    • Holoscan Core
    • GPU Resident Execution
    • Holoscan by Example
    • Create an Application
    • Create a Distributed Application
    • Create an Operator
    • Create an Operator via Decorator
    • Create a Condition
    • Dynamic Flow Control
    • CUDA Stream Handling
    • Logging
    • Data Logging
    • Debugging
    • Python Operator Bindings
  • Operators
    • Operators and Extensions
    • Visualization
    • Inference
    • Testing
    • Video I/O Vendor Implementation Guide
  • Components
    • Schedulers
    • Conditions
    • Resources
    • Analytics
  • AI Skills
    • Ai Skills
  • API reference
              • AsyncPingRxOp
              • AsyncPingTxOp
              • BayerDemosaicGpuResidentOp
              • BayerDemosaicOp
              • DataTypeRxTestOp
              • DataTypeTxTestOp
              • FormatConverterOp
              • ForwardOp
              • GPUResidentInferenceOp
              • GXFCodeletOp
              • GXFOperator
              • HolovizOp
              • InferenceOp
              • InferenceProcessorOp
              • OperatorRunner
              • PingRxOp
              • PingTensorRxOp
              • PingTensorTxOp
              • PingTxOp
              • PoseTreeManagerLookupOp
              • RawImageProcessorOp
              • SegmentationPostprocessorOp
              • V4L2VideoCaptureOp
              • VideoAcquisitionOperator
              • VideoStreamRecorderOp
              • VideoStreamReplayerOp
              • VideoTransmissionOperator
              • VirtualOperator
              • VirtualReceiverOp
              • VirtualTransmitterOp
  • Performance
    • Performance Considerations
    • Flow Tracking
    • GXF Job Statistics
    • Nsight Profiling
  • HoloHub
    • HoloHub Overview
  • FAQ
    • FAQ
NVIDIANVIDIA
Developer-friendly docs for your API
Privacy Policy | Your Privacy Choices | Terms of Service | Accessibility | Corporate Policies | Product Security | Contact

Copyright © 2026, NVIDIA Corporation.

LogoLogoDocumentation
On this page
  • Constructors
  • FormatConverterOp
  • Methods
  • setup
  • initialize
  • start
  • compute
  • stop
  • resizeImage
  • convertTensorFormat
  • operator_type
  • id
  • name
  • fragment
  • spec
  • spec_shared
  • condition
  • conditions
  • resource
  • resources
  • add_arg
  • is_root
  • is_user_defined_root
  • is_leaf
  • qualified_name
  • to_yaml_node
  • graph_entity
  • get_data_flow_tracking_label
  • metadata
  • is_metadata_enabled
  • enable_metadata
  • metadata_policy
  • receiver
  • transmitter
  • bind_input_topic
  • bind_output_topic
  • input_topic
  • output_topic
  • input_qos
  • output_qos
  • queue_policy
  • input_exec_spec
  • output_exec_spec
  • dynamic_flow_func
  • self_shared
  • next_flows
  • add_dynamic_flow
  • dynamic_flows
  • find_flow_info
  • find_all_flow_info
  • async_condition
  • stop_execution
  • execution_context
  • ensure_contexts
  • release_internal_resources
  • operator
  • defaults
  • is_gxf_compatible_operator_type
  • operator std::shared_ptr< Executor > executor
  • has_pubsub_connector
  • has_network_connector
  • args
  • description
  • service
  • get_service_by_type_info
  • reset_backend_objects
  • initialize_graph_entity
  • initialize_async_condition
  • add_codelet_to_graph_entity
  • initialize_conditions
  • initialize_resources
  • update_params_from_args
  • update_connector_arguments
  • find_ports_used_by_condition_args
  • get_consolidated_input_label
  • update_input_message_label
  • delete_input_message_label
  • reset_input_message_labels
  • has_input_message_labels
  • num_published_messages_map
  • update_published_messages
  • operator.void initialize_next_flows
  • non_default_input_ports
  • non_default_output_ports
  • set_input_exec_spec
  • set_output_exec_spec
  • set_dynamic_flows
  • set_self_shared
  • initialize_execution_context
  • service_provider
  • Static methods
  • is_all_operator_successor_virtual
  • is_all_operator_predecessor_virtual
  • parse_port_name
  • parse_operator_port_key
  • register_codec
  • validate_operator_name
  • register_converter
  • register_argument_setter
  • Types
  • OperatorType
  • Member variables
API referenceC++ APIHoloscanNamespacesOpsClasses

holoscan::ops::FormatConverterOp

Beta
||View as Markdown|
Previous

holoscan::ops::DataTypeTxTestOp

Next

holoscan::ops::ForwardOp

Operator class to convert the data format of the input data.

==Named Inputs==

  • source_video : nvidia::gxf::Tensor or nvidia::gxf::VideoBuffer The input video frame to process. If the input is a VideoBuffer it must be in format GXF_VIDEO_FORMAT_RGBA, GXF_VIDEO_FORMAT_RGB or GXF_VIDEO_FORMAT_NV12, GXF_VIDEO_FORMAT_NV12_ER, GXF_VIDEO_FORMAT_NV12_709 or GXF_VIDEO_FORMAT_NV12_709_ER. If a video buffer is not found, the input port message is searched for a tensor with the name specified by in_tensor_name. This must be a tensor in one of several supported formats (unsigned 8-bit int or float32 graycale, unsigned 8-bit int RGB or RGBA YUV420, NV12BT601Full, NV12BT709CSC, NV12BT709HDTV, or YUYV). The tensor or video buffer may be in either host or device memory (a host->device copy is performed if needed).
    • The input video frame to process. If the input is a VideoBuffer it must be in format GXF_VIDEO_FORMAT_RGBA, GXF_VIDEO_FORMAT_RGB or GXF_VIDEO_FORMAT_NV12, GXF_VIDEO_FORMAT_NV12_ER, GXF_VIDEO_FORMAT_NV12_709 or GXF_VIDEO_FORMAT_NV12_709_ER. If a video buffer is not found, the input port message is searched for a tensor with the name specified by in_tensor_name. This must be a tensor in one of several supported formats (unsigned 8-bit int or float32 graycale, unsigned 8-bit int RGB or RGBA YUV420, NV12BT601Full, NV12BT709CSC, NV12BT709HDTV, or YUYV). The tensor or video buffer may be in either host or device memory (a host->device copy is performed if needed).

==Named Outputs==

  • tensor : nvidia::gxf::Tensor The output video frame after processing. The shape, data type and number of channels of this output tensor will depend on the specific parameters that were set for this operator. The name of the Tensor transmitted on this port is determined by out_tensor_name.
    • The output video frame after processing. The shape, data type and number of channels of this output tensor will depend on the specific parameters that were set for this operator. The name of the Tensor transmitted on this port is determined by out_tensor_name.

==Parameters==

  • pool: Memory pool allocator (holoscan::Allocator) used by the operator.
  • out_dtype: Destination data type. The available options are: “rgb888” “uint8” “float32” “rgba8888” “yuv420”
    • "rgb888"
    • "uint8"
    • "float32"
    • "rgba8888"
    • "yuv420"
  • in_dtype: Source data type. The available options are: “rgb888” “uint8” “float32” “rgba8888” “yuv420” “nv12” (alias for nv12_bt709_hdtv) “nv12_bt601_full” (BT.601 full range as in NPP’s NV12ToRGB functions and IPP’s YUVToRGB) “nv12_bt709_hdtv” (BT.709 recommendation for high-definition TV (HDTV)) “nv12_bt709_csc” (BT.709 recommendation for computer systems consideration (CSC)) “yuyv” “rgb161616” “rgba16161616” Optional (default: “rgb888”).
    • "rgb888"
    • "uint8"
    • "float32"
    • "rgba8888"
    • "yuv420"
    • "nv12" (alias for nv12_bt709_hdtv)
    • "nv12_bt601_full" (BT.601 full range as in NPP’s NV12ToRGB functions and IPP’s YUVToRGB)
    • "nv12_bt709_hdtv" (BT.709 recommendation for high-definition TV (HDTV))
    • "nv12_bt709_csc" (BT.709 recommendation for computer systems consideration (CSC))
    • "yuyv"
    • "rgb161616"
    • "rgba16161616" Optional (default: "rgb888").
  • in_tensor_name: The name of the input tensor (or VideoBuffer). Optional (default: "").
  • out_tensor_name: The name of the output tensor. Optional (default: "").
  • scale_min: Output will be clipped to this minimum value. Optional (default: 0.0).
  • scale_max: Output will be clipped to this maximum value. Optional (default: 1.0).
  • alpha_value: Unsigned integer in range [0, 255], indicating the alpha channel value to use when converting from RGB to RGBA. Optional (default: 255).
  • resize_height: Desired height for the (resized) output. Height will be unchanged if resize_height is 0. Optional (default: 0).
  • resize_width: Desired width for the (resized) output. Width will be unchanged if resize_width is 0. Optional (default: 0).
  • resize_mode: Resize mode enum value corresponding to NPP’s NppiInterpolationMode. Values available at: https://docs.nvidia.com/cuda/npp/nppdefs.html?highlight=Two%20parameter%20cubic%20filter#c.NppiInterpolationMode NPPI_INTER_UNDEFINED (0): Undefined filtering interpolation mode. NPPI_INTER_NN (1): Nearest neighbor filtering. NPPI_INTER_LINEAR (2): Linear interpolation. NPPI_INTER_CUBIC (4): Cubic interpolation. NPPI_INTER_CUBIC2P_BSPLINE (5): Two-parameter cubic filter (B=1, C=0) NPPI_INTER_CUBIC2P_CATMULLROM (6): Two-parameter cubic filter (B=0, C=1/2) NPPI_INTER_CUBIC2P_B05C03 (7): Two-parameter cubic filter (B=1/2, C=3/10) NPPI_INTER_SUPER (8): Super sampling. NPPI_INTER_LANCZOS (16): Lanczos filtering. NPPI_INTER_LANCZOS3_ADVANCED (17): Generic Lanczos filtering with order 3. NPPI_SMOOTH_EDGE (0x8000000): Smooth edge filtering.
    • NPPI_INTER_UNDEFINED (0): Undefined filtering interpolation mode.
    • NPPI_INTER_NN (1): Nearest neighbor filtering.
    • NPPI_INTER_LINEAR (2): Linear interpolation.
    • NPPI_INTER_CUBIC (4): Cubic interpolation.
    • NPPI_INTER_CUBIC2P_BSPLINE (5): Two-parameter cubic filter (B=1, C=0)
    • NPPI_INTER_CUBIC2P_CATMULLROM (6): Two-parameter cubic filter (B=0, C=1/2)
    • NPPI_INTER_CUBIC2P_B05C03 (7): Two-parameter cubic filter (B=1/2, C=3/10)
    • NPPI_INTER_SUPER (8): Super sampling.
    • NPPI_INTER_LANCZOS (16): Lanczos filtering.
    • NPPI_INTER_LANCZOS3_ADVANCED (17): Generic Lanczos filtering with order 3.
    • NPPI_SMOOTH_EDGE (0x8000000): Smooth edge filtering. Optional (default: 0). The default value 0 (NPPI_INTER_UNDEFINED) which would be equivalent to 4 (NPPI_INTER_CUBIC).
  • out_channel_order: Sequence of integers describing how channel values are permuted. Optional (default: [0, 1, 2] for 3-channel images and [0, 1, 2, 3] for 4-channel images).
  • cuda_stream_pool: holoscan::CudaStreamPool instance to allocate CUDA streams. Optional (default: nullptr).

==Device Memory Requirements==

When using this operator with a BlockMemoryPool, between 1 and 3 device memory blocks (storage_type = 1) will be required based on the input tensors and parameters:

  • 1.) In all cases there is a memory block needed for the output tensor. The size of this block will be out_height * out_width * out_channels * out_element_size_bytes where (out_height, out_width) will either be (in_height, in_width) (or (resize_height, resize_width) a resize was specified). out_element_size is the element size in bytes (e.g. 1 for RGB888 or 4 for Float32).
  • 2.) If a resize is being done, another memory block is required for this. This block will have size resize_height * resize_width * in_channels * in_element_size_bytes.
  • 3.) If the input tensor will be in host memory, a memory block is needed to copy the input to the device. This block will have size in_height * in_width * in_channels * in_element_size_bytes.

Thus when declaring the memory pool, num_blocks should be between 1-3 and block_size should be set to the maximum of the individual blocks sizes described above.

==Notes==

This operator may launch CUDA kernels that execute asynchronously on a CUDA stream. As a result, the compute method may return before all GPU work has completed. Downstream operators that receive data from this operator should either:

  • Call op_input.receive_cuda_stream(<port_name>) (after calling receive for that port) to synchronize the CUDA stream with the downstream operator’s dedicated internal stream before accessing the data.
  • Add a CudaStreamCondition to delay scheduling until upstream GPU work has completed.

For more details on CUDA stream handling in Holoscan, see the {ref}CUDA Stream Handling in Holoscan Applications <holoscan-cuda-stream-handling> section of the Holoscan SDK documentation.

#include <holoscan/ops/format_converter.hpp>

Inherits from: holoscan::Operator (public)


Constructors

FormatConverterOp

holoscan::ops::FormatConverterOp::FormatConverterOp() = defaultholoscan::ops::FormatConverterOp::FormatConverterOp() = default

Methods

setup

void holoscan::ops::FormatConverterOp::setup(
OperatorSpec &spec
) override

Define the operator specification.

Parameters

spec
OperatorSpec &

The reference to the operator specification.

initialize

void holoscan::ops::FormatConverterOp::initialize() override

Initialize the component.

This method is called only once when the component is created for the first time, and use of light-weight initialization.

start

void holoscan::ops::FormatConverterOp::start() override

Implement the startup logic of the operator.

This method is called multiple times over the lifecycle of the operator according to the order defined in the lifecycle, and used for heavy initialization tasks such as allocating memory resources.

compute

void holoscan::ops::FormatConverterOp::compute(
InputContext &op_input,
OutputContext &op_output,
ExecutionContext &context
) override

Implement the compute method.

This method is called by the runtime multiple times. The runtime calls this method until the operator is stopped.

Parameters

op_input
InputContext &

The input context of the operator.

op_output
OutputContext &

The output context of the operator.

context
ExecutionContext &

The execution context of the operator.

stop

void holoscan::ops::FormatConverterOp::stop() override

Implement the shutdown logic of the operator.

This method is called multiple times over the lifecycle of the operator according to the order defined in the lifecycle, and used for heavy deinitialization tasks such as deallocation of all resources previously assigned in start.

resizeImage

nvidia::gxf::Expected<void *> holoscan::ops::FormatConverterOp::resizeImage(
const void *in_tensor_data,
const std::vector<nvidia::gxf::ColorPlane> &in_color_planes,
const int32_t rows,
const int32_t columns,
const int16_t channels,
const nvidia::gxf::PrimitiveType primitive_type,
const int32_t resize_width,
const int32_t resize_height
)

convertTensorFormat

void holoscan::ops::FormatConverterOp::convertTensorFormat(
const void *in_tensor_data,
const std::vector<nvidia::gxf::ColorPlane> &in_color_planes,
void *out_tensor_data,
const int32_t rows,
const int32_t columns,
const int16_t out_channels
)

operator_type

OperatorType holoscan::ops::FormatConverterOp::operator_type() constOperatorType holoscan::ops::FormatConverterOp::operator_type() const

Get the operator type.

Returns: The operator type.

id

Mutable
Const
Operator & holoscan::ops::FormatConverterOp::id(Operator & holoscan::ops::FormatConverterOp::id(
int64_t id
)

Set the Operator ID.

Returns: The reference to this operator.

Parameters

id
int64_t

The ID of the operator.

name

Mutable
Const
Operator & holoscan::ops::FormatConverterOp::name(Operator & holoscan::ops::FormatConverterOp::name(
const std::string &name
)

Set the name of the operator.

Returns: The reference to this operator.

Parameters

name
const std::string &

The name of the operator.

fragment

Set the fragment of the operator
Overload 2
Const
Operator & holoscan::ops::FormatConverterOp::fragment(Operator & holoscan::ops::FormatConverterOp::fragment(
Fragment *fragment
)

Set the fragment of the operator.

Returns: The reference to this operator.

Parameters

fragment
Fragment *

The pointer to the fragment of the operator.

spec

Set the operator spec
Get the operator spec
Operator & holoscan::ops::FormatConverterOp::spec(Operator & holoscan::ops::FormatConverterOp::spec(
const std::shared_ptr<OperatorSpec> &spec
)

Set the operator spec.

Returns: The reference to this operator.

Parameters

spec
const std::shared_ptr<OperatorSpec> &

The operator spec.

spec_shared

std::shared_ptr<OperatorSpec> holoscan::ops::FormatConverterOp::spec_shared()std::shared_ptr<OperatorSpec> holoscan::ops::FormatConverterOp::spec_shared()

Get the shared pointer to the operator spec.

Returns: The shared pointer to the operator spec.

condition

template <typename ConditionT>
std::shared_ptr<ConditionT> holoscan::ops::FormatConverterOp::condition(
const std::string &name
)

Get a shared pointer to the Condition object.

Returns: The reference to the Condition object. If the condition does not exist, return the nullptr.

Parameters

name
const std::string &

The name of the condition.

conditions

std::unordered_map<std::string, std::shared_ptr<Condition>> & holoscan::ops::FormatConverterOp::conditions()std::unordered_map<std::string, std::shared_ptr<Condition>> & holoscan::ops::FormatConverterOp::conditions()

Get the conditions of the operator.

Returns: The conditions of the operator.

resource

template <typename ResourceT>
std::shared_ptr<ResourceT> holoscan::ops::FormatConverterOp::resource(
const std::string &name
)

Get a shared pointer to the Resource object.

Returns: The reference to the Resource object. If the resource does not exist, returns the nullptr.

Parameters

name
const std::string &

The name of the resource.

resources

std::unordered_map<std::string, std::shared_ptr<Resource>> & holoscan::ops::FormatConverterOp::resources()std::unordered_map<std::string, std::shared_ptr<Resource>> & holoscan::ops::FormatConverterOp::resources()

Get the resources of the operator.

Returns: The resources of the operator.

add_arg

Add a condition to the operator (1)
Add a condition to the operator (2)
Add a resource to the operator (1)
Add a resource to the operator (2)
Add an argument to the component (1)
Add an argument to the component (2)
Add a list of arguments to the component (1)
Add a list of arguments to the component (2)
void holoscan::ops::FormatConverterOp::add_arg(
const std::shared_ptr<Condition> &arg
)

Add a condition to the operator.

Parameters

arg
const std::shared_ptr<Condition> &

The condition to add.

is_root

bool holoscan::ops::FormatConverterOp::is_root()

Returns whether the operator is a root operator based on its fragment’s graph.

Returns: True, if the operator is a root operator; false, otherwise

is_user_defined_root

bool holoscan::ops::FormatConverterOp::is_user_defined_root()

Returns whether the operator is a user-defined root operator i.e., the first operator added to the graph.

Returns: True, if the operator is a user-defined root operator; false, otherwise

is_leaf

bool holoscan::ops::FormatConverterOp::is_leaf()

Returns whether the operator is a leaf operator based on its fragment’s graph.

Returns: True, if the operator is a leaf operator; false, otherwise

qualified_name

std::string holoscan::ops::FormatConverterOp::qualified_name() const

Returns the fully qualified name of the operator including the name of the fragment.

Returns: std::string fully qualified name of the operator in the format: “<fragment_name>.<operator_name>“

to_yaml_node

YAML::Node holoscan::ops::FormatConverterOp::to_yaml_node() const override

Get a YAML representation of the operator.

Returns: YAML node including type, specs, conditions and resources of the operator in addition to the base component properties.

graph_entity

std::shared_ptr<nvidia::gxf::GraphEntity> holoscan::ops::FormatConverterOp::graph_entity()

Get the GXF GraphEntity object corresponding to this operator.

Returns: graph entity corresponding to the operator

get_data_flow_tracking_label

MessageLabel holoscan::ops::FormatConverterOp::get_data_flow_tracking_label(MessageLabel holoscan::ops::FormatConverterOp::get_data_flow_tracking_label(
const std::string &input_port_name
)

Get the current message label for a given input port.

This method retrieves the MessageLabel associated with data received on the specified input port. The MessageLabel contains timing and path information for data flow tracking.

This method should ideally be called after receiving data on the input port.

If the input_port_name is invalid (not found in the operator’s input ports), an error is logged and an empty MessageLabel is returned.

Returns: MessageLabel The current message label for the input port. Returns an empty MessageLabel if the port does not have a message label or if the port does not exist (logs an error in the latter case as well).

Throws: std::runtime_error If the operator backend is not GXF-compatible.

Throws: std::runtime_error If fragment is not set.

Throws: std::runtime_error If operator spec is not set.

Throws: std::runtime_error If fragment flow tracking is not enabled.

Parameters

input_port_name
const std::string &

The name of the input port.

metadata

std::shared_ptr<MetadataDictionary> holoscan::ops::FormatConverterOp::metadata()std::shared_ptr<MetadataDictionary> holoscan::ops::FormatConverterOp::metadata()

Get a shared pointer to the dynamic metadata of this operator.

Note: currently this metadata dictionary is only active if explicitly enabled for the application by setting Fragment::is_metadata_enabled(true). When metadata is disabled the dictionary will not be populated by receive calls and will not be emitted on emit calls.

This metadata dictionary is always empty at the start of each compute call. It is populated by metadata received on input ports during InputContext::receive() calls and can be modified as desired by the operator during the compute call. Any metadata corresponding to this object will be sent on the output ports by any OutputContext::emit() calls.

Returns: The metadata dictionary for this operator.

is_metadata_enabled

bool holoscan::ops::FormatConverterOp::is_metadata_enabled() const

Determine if metadata is enabled for this operator.

Returns: Boolean indicating if metadata is enabled (returns fragment()``->``is_metadata_enabled() if enable_metadata was not explicitly called for the operator.

enable_metadata

void holoscan::ops::FormatConverterOp::enable_metadata(
bool enable
)

Enable or disable metadata for this operator.

If this method has not been used to explicitly enable or disable metadata, the value for is_metadata_enabled() will be determined by Fragment::is_metadata_enabled() when the operator is initialized.

Parameters

enable
bool

Boolean indicating if metadata should be enabled.

metadata_policy

Mutable
Const
void holoscan::ops::FormatConverterOp::metadata_policy(
MetadataPolicy policy
)

Set the metadata update policy used by this operator.

The metadata policy determines how metadata is merged across multiple receive calls:

  • MetadataPolicy::kUpdate: Update the existing value when a key already exists.
  • MetadataPolicy::kInplaceUpdate: Update the existing MetadataObject’s value in-place when a key already exists.
  • MetadataPolicy::kReject: Do not modify the existing value if a key already exists.
  • MetadataPolicy::kRaise: Raise an exception if a key already exists (default).

Parameters

policy
MetadataPolicy

The metadata update policy to be used by this operator.

receiver

std::optional<std::shared_ptr<Receiver>> holoscan::ops::FormatConverterOp::receiver(std::optional<std::shared_ptr<Receiver>> holoscan::ops::FormatConverterOp::receiver(
const std::string &port_name
)

If no CudaStreamPool parameter or argument already exists, add a default one.

This method is available to be called by derived classes to add a default CudaStreamPool in This method is available to be called by derived classes to add a default CudaStreamPool inthe case that the user did not pass one in as an argument tomake_operator`.

This function will not add an additional CUDA stream pool if one was already passed in as an argument to make_operator (i.e. it is in resources_) or if a “cuda_stream_pool” parameter already exists in the operator spec.

/** Return the Receiver corresponding to a specific input port.

Returns: The Receiver corresponding to the input port, if it exists. Otherwise, return nullopt.

Parameters

port_name
const std::string &

The name of the input port.

transmitter

std::optional<std::shared_ptr<Transmitter>> holoscan::ops::FormatConverterOp::transmitter(std::optional<std::shared_ptr<Transmitter>> holoscan::ops::FormatConverterOp::transmitter(
const std::string &port_name
)

Return the Transmitter corresponding to a specific output port.

Returns: The Transmitter corresponding to the output port, if it exists. Otherwise, return nullopt.

Parameters

port_name
const std::string &

The name of the output port.

bind_input_topic

void holoscan::ops::FormatConverterOp::bind_input_topic(
const std::string &port_name,
const std::string &topic,
const std::optional<nvidia::gxf::QoSProfile> &qos = std::nullopt,
bool replace_connector = false
)

Bind an input port to a Pub/Sub topic.

This is the programmatic override path for topic-mapped ports and takes precedence over any lower-priority IOSpec::topic() default configured in setup().

Parameters

port_name
const std::string &

The input port to bind.

topic
const std::string &

The topic name to subscribe to.

qos
const std::optional<nvidia::gxf::QoSProfile> &Defaults to std::nullopt

Optional QoS profile override. When nullopt, any QoS already configured on the port (e.g. in setup()) is preserved.

replace_connector
boolDefaults to false

If true, replace an explicitly non-PubSub connector on this port with a Pub/Sub connector.

bind_output_topic

void holoscan::ops::FormatConverterOp::bind_output_topic(
const std::string &port_name,
const std::string &topic,
const std::optional<nvidia::gxf::QoSProfile> &qos = std::nullopt,
bool replace_connector = false
)

Bind an output port to a Pub/Sub topic.

This is the programmatic override path for topic-mapped ports and takes precedence over any lower-priority IOSpec::topic() default configured in setup().

Parameters

port_name
const std::string &

The output port to bind.

topic
const std::string &

The topic name to publish to.

qos
const std::optional<nvidia::gxf::QoSProfile> &Defaults to std::nullopt

Optional QoS profile override. When nullopt, any QoS already configured on the port (e.g. in setup()) is preserved.

replace_connector
boolDefaults to false

If true, replace an explicitly non-PubSub connector on this port with a Pub/Sub connector.

input_topic

std::optional<std::string> holoscan::ops::FormatConverterOp::input_topic(
const std::string &port_name
) const

Get the configured topic name for an input port, if any.

output_topic

std::optional<std::string> holoscan::ops::FormatConverterOp::output_topic(
const std::string &port_name
) const

Get the configured topic name for an output port, if any.

input_qos

std::optional<nvidia::gxf::QoSProfile> holoscan::ops::FormatConverterOp::input_qos(
const std::string &port_name
) const

Get the effective QoS profile for an input port, if it is topic-mapped.

output_qos

std::optional<nvidia::gxf::QoSProfile> holoscan::ops::FormatConverterOp::output_qos(
const std::string &port_name
) const

Get the effective QoS profile for an output port, if it is topic-mapped.

queue_policy

void holoscan::ops::FormatConverterOp::queue_policy(
const std::string &port_name,
IOSpec::IOType port_type = IOSpec::IOType::kInput,
IOSpec::QueuePolicy policy = IOSpec::QueuePolicy::kFault
)

Set the queue policy to be used by an input or output port.

The following IOSpec::QueuePolicy values are supported:

  • QueuePolicy::kPop - If the queue is full, pop the oldest item, then add the new one.
  • QueuePolicy::kReject - If the queue is full, reject (discard) the new item.
  • QueuePolicy::kFault - If the queue is full, log a warning and reject the new item.

Parameters

port_name
const std::string &

The name of the port.

port_type
IOSpec::IOTypeDefaults to IOSpec::IOType::kInput

Enum flag indicating whether port_name specifies an input or output port.

policy
IOSpec::QueuePolicyDefaults to IOSpec::QueuePolicy::kFault

The queue policy to set for the port.

input_exec_spec

const std::shared_ptr<IOSpec> & holoscan::ops::FormatConverterOp::input_exec_spec()const std::shared_ptr<IOSpec> & holoscan::ops::FormatConverterOp::input_exec_spec()

output_exec_spec

const std::shared_ptr<IOSpec> & holoscan::ops::FormatConverterOp::output_exec_spec()const std::shared_ptr<IOSpec> & holoscan::ops::FormatConverterOp::output_exec_spec()

dynamic_flow_func

const std::function<void(
const std::shared_ptr<Operator> &
)

self_shared

std::shared_ptr<Operator> holoscan::ops::FormatConverterOp::self_shared()std::shared_ptr<Operator> holoscan::ops::FormatConverterOp::self_shared()

next_flows

const std::vector<std::shared_ptr<FlowInfo>> & holoscan::ops::FormatConverterOp::next_flows()const std::vector<std::shared_ptr<FlowInfo>> & holoscan::ops::FormatConverterOp::next_flows()

Get the list of next flows connected to this operator.

Returns: A vector of FlowInfo objects representing the flows to downstream operators.

add_dynamic_flow

Overload 1
Overload 2
Overload 3
Overload 4
void holoscan::ops::FormatConverterOp::add_dynamic_flow(
const std::shared_ptr<FlowInfo> &flow
)

Add a dynamic flow from this operator to another operator using a FlowInfo object.

Parameters

flow
const std::shared_ptr<FlowInfo> &

The flow information object describing the connection between operators.

dynamic_flows

const std::shared_ptr<std::vector<std::shared_ptr<FlowInfo>>> & holoscan::ops::FormatConverterOp::dynamic_flows()const std::shared_ptr<std::vector<std::shared_ptr<FlowInfo>>> & holoscan::ops::FormatConverterOp::dynamic_flows()

Get the list of dynamic flows that have been added to this operator.

Returns: A shared pointer to a vector of FlowInfo objects representing the dynamic flows.

find_flow_info

const std::shared_ptr<Operator::FlowInfo> & holoscan::ops::FormatConverterOp::find_flow_info(const std::shared_ptr<Operator::FlowInfo> & holoscan::ops::FormatConverterOp::find_flow_info(const std::shared_ptr<Operator::FlowInfo> & holoscan::ops::FormatConverterOp::find_flow_info(
const std::function<bool(const std::shared_ptr<Operator::FlowInfo> &)> &predicate const std::function<bool(const std::shared_ptr<Operator::FlowInfo> &)> &predicate
)

Locate a flow info in the operator’s next flows based on a given predicate.

Returns: Shared pointer to the matching FlowInfo, or nullptr if not found.

Parameters

predicate
const std::function<bool(const std::shared_ptr<Operator::FlowInfo> &)> &

Lambda function that takes a FlowInfo shared pointer and returns a boolean.

find_all_flow_info

std::vector<std::shared_ptr<Operator::FlowInfo>> holoscan::ops::FormatConverterOp::find_all_flow_info(std::vector<std::shared_ptr<Operator::FlowInfo>> holoscan::ops::FormatConverterOp::find_all_flow_info(std::vector<std::shared_ptr<Operator::FlowInfo>> holoscan::ops::FormatConverterOp::find_all_flow_info(
const std::function<bool(const std::shared_ptr<Operator::FlowInfo> &)> &predicate const std::function<bool(const std::shared_ptr<Operator::FlowInfo> &)> &predicate
)

Find all FlowInfo objects in the operator’s next flows that match a given condition.

Returns: A vector of shared pointers to the matching FlowInfo objects.

Parameters

predicate
const std::function<bool(const std::shared_ptr<Operator::FlowInfo> &)> &

A lambda function that takes a shared pointer to a FlowInfo object and returns a boolean.

async_condition

std::shared_ptr<holoscan::AsynchronousCondition> holoscan::ops::FormatConverterOp::async_condition()std::shared_ptr<holoscan::AsynchronousCondition> holoscan::ops::FormatConverterOp::async_condition()

Get the internal asynchronous condition for the operator.

Note: This object is only accessible after the executor has called Operator::initialize() via run() or run_async(). If accessed during Application::compose(), it will return nullptr.

Returns: A shared pointer to the internal asynchronous condition.

stop_execution

void holoscan::ops::FormatConverterOp::stop_execution()

Stop the execution of the operator.

This method is used to stop the execution of the operator by setting the internal async condition to EVENT_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operator will not be scheduled for execution (the compute() method will not be called).

Note that executing this method does not trigger the operator’s stop() method. The stop() method is called only when the scheduler deactivates all operators together.

execution_context

virtual std::shared_ptr<holoscan::ExecutionContext> holoscan::ops::FormatConverterOp::execution_context() constvirtual std::shared_ptr<holoscan::ExecutionContext> holoscan::ops::FormatConverterOp::execution_context() const

Get the ExecutionContext object.

Returns: The shared pointer to the ExecutionContext object.

ensure_contexts

void holoscan::ops::FormatConverterOp::ensure_contexts()

Ensure the contexts (input/output/execution) for the operator.

This method is called by the GXFExecutor when the operator is initialized.

release_internal_resources

virtual void holoscan::ops::FormatConverterOp::release_internal_resources()

Internal method to clean up operator resources and prevent circular references.

This is an internal method called automatically by the GXFWrapper during operator shutdown (in GXFWrapper::stop() method). It resets std::shared_ptr fields and std::function objects such as input_exec_spec_, output_exec_spec_, next_flows_, dynamic_flows_, and dynamic_flow_func_ to break potential circular references between connected Operator objects.

This is an internal method that should never be called directly by user code. Improper use can lead to undefined behavior.

operator

*List of restricted substrings that cannot be used in holoscan::ops::FormatConverterOp::operator(
e.g. GXF GraphEntity
) override

defaults

*Set the parameters based on holoscan::ops::FormatConverterOp::defaults(
sets GXF parameters for GXF operators
)

is_gxf_compatible_operator_type

bool holoscan::ops::FormatConverterOp::is_gxf_compatible_operator_type() const

Check if the operator is a GXF compatible operator type.

This checks the OperatorType and returns true if it is one of {kNative, kGXF, kVirtual}.

Returns: True if the operator is a GXF compatible operator type, false otherwise.

operator std::shared_ptr< Executor > executor

*Get the executor of the holoscan::ops::FormatConverterOp::operator std::shared_ptr<Executor> executor()

has_pubsub_connector

*name Connector type queries *bool holoscan::ops::FormatConverterOp::has_pubsub_connector()

Check if the operator has any UCX connectors.

Check if the operator has any PubSub connectors.

has_network_connector

bool holoscan::ops::FormatConverterOp::has_network_connector()

Check if the operator has any network (UCX or PubSub) connectors.

args

std::vector<Arg> & holoscan::ComponentBase::args()

Get the list of arguments.

Returns: The vector of arguments.

description

std::string holoscan::ComponentBase::description() const

Get a description of the component.

Returns: YAML string.

See also: to_yaml_node()

service

template <typename ServiceT = DefaultFragmentService>
std::shared_ptr<ServiceT> holoscan::ComponentBase::service(
std::string_view id = ""
) const

Retrieve a registered fragment service or resource.

Retrieves a previously registered fragment service or resource by its type and optional identifier. Returns nullptr if no service/resource is found with the specified type and identifier.

Note that any changes to the service retrieval logic in this method should be synchronized with the implementation in Fragment::service() method to maintain consistency.

Returns: The shared pointer to the service/resource, or nullptr if not found or if type casting fails.

Template parameters

ServiceT
typename

The type of the service/resource to retrieve. Must inherit from either Resource or FragmentService. Defaults to DefaultFragmentService if not specified.

Parameters

id
std::string_viewDefaults to ""

The identifier of the service/resource. If empty, retrieves by type only.

get_service_by_type_info

std::shared_ptr<FragmentService> holoscan::ComponentBase::get_service_by_type_info(
const std::type_info &service_type,
std::string_view id = ""
) const

Retrieve a registered fragment service or resource for Python bindings.

This is a helper method for Python bindings to retrieve a service by its C++ type info.

Returns: The shared pointer to the base service, or nullptr if not found.

Parameters

service_type
const std::type_info &

The type info of the service/resource to retrieve.

id
std::string_viewDefaults to ""

The identifier of the service/resource. If empty, retrieves by type only.

reset_backend_objects

virtual void holoscan::ComponentBase::reset_backend_objects()

Reset any backend-specific objects (e.g. GXF GraphEntity).

initialize_graph_entity

gxf_uid_t holoscan::ops::FormatConverterOp::initialize_graph_entity(
void *context,
const std::string &entity_prefix = ""
)

This function creates a GraphEntity corresponding to the operator.

Returns: The GXF entity eid corresponding to the graph entity.

Parameters

context
void *

The GXF context.

entity_prefix
const std::string &Defaults to ""

Prefix to add to the operator’s name when creating the GraphEntity.

initialize_async_condition

void holoscan::ops::FormatConverterOp::initialize_async_condition()

Initialize the internal asynchronous condition to control the operator execution.

This method is called by the GXFExecutor when the operator is initialized.

add_codelet_to_graph_entity

virtual gxf_uid_t holoscan::ops::FormatConverterOp::add_codelet_to_graph_entity()

Add this operator as the codelet in the GXF GraphEntity.

Returns: The codelet component id corresponding to GXF codelet.

initialize_conditions

*Initialize conditions and add GXF conditions to graph_entity_ void holoscan::ops::FormatConverterOp::initialize_conditions()

initialize_resources

*Initialize resources and add GXF resources to graph_entity_ void holoscan::ops::FormatConverterOp::initialize_resources()

update_params_from_args

Overload 1
Update parameters based on the specified arguments
*Update parameters based on the specified arguments void holoscan::ops::FormatConverterOp::update_params_from_args()

update_connector_arguments

void holoscan::ops::FormatConverterOp::update_connector_arguments()

Replace any “receiver” supplied as a string with the actual receiver of that name.

Can only be called after GXFExecutor::create_input_port so the input ports (receivers) exist.

find_ports_used_by_condition_args

void holoscan::ops::FormatConverterOp::find_ports_used_by_condition_args()

Determine ports whose transmitter or receiver are associated with an Arg for a Condition.

Should be called before GXFExecutor::create_input_port or GXFExecutor::create_output_port.

get_consolidated_input_label

MessageLabel holoscan::ops::FormatConverterOp::get_consolidated_input_label()MessageLabel holoscan::ops::FormatConverterOp::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: The consolidated MessageLabel

update_input_message_label

void holoscan::ops::FormatConverterOp::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

input_name
std::string

The input port name for which the MessageLabel is updated

m
MessageLabel

The new MessageLabel that will be set for the input port

delete_input_message_label

void holoscan::ops::FormatConverterOp::delete_input_message_label(
const std::string &input_name
)

Delete the input_message_labels map entry for the given input_name.

Parameters

input_name
const std::string &

The input port name for which the MessageLabel is deleted

reset_input_message_labels

void holoscan::ops::FormatConverterOp::reset_input_message_labels()

Reset the input message labels to clear all its contents.

This is done for a leaf operator when it finishes its execution as it is assumed that all its inputs are processed.

has_input_message_labels

bool holoscan::ops::FormatConverterOp::has_input_message_labels()

Check if the operator has any input message labels.

num_published_messages_map

std::map<std::string, uint64_t> holoscan::ops::FormatConverterOp::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: The map of the number of published messages for every output name.

update_published_messages

void holoscan::ops::FormatConverterOp::update_published_messages(
const std::string &output_name
)

This function updates the number of published messages for a given output port.

Parameters

output_name
const std::string &

The name of the output port

operator.void initialize_next_flows

*Initialize the next flows for the holoscan::ops::FormatConverterOp::operator.void initialize_next_flows()

non_default_input_ports

std::vector<std::string> & holoscan::ops::FormatConverterOp::non_default_input_ports()

non_default_output_ports

std::vector<std::string> & holoscan::ops::FormatConverterOp::non_default_output_ports()

set_input_exec_spec

void holoscan::ops::FormatConverterOp::set_input_exec_spec(
const std::shared_ptr<IOSpec> &input_exec_spec
)

set_output_exec_spec

void holoscan::ops::FormatConverterOp::set_output_exec_spec(
const std::shared_ptr<IOSpec> &output_exec_spec
)

set_dynamic_flows

void holoscan::ops::FormatConverterOp::set_dynamic_flows(
const std::function<void(const std::shared_ptr<Operator> &)> &dynamic_flow_func
)

set_self_shared

void holoscan::ops::FormatConverterOp::set_self_shared(
const std::shared_ptr<Operator> &this_op
)

initialize_execution_context

virtual std::shared_ptr<ExecutionContext> holoscan::ops::FormatConverterOp::initialize_execution_context()virtual std::shared_ptr<ExecutionContext> holoscan::ops::FormatConverterOp::initialize_execution_context()

service_provider

void holoscan::ComponentBase::service_provider(
FragmentServiceProvider *provider
)

Set the service provider that owns this component.


Static methods

is_all_operator_successor_virtual

static bool holoscan::ops::FormatConverterOp::is_all_operator_successor_virtual(
const OperatorNodeType &op,
OperatorFlowGraph &graph
)

Returns whether all the successors of an operator are virtual operators.

Returns: true if the operator has all virtual operator successors, false otherwise

Parameters

op
const OperatorNodeType &

The shared_ptr to the operator for which the check is to be performed

graph
OperatorFlowGraph &

The graph of operators. fragment()->graph() can usually be used to get this graph.

is_all_operator_predecessor_virtual

static bool holoscan::ops::FormatConverterOp::is_all_operator_predecessor_virtual(
const OperatorNodeType &op,
OperatorFlowGraph &graph
)

Returns whether all the predecessors of an operator are virtual operators.

Returns: true if the operator has all virtual operator predecessors, false otherwise

Parameters

op
const OperatorNodeType &

The shared_ptr to the operator for which the check is to be performed

graph
OperatorFlowGraph &

The graph of operators. fragment()->graph() can usually be used to get this graph.

parse_port_name

static std::pair<std::string, std::string> holoscan::ops::FormatConverterOp::parse_port_name(
const std::string &op_port_name
)

Return operator name and port name from a string in the format of “<op_name>[.<port_name>]“.

parse_operator_port_key

static std::pair<std::string, std::string> holoscan::ops::FormatConverterOp::parse_operator_port_key(
const std::string &operator_port_key
)

Return operator name and port name from a string in the format of “<op_name>-<port_name>“.

register_codec

template <typename typeT>
static void holoscan::ops::FormatConverterOp::register_codec(
const std::string &codec_name,
bool overwrite = true
)

Register the codec for serialization/deserialization of a custom type.

Deprecated

Use holoscan::gxf::GXFExecutor::register_codec instead.

validate_operator_name

static void holoscan::ops::FormatConverterOp::validate_operator_name(
const std::string &name
)

Validate operator name against restricted keywords and patterns.

Throws: std::invalid_argument if the name contains restricted patterns.

Parameters

name
const std::string &

The name to validate.

register_converter

template <typename typeT>
static void holoscan::ComponentBase::register_converter()

Register the argument setter for the given type.

If an operator or resource 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/resource (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 and YAML::convert<T>::decode are implemented for the given type. You need to specialize the YAML::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

typeT
typename

The type of the argument to register.

Example

void MyOp::initialize() {
register_converter<Vec3>();
}

Example

struct Vec3 {
// make sure you have overloaded operator==() for the comparison
double x, y, z;
};

Example

namespace YAML {
template<>
struct convert<Vec3> {
static Node encode(const Vec3& rhs) {
Node node;
node.push_back(rhs.x);
node.push_back(rhs.y);
node.push_back(rhs.z);
return node;
}
static bool decode(const Node& node, Vec3& rhs) {
if(!node.IsSequence() || node.size() != 3) {
return false;
}
rhs.x = node[0].as<double>();
rhs.y = node[1].as<double>();
rhs.z = node[2].as<double>();
return true;
}
};
}

register_argument_setter

template <typename typeT>
void holoscan::ComponentBase::register_argument_setter()

Register the argument setter for the given type.

Please refer to the documentation of register_converter() for more details.

Template parameters

typeT
typename

The type of the argument to register.


Types

OperatorType

Operator type used by the executor.

NameValueDescription
kNativeNative operator.
kGXFGXF operator.
kVirtualVirtual operator.
kGPUResidentGPU-resident operator.
kUnknownPlaceholder for unknown operator type.

Member variables

NameTypeDescription
in_Parameter< holoscan::IOSpec * >
out_Parameter< holoscan::IOSpec * >
in_tensor_name_Parameter< std::string >
out_tensor_name_Parameter< std::string >
scale_min_Parameter< float >
scale_max_Parameter< float >
alpha_value_Parameter< uint8_t >
resize_width_Parameter< int32_t >
resize_height_Parameter< int32_t >
resize_mode_Parameter< int32_t >
out_channel_order_Parameter< std::vector< int > >
cuda_stream_pool_Parameter< std::shared_ptr< CudaStreamPool > >
resize_buffer_std::unique_ptr< nvidia::gxf::MemoryBuffer >
channel_buffer_std::unique_ptr< nvidia::gxf::MemoryBuffer >
device_scratch_buffer_std::unique_ptr< nvidia::gxf::MemoryBuffer >
pool_Parameter< std::shared_ptr< Allocator > >
in_dtype_str_Parameter< std::string >
out_dtype_str_Parameter< std::string >
in_dtype_FormatDType
out_dtype_FormatDType
in_primitive_type_nvidia::gxf::PrimitiveType
out_primitive_type_nvidia::gxf::PrimitiveType
format_conversion_type_FormatConversionType
npp_stream_ctx_NppStreamContext
kInputExecPortName static constexprconst char *Default input execution port name.
kOutputExecPortName static constexprconst char *Default output execution port name.
is_initialized_boolWhether the operator is initialized.
operator_type_OperatorTypeThe type of the operator.
spec_std::shared_ptr< OperatorSpec >The operator spec of the operator.
conditions_std::unordered_map< std::string, std::shared_ptr< Condition > >The conditions of the operator.
resources_std::unordered_map< std::string, std::shared_ptr< Resource > >The resources used by the operator.
graph_entity_std::shared_ptr< nvidia::gxf::GraphEntity >GXF graph entity corresponding to.
internal_async_condition_*< the Operator *The asynchronous condition to control the operator execution. std::shared_ptr< holoscan::AsynchronousCondition >
dynamic_metadata_std::shared_ptr< MetadataDictionary >The metadata dictionary for the operator.
is_metadata_enabled_std::optional< bool >Flag to enable or disable metadata for the operator.
input_exec_spec_*< If not set, the value from the Fragment is used. std::shared_ptr< IOSpec >The input execution port specification.
output_exec_spec_std::shared_ptr< IOSpec >The output execution port specification.
dynamic_flow_func_std::function< void(const std::shared_ptr< Operator > &)>
self_shared_std::weak_ptr< Operator >
next_flows_std::shared_ptr< std::vector< std::shared_ptr< FlowInfo > > >
dynamic_flows_std::shared_ptr< std::vector< std::shared_ptr< FlowInfo > > >
id_int64_tThe ID of the component.
name_std::stringName of the component.
fragment_Fragment *Pointer to the fragment that owns this component.
args_std::vector< Arg >List of arguments.
service_provider_FragmentServiceProvider *Pointer to the service provider.