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
fused_concat
def fused_concat[dtype: DType, rank: Int, InputFnType: def[input_index: Int, width: Int, alignment: Int = Int(1)](Coord[*?]) -> SIMD[dtype, width] & RegisterPassable & ImplicitlyCopyable, OutputFnType: ElementwiseEpilogueFn, OutputLayoutType: TensorLayout, *, axis: Int, target: StringSpan[ImmStaticOrigin] = StringSpan("cpu")](input_shapes: StaticTuple[IndexList[rank]], output_layout: OutputLayoutType, input_fn: InputFnType, output_0_fn: OutputFnType, ctx: DeviceContextBase)
Concatenates inputs produced by input_fn along axis, handing each element to output_0_fn.
Instead of reading from concrete input tensors, the fused variant drives the
concat from a caller-supplied input_fn that produces values on demand,
allowing the concat to be fused with preceding elementwise operations.
Dispatches to the CPU or GPU fused implementation based on target and
returns early when the output tensor is empty.
Parameters:
- dtype (
DType): Element type of the input and output tensors. - rank (
Int): Number of dimensions in the input and output tensors. - InputFnType (
def[input_index: Int, width: Int, alignment: Int = Int(1)](Coord[*?]) -> SIMD[dtype, width]&RegisterPassable&ImplicitlyCopyable): Type of the input function (inferred). - OutputFnType (
ElementwiseEpilogueFn): Type of the output epilogue function (inferred). - OutputLayoutType (
TensorLayout): Layout type of the concatenated output. - axis (
Int): Axis along which to concatenate the inputs. - target (
StringSpan[ImmStaticOrigin]): Target device to dispatch to (defaults to"cpu").
Args:
- input_shapes (
StaticTuple[IndexList[rank]]): Static tuple of per-input shapes describing each logical input thatinput_fnproduces. - output_layout (
OutputLayoutType): Layout of the concatenated output. The concat reads only its shape; every element reaches the output throughoutput_0_fn. - input_fn (
InputFnType): Function that produces input element values on demand, indexed by input position. - output_0_fn (
OutputFnType): Epilogue function that stores each produced element. - ctx (
DeviceContextBase): Device context used to schedule the work.