DriveWorks SDK Reference
3.5.78 Release
For Test and Development only

Tensor Streamer

Detailed Description

Defines the tensor streamer function, enabling streaming tensors between different APIs.

Note
SW Release Applicability: These APIs are available in both NVIDIA DriveWorks and NVIDIA DRIVE Software releases.

Typedefs

typedef struct dwDNNTensorStreamerObject * dwDNNTensorStreamerHandle_t
 

Functions

DW_API_PUBLIC dwStatus dwDNNTensorStreamer_consumerReceive (dwDNNTensorHandle_t *tensor, dwTime_t timeout_us, dwDNNTensorStreamerHandle_t streamer)
 Receive a pointer to a dwDNNTensorHandle_t from the streamer, acting as a consumer. More...
 
DW_API_PUBLIC dwStatus dwDNNTensorStreamer_consumerReturn (dwDNNTensorHandle_t *tensor, dwDNNTensorStreamerHandle_t streamer)
 Return the received tensor back to the producer. More...
 
DW_API_PUBLIC dwStatus dwDNNTensorStreamer_getCUDAStream (cudaStream_t *stream, dwDNNTensorStreamerHandle_t streamer)
 Get CUDA stream used by the tensor streamer. More...
 
DW_API_PUBLIC dwStatus dwDNNTensorStreamer_getOutputProperties (dwDNNTensorProperties *props, dwDNNTensorStreamerHandle_t streamer)
 Get tensor properties of the tensor received from the streamer. More...
 
DW_API_PUBLIC dwStatus dwDNNTensorStreamer_initialize (dwDNNTensorStreamerHandle_t *streamer, const dwDNNTensorProperties *from, dwDNNTensorType to, dwContextHandle_t ctx)
 Creates and initializes the tensor streamer capable of moving tensors between different API types. More...
 
DW_API_PUBLIC dwStatus dwDNNTensorStreamer_producerReturn (dwDNNTensorHandle_t *tensor, dwTime_t timeout_us, dwDNNTensorStreamerHandle_t streamer)
 The producer streamer waits for the tensor sent to be returned by the consumer. More...
 
DW_API_PUBLIC dwStatus dwDNNTensorStreamer_producerSend (dwDNNTensorHandle_t tensor, dwDNNTensorStreamerHandle_t streamer)
 Sends an tensor through the streamer acting as the producer. More...
 
DW_API_PUBLIC dwStatus dwDNNTensorStreamer_release (dwDNNTensorStreamerHandle_t streamer)
 Releases the tensor streamer. More...
 
DW_API_PUBLIC dwStatus dwDNNTensorStreamer_setCUDAStream (cudaStream_t stream, dwDNNTensorStreamerHandle_t streamer)
 Sets the CUDA stream for CUDA related streaming operations such as post and receive. More...
 

Typedef Documentation

◆ dwDNNTensorStreamerHandle_t

typedef struct dwDNNTensorStreamerObject* dwDNNTensorStreamerHandle_t

Definition at line 59 of file TensorStreamer.h.

Function Documentation

◆ dwDNNTensorStreamer_consumerReceive()

DW_API_PUBLIC dwStatus dwDNNTensorStreamer_consumerReceive ( dwDNNTensorHandle_t tensor,
dwTime_t  timeout_us,
dwDNNTensorStreamerHandle_t  streamer 
)

Receive a pointer to a dwDNNTensorHandle_t from the streamer, acting as a consumer.

Can wait until timeout before failing.

Parameters
[out]tensorA pointer to a dwDNNTensorHandle_t sent by the producer, not null if successfully converted.
[in]timeout_usTimeout in milliseconds before interrupting the waiting for producer.
[in]streamerA handle to the tensor streamer.
Returns
DW_INVALID_ARGUMENT if the given tensor handle is NULL
DW_INVALID_HANDLE if the given streamer handle (consumer) is invalid, i.e. null or of wrong type
DW_TIME_OUT if times out
or DW_SUCCESS otherwise.

◆ dwDNNTensorStreamer_consumerReturn()

DW_API_PUBLIC dwStatus dwDNNTensorStreamer_consumerReturn ( dwDNNTensorHandle_t tensor,
dwDNNTensorStreamerHandle_t  streamer 
)

Return the received tensor back to the producer.

Ownership is given back and tensor goes back to null

Parameters
[in]tensorA pointer to the dwDNNTensorHandle_t to return to the producer.
[in]streamerA handle to the tensor streamer.
Returns
DW_INVALID_HANDLE if the given streamer handle (consumer) is invalid, i.e. null or of wrong type
DW_INTERNAL_ERROR if the tensor has been received yet or an underlying error depending on the producer/consumer combination has occurred
or DW_SUCCESS otherwise.

◆ dwDNNTensorStreamer_getCUDAStream()

DW_API_PUBLIC dwStatus dwDNNTensorStreamer_getCUDAStream ( cudaStream_t *  stream,
dwDNNTensorStreamerHandle_t  streamer 
)

Get CUDA stream used by the tensor streamer.

Parameters
[out]streamCUDA stream used by the streamer
[in]streamerA handle to the tensor streamer.
Returns
DW_INVALID_HANDLE if the given context handle is invalid,i.e null or of wrong type
DW_NOT_SUPPORTED if the streamer does not work with CUDA tensors,
or DW_SUCCESS otherwise.

◆ dwDNNTensorStreamer_getOutputProperties()

DW_API_PUBLIC dwStatus dwDNNTensorStreamer_getOutputProperties ( dwDNNTensorProperties props,
dwDNNTensorStreamerHandle_t  streamer 
)

Get tensor properties of the tensor received from the streamer.

Parameters
[out]propsProperties of the resulting tensors.
[in]streamerA handle to the tensor streamer.
Returns
DW_INVALID_HANDLE if the given context handle is invalid,i.e null or of wrong type
DW_SUCCESS if successful.

◆ dwDNNTensorStreamer_initialize()

DW_API_PUBLIC dwStatus dwDNNTensorStreamer_initialize ( dwDNNTensorStreamerHandle_t streamer,
const dwDNNTensorProperties from,
dwDNNTensorType  to,
dwContextHandle_t  ctx 
)

Creates and initializes the tensor streamer capable of moving tensors between different API types.

For example an tensor can be moved from NvMedia API into GL textured type or from CPU memory to CUDA.

Parameters
[out]streamerA handle to the tensor streamer (if successfully initialized.)
[in]fromThe properties of the source tensor for streaming.
[in]toThe type of the destination tensor.
[in]ctxThe DriveWorks context.
Returns
DW_SUCCESS if the translator was created,
DW_INVALID_ARGUMENT if the given tensor types are invalid or the streamer pointer is null,
DW_INVALID_HANDLE if the given context handle is invalid,i.e null or of wrong type
DW_NOT_IMPLEMENTED if the desired streamer between given types is not implemented,
DW_NOT_AVAILABLE if the desired streamer between given two types is currently not available due to missing resources or non-initialized APIs,
or DW_NOT_SUPPORTED if the desired streamer cannot work with given pixel format or type.

◆ dwDNNTensorStreamer_producerReturn()

DW_API_PUBLIC dwStatus dwDNNTensorStreamer_producerReturn ( dwDNNTensorHandle_t tensor,
dwTime_t  timeout_us,
dwDNNTensorStreamerHandle_t  streamer 
)

The producer streamer waits for the tensor sent to be returned by the consumer.

Waits for a max timeout. Returns a pointer to the dwDNNTensorHandle of the returned tensor, if the pointer passed is not null, otherwise it does not return a pointer

Parameters
[out]tensorA pointer to a dwDNNTensorHandle_t returned by the producer
[in]timeout_usTimeout in milliseconds before interrupting the waiting and return a timeout error.
[in]streamerA handle to the tensor streamer.
Returns
DW_INVALID_ARGUMENT if the given streamer handle (producer) is null
DW_INVALID_HANDLE if the given streamer handle (producer) is invalid,i.e. of wrong type
DW_TIME_OUT if times out
or DW_SUCCESS otherwise.

◆ dwDNNTensorStreamer_producerSend()

DW_API_PUBLIC dwStatus dwDNNTensorStreamer_producerSend ( dwDNNTensorHandle_t  tensor,
dwDNNTensorStreamerHandle_t  streamer 
)

Sends an tensor through the streamer acting as the producer.

Note
The ownership of the tensor remains by the caller.
Parameters
[in]tensorA dwTensorHandle_t to send through the streamer
[in]streamerA handle to the tensor streamer.
Returns
DW_INVALID_HANDLE if the given streamer handle (producer) is invalid,i.e. of wrong type
DW_INVALID_ARGUMENT if the given streamer handle (producer) or the tensor handle is NULL
DW_INVALID_HANDLE if the dwDNNTensorType of the input tensor doesn't match the streamer's
DW_BUSY_WAITING if the tensor cannot be sent. Non fatal error, it is possible to retry
or DW_SUCCESS otherwise.

◆ dwDNNTensorStreamer_release()

DW_API_PUBLIC dwStatus dwDNNTensorStreamer_release ( dwDNNTensorStreamerHandle_t  streamer)

Releases the tensor streamer.

This releases all memory and closes all related resources. The handle is set to null.

Parameters
[in]streamerA handle to the tensor streamer.
Returns
DW_SUCCESS if successful.

◆ dwDNNTensorStreamer_setCUDAStream()

DW_API_PUBLIC dwStatus dwDNNTensorStreamer_setCUDAStream ( cudaStream_t  stream,
dwDNNTensorStreamerHandle_t  streamer 
)

Sets the CUDA stream for CUDA related streaming operations such as post and receive.

Note
The ownership of the stream remains by the callee.
Parameters
[in]streamThe CUDA stream to be used. Default is 0.
[in]streamerA handle to the tensor streamer.
Returns
DW_INVALID_HANDLE if the given context handle is invalid,i.e null or of wrong type
DW_NOT_SUPPORTED if the streamer does not work with CUDA tensors,
or DW_SUCCESS otherwise.