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 function
memcpy_or_fuse
def memcpy_or_fuse[EpilogueFnType: ElementwiseEpilogueFn, //, rank: Int, dtype: DType, has_epilogue: Bool](dest_data: Pointer[Int8], out_byte_offset: Int, src_data: Pointer[Int8], n: Int, out_shape: IndexList[rank, element_type=out_shape.element_type], epilogue_fn: EpilogueFnType)
Copies n bytes from src_data into dest_data at out_byte_offset, applying epilogue_fn elementwise when has_epilogue is set.
When has_epilogue is False, this performs a plain memcpy of
n bytes. Otherwise 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:
- EpilogueFnType (
ElementwiseEpilogueFn): Type of the epilogue function (inferred). - rank (
Int): Number of dimensions in the output tensor used for epilogue indexing. - dtype (
DType): Element type of the tensors being copied. - has_epilogue (
Bool): Whether to applyepilogue_fnto each copied element; whenFalse, a plain bytememcpyis performed.
Args:
- dest_data (
Pointer[Int8]): Destination byte buffer to write into. - out_byte_offset (
Int): Byte offset intodest_datawhere the copy starts. - src_data (
Pointer[Int8]): 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. - epilogue_fn (
EpilogueFnType): Elementwise function applied to each copied element; ignored unlesshas_epilogue.