recv_tensordict#
- async tensordict._ucxx.recv_tensordict(endpoint, td: TensorDictBase | None = None, *, device: device | str | None = None, consolidated: bool = True) TensorDictBase#
Receives a tensordict that
send_tensordict()sends over a UCXX endpoint.Warning
recv_tensordictis experimental: its API can change in a minor release without a deprecation cycle.It keeps no state: each call reads the metadata, then the storage. It needs the optional
ucxxpackage. The sender controls the size of the allocation: use it only on a trusted network.- Parameters:
endpoint (ucxx.Endpoint) – the endpoint to receive from.
td (TensorDictBase, optional) – a consolidated tensordict to receive into. If its layout, storage size and device match the data, the data is written into its storage, and
tdis returned. Otherwisetdis not changed, and a new tensordict is returned. Defaults toNone.
- Keyword Arguments:
device (device, str or int, optional) – the device to receive on. Defaults to
None, which uses the device of the storage oftdif it is consolidated, and the CPU otherwise. Withconsolidated=False, the default is the CPU.consolidated (bool, optional) – the
consolidatedargument of the sender’ssend_tensordict(). WithFalse, reads the leaves one by one, as a pipe withconsolidated=Falsedoes, and returns a new tensordict:tdis not used. Defaults toTrue.
- Returns:
tdor a new consolidated tensordict, or withconsolidated=False, a new tensordict that is not consolidated.- Return type:
The received tensordict
- Raises:
ImportError – if
ucxxis not installed.