Skip to main content

TensorPtr_clone_to

Function TensorPtr_clone_to 

Source
pub fn TensorPtr_clone_to(
    tensor: SharedPtr<Tensor>,
    device: ET_Device,
) -> SharedPtr<Tensor>
Available on crate features std and tensor-ptr only.
Expand description

Clones a TensorPtr’s data onto the given target device, allocating and copying as needed.

The transfer direction is inferred from the source and target device: host-to-device when target is an accelerator, and device-to-host when target is CPU. Copies use the DeviceAllocator registered for the accelerator side; a device-backed result owns its memory and frees it via that allocator when destroyed.

Source and target must differ in device domain: for a CPU-to-CPU copy use TensorPtr_clone, and device-to-device transfers are not supported.

Arguments:

  • tensor: The source tensor whose data will be copied.
  • device: The destination device (CPU or an accelerator).

Returns a TensorPtr backed by device memory containing the copied data.