IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/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. /max/get-started.md).

Mojo function

memcpy_or_fuse

def memcpy_or_fuse[rank: Int, dtype: DType, epilogue_fn: Optional[def[c_type: DType, rank: Int, width: SIMDLength = SIMDLength(1), *, alignment: Int = Int(1)](IndexList[rank], SIMD[c_type, width]) capturing thin -> None]](dest_data: Pointer[Int8, _safe=False], out_byte_offset: Int, src_data: Pointer[Int8, _safe=False], n: Int, out_shape: IndexList[rank, element_type=out_shape.element_type])

Copies n bytes from src_data into dest_data at out_byte_offset, applying epilogue_fn elementwise when present.

When no epilogue function is supplied, this performs a plain memcpy of n bytes. When an epilogue function is supplied, the source bytes are reinterpreted as typed elements and the epilogue is applied scalar-by-scalar so that fused concat can transform values while copying them into the output buffer.

Parameters:

Args:

  • ​dest_data (Pointer[Int8, _safe=False]): Destination byte buffer to write into.
  • ​out_byte_offset (Int): Byte offset into dest_data where the copy starts.
  • ​src_data (Pointer[Int8, _safe=False]): Source byte buffer to read from.
  • ​n (Int): Number of bytes to copy.
  • ​out_shape (IndexList[rank, element_type=out_shape.element_type]): Shape of the output tensor used to compute multi-dimensional indices for the epilogue function.

Was this page helpful?