holoscan::gxf::GXFInputContext
holoscan::gxf::GXFInputContext
Class to hold the input context for a GXF Operator.
This class provides the interface to receive the input data from the operator using GXF.
Inherits from: holoscan::InputContext (public)
Constructors
GXFInputContext
Construct a new GXFInputContext object
Construct a new GXFInputContext object (with inputs)
Construct a new GXFInputContext object.
Parameters
The pointer to the execution context.
The pointer to the GXFOperator object.
Methods
gxf_context
Get a pointer to the GXF execution runtime.
Returns: The pointer to the GXF context.
receive_cuda_stream
Synchronize any streams found on this port to the operator’s internal CUDA stream.
The receive method must have been called for input_port_name prior to calling this method in order for any received streams to be found. This method will call cudaSetDevice to make the device corresponding to the operator’s internal stream current.
If no CudaStreamPool resource was available on the operator, the operator will not have an internal stream. In that case, the first stream received on the input port will be returned and any additional streams on the input will have been synchronized to it. If no streams were found on the input and no CudaStreamPool resource was available, cudaStreamDefault is returned.
Returns: The operator’s internal CUDA stream, when possible. Returns cudaStreamDefault instead if no CudaStreamPool resource was available and no stream was found on the input port.
Parameters
The name of the input port. Can be omitted if the operator only has a single input port.
Whether to allocate a new stream if no stream is found. If false or the operator does not have a cuda_stream_pool parameter set, returns cudaStreamDefault.
Whether to also synchronize any received streams to the default stream.
receive_cuda_streams
Retrieve the CUDA streams found on an input port.
This method is intended for advanced use cases where it is the users responsibility to manage any necessary stream synchronization. In most cases, it is recommended to use receive_cuda_stream instead.
Returns: Vector of (optional) cudaStream_t. In normal operation, the length of the vector matches the number of messages on the input port, with std::nullopt for messages without a stream. If stream handling is unavailable (e.g., CudaObjectHandler not initialized), an empty vector is returned.
Parameters
The name of the input port. Can be omitted if the operator only has a single input port.
execution_context
Get pointer to the execution context.
Returns: The pointer to the execution context.
op
Return the operator that this context is associated with.
Returns: The pointer to the operator.
inputs
Return the reference to the map of the input specs.
Returns: The reference to the map of the input specs.
empty
Return whether the input port has any data.
For parameters with std::vector<IOSpec*> type, if all the inputs are empty, it will return true. Otherwise, it will return false.
Returns: True, if it has no data, otherwise false.
Parameters
The name of the input port to check.
reset_acquisition_timestamps
Reset acquisition timestamp map values to std::nullopt for all input ports.
This method should be called before each compute call to reset the timestamp values while preserving the pre-initialized map structure for performance.
get_acquisition_timestamp
Get the acquisition timestamp for a given input port.
Returns: The acquisition timestamp. If no timestamp was published by the upstream operator, std::nullopt is returned.
Parameters
The name of the input port.
get_acquisition_timestamps
Get all acquisition timestamp for a given input port.
For a port with queue size not equal to one (e.g. an IOSpec::kAnySize connection) there may be multiple messages in a queue, each with its own acquisition timestamp. This method returns a vector of std::optional<int64_t> where the length of the vector is the same as the number of messages received on that port.
Returns: The acquisition timestamps. Values of std::nullopt in the vector indicate that the corresponding message did not contain a timestamp.
Parameters
The name of the input port.
receive
Receive a message from the input port with the given name.
If the operator has a single input port, the name of the input port can be omitted.
If the input port with the given name and type (DataT) is available, it will return the data from the input port. Otherwise, it will return an object of the holoscan::unexpected class which will contain the error message. The error message can be access by calling the what() method of the holoscan::unexpected object.
It throws an invalid argument exception if the operator attempts to receive non-vector data (op_input.receive<T>()) from an input port with a queue size of IOSpec::kAnySize.
Example:
Returns: The received data.
Template parameters
The type of the data to receive.
Parameters
The name of the input port to receive the data from.
Example
cuda_object_handler
Overload 1
Overload 2
Get the CUDA stream/event handler used by this input context.
This CudaObjectHandler class is designed primarily for internal use and is not guaranteed to have a stable API. Application authors should instead rely on the public receive_cuda_stream and receive_cuda_streams methods.
empty_impl
The implementation of the empty method.
Returns: True if the input port is empty or by default. Otherwise, false.
Parameters
The name of the input port
receive_impl
The implementation of the receive method.
Depending on the type of the data, this method receives a message from the input port with the given name.
Returns: The data received from the input port.
Parameters
The name of the input port.
The input type (kGXFEntity or kAny).
Whether to print an error message when the input port is not found.
Whether any calls to log_backend_specific should be skipped. Currently used to avoid duplication of logging of TensorMap contents.
retrieve_cuda_streams
gxf_cuda_object_handler
is_valid_param_type
any_size_param_count
should_fallback_to_direct_any_size_input
fill_input_vector_from_params
fill_input_vector_from_inputs
get_unique_id
log_tensor
log_tensormap
populate_tensor_map
process_received_value
handle_null_value
Overload 1
Overload 2
handle_bad_any_cast
receive_single_value
create_receive_error
prepopulate_acquisition_timestamp_map
get_first_stream_for_logging
Helper to extract the first received CUDA stream for logging.
Returns: The first CUDA stream if available, std::nullopt otherwise
Parameters
The name of the input port
Types
InputType
The input data type.