def put(self,keys: Union[str, List[str]],tensors: Union[torch.Tensor, List[torch.Tensor], List[List[torch.Tensor]]],**kwargs) -> List[bool]

Function

Writes or overwrites the tensor data corresponding to one key or a group of keys.

Prototype

def put(self,keys: Union[str, List[str]],tensors: Union[torch.Tensor, List[torch.Tensor], List[List[torch.Tensor]]],**kwargs
) -> List[bool]:

Parameters

Parameter

Type

Description

keys

Union[str, List[str]]

  • str: writes a single entry.
  • List[str]: indicates batch write. The length must be the same as that of tensors.

tensors

Union[Tensor, List[Tensor], List[List[Tensor]]]

  • Tensor: A single key corresponds to a single tensor.
  • List[Tensor]: Multiple keys correspond to a list of tensors with the same length.
  • List[List[Tensor]]: A two-dimensional list is used for multi-shard or multi-segment writing.

**kwargs

-

  • overwrite (bool): Whether to overwrite an existing key (determined by the implementation by default).
  • ttl (float|int): indicates expiration time in seconds (if supported by the backend).
  • sync (bool): Whether to flush data to disks synchronously.
  • shard (Any): indicates the shard policy or identifier.
  • Other implementation-related parameters.

Return Value

  • List[bool]: indicates the current keys written to the pooling backend and the boolean values indicating success or failure for the corresponding tensors. Each boolean value corresponds to the result of each key. If keys is of the str type, the return value is still of List[bool] type and the length is 1.