Skip to main content

Mojo function

copy_tensor

copy_tensor[dtype: DType, rank: Int, //, *, target: StringSlice[StaticConstantOrigin] = "cpu", _trace_name: StringSlice[StaticConstantOrigin] = "mogg.copy_tensor"](dst: ManagedTensorSlice[dst.io_spec, static_spec=dst.static_spec], src: ManagedTensorSlice[src.io_spec, static_spec=src.static_spec], ctx: DeviceContextPtr)

Copy elements from src to dst using fused load and store.

Reads each element of src via _fused_load (dispatches through the fused input lambda when present, falls back to a direct load otherwise) and writes to dst through its fused output store, dispatching via foreach.

Parameters:

  • dtype (DType): The element type of both tensor slices.
  • rank (Int): The rank of both tensor slices.
  • target (StringSlice): The target device (e.g. "cpu", "gpu").
  • _trace_name (StringSlice): Name shown in the execution trace.

Args:

Was this page helpful?