IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Mojo struct

InplaceMemcpy

struct InplaceMemcpy[DstDevice: StringSlice[ImmStaticOrigin], SrcDevice: StringSlice[ImmStaticOrigin]]

Copies the contents of src into dst in place.

Semantically equivalent to Buffer.inplace_copy_from, but exposed as a graph op so the copy can be scheduled as part of a compiled MAX graph. Both operands must have the same dtype, rank, and total element count.

Supports the four direction combinations expressible with a single DeviceContext: GPU-to-GPU on the same device, GPU-to-CPU, CPU-to-GPU, and CPU-to-CPU. Cross-GPU memcpy (different GPU ids) is rejected by the Python wrapper at graph build time.

Parameters​

Implemented traits​

AnyType, ImplicitlyDeletable

Methods​

execute​

static def execute[target: StringSlice[ImmStaticOrigin], dtype: DType, rank: Int](dst: ManagedTensorSlice[IOSpec[_, _].MutableInput, static_spec=dst.static_spec], src: ManagedTensorSlice[IOSpec[_, _].Input, static_spec=src.static_spec], ctx: DeviceContext)