TensorPlay
latest (dev)
Copy
View Markdown

Latest development documentation · Updated 2026-10-08

tensorplay.nested.nested_tensor

tensorplay.nested.nested_tensor(ts, *, dtype=None, device=None, requires_grad=False, layout=None, pin_memory=False)[source]

Constructs a nested tensor from a list / tuple of tensors.

Constituents must share the same rank; they are always copied into one packed buffer sized to the total element count.

Parameters:

ts (List[Tensor] or Tuple[Tensor]) – tensors of the same rank.

Keyword Arguments:
  • dtype (tensorplay.dtype, optional) – desired dtype of the result.

  • device (tensorplay.device, optional) – desired device of the result.

  • requires_grad (bool, optional) – whether the result tracks gradients.

  • layout – only the strided layout (None or 0) is supported.

  • pin_memory (bool, optional) – whether the packed buffer is pinned.

Returns:

the nested tensor.

Return type:

Tensor

On this page

Ask DeepWiki