Skip to main content

to_host

Tensor.to_host(to_contiguous : bool = False)

Retrieves or creates a tensor in host memory with tensor data based on the current Tensor object.

The following table summarizes the behavior of this function:

  • Original Tensor Location : The memory location of the original tensor.

  • Is Contiguous : Whether the memory layout of the original tensor is contiguous.

  • to_contiguous Setting : The value of the to_contiguous parameter.

  • Returned Tensor : Describes the returned tensor after performing this function, including if the returned tensor has contiguous or non-contiguous memory layout on host.

Original Tensor LocationIs Contiguousto_contiguous SettingReturned Tensor
On Houmo device memoryYestrue/falseNew tensor, contiguous.
On Houmo device memoryNotrueNew tensor, contiguous.
On Houmo device memoryNofalseNew tensor, non-contiguous.
On Host memoryYestrue/falseOriginal tensor, contiguous.
On Host memoryNotrueNew tensor, contiguous.
On Host memoryNofalseOriginal tensor, non-contiguous.

Parameters:

to_contiguous (bool _,_optional) -- Specifies if to return the tensor with contiguous or non-contiguous memory layout. If set to true, the returned tensor is stored on host with contiguous in memory. If set to false, the returned tensor preserves its original memory layout. Defaults to false.

Returns:

A new object representing the tensor stored in host memory.

Return type:

Tensor

Raises:

RuntimeError -- If the operation fails, such as due to memory allocation or data copy errors.