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_contiguousparameter.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 Location
Is Contiguous
to_contiguous Setting
Returned Tensor
On Houmo device memory
Yes
true/false
New tensor, contiguous.
On Houmo device memory
No
true
New tensor, contiguous.
On Houmo device memory
No
false
New tensor, non-contiguous.
On Host memory
Yes
true/false
Original tensor, contiguous.
On Host memory
No
true
New tensor, contiguous.
On Host memory
No
false
Original 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 tofalse, the returned tensor preserves its original memory layout. Defaults tofalse.- Returns:
A new object representing the tensor stored in host memory.
- Return type:
- Raises:
RuntimeError -- If the operation fails, such as due to memory allocation or data copy errors.