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:
- βrank (
Int): Number of dimensions in the output tensor used for epilogue indexing. - βdtype (
DType): Element type of the tensors being copied. - β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]): Optional elementwise function applied to each copied element; when absent, a plain bytememcpyis performed.
Args:
- βdest_data (
Pointer[Int8, _safe=False]): Destination byte buffer to write into. - βout_byte_offset (
Int): Byte offset intodest_datawhere 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?
Thank you! We'll create more content like this.
Thank you for helping us improve!