Class GXFInputContext
Defined in File gxf_io_context.hpp
Base Type
public holoscan::InputContext
(Class InputContext)
-
class GXFInputContext : public holoscan::InputContext
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.
Public Functions
-
GXFInputContext(ExecutionContext *execution_context, Operator *op)
Construct a new GXFInputContext object.
- Parameters
execution_context – The pointer to the execution context.
op – The pointer to the GXFOperator object.
Construct a new GXFInputContext object.
- Parameters
execution_context – The pointer to the execution context.
op – The pointer to the GXFOperator object.
inputs – inputs The references to the map of the input specs.
-
gxf_context_t gxf_context() const
Get a pointer to the GXF execution runtime.
- Returns
The pointer to the GXF context.
-
virtual cudaStream_t receive_cuda_stream(const char *input_port_name = nullptr, bool allocate = true, bool sync_to_default = false) override
Synchronize any streams found on this port to the operator’s internal CUDA stream.
The
receive
method must have been called forinput_port_name
prior to calling this method in order for any received streams to be found. This method will callcudaSetDevice
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 noCudaStreamPool
resource was available,cudaStreamDefault
is returned.- Parameters
input_port_name – The name of the input port. Can be omitted if the operator only has a single input port.
allocate – 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.sync_to_default – Whether to also synchronize any received streams to the default stream.
- 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.
-
virtual std::vector<std::optional<cudaStream_t>> receive_cuda_streams(const char *input_port_name = nullptr) override
Retrieve the CUDA streams found 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.- Parameters
input_port_name – The name of the input port. Can be omitted if the operator only has a single input port.
- Returns
Vector of (optional) cudaStream_t. The length of the vector will match the number of messages on the input port. Any messages that do not contain a stream will have value of std::nullopt.
Protected Functions
-
virtual bool empty_impl(const char *name = nullptr) override
The implementation of the
empty
method.- Parameters
name – The name of the input port
- Returns
True if the input port is empty or by default. Otherwise, false.
-
virtual std::any receive_impl(const char *name = nullptr, InputType in_type = InputType::kAny, bool no_error_message = false) override
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.
- Parameters
name – The name of the input port.
no_error_message – Whether to print an error message when the input port is not found.
- Returns
The data received from the input port.
-
gxf_result_t retrieve_cuda_streams(nvidia::gxf::Entity &message, const std::string &input_name)
-
GXFInputContext(ExecutionContext *execution_context, Operator *op)