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 module
conv_utils
Utilities for direct convolution kernels on CPU.
Provides convolution shape description, L2 tiling heuristics, micro-kernel shape selection, and work partitioning helpers used by the direct and im2col convolution implementations.
comptime values
ConvEpilogueFn
comptime ConvEpilogueFn = def(Coord[*?], Int) -> None & RegisterPassable & ImplicitlyCopyable
Fused epilogue applied over a whole f_size-long run at coords.
Distinct from ConvSimdEpilogueFn, which receives the value; this one receives
only the coordinate and the run length. Rank-N in the output's own space; the
Coord carries its rank, so there is no rank parameter.
ConvSimdEpilogueFn
comptime ConvSimdEpilogueFn = def[dtype: DType, width: SIMDLength, alignment: Int = Int(1)](Coord[*?], SIMD[dtype, width]) -> None & RegisterPassable & ImplicitlyCopyable
Value-taking counterpart of elementwise_simd_epilogue_type.
A unified closure passed as a runtime value carries the origins of its captures, so the buffers it writes stay alive until the convolution that calls it returns.
elementwise_simd_epilogue_type
comptime elementwise_simd_epilogue_type = def[dtype: DType, width: SIMDLength, alignment: Int = Int(1)](Coord[*?], SIMD[dtype, width]) capturing thin -> None
Fused elementwise epilogue for convolution: (coord, value) -> None.
The coordinate is rank-N in the output's own space (NHWC / NDHWC), unlike
linalg.utils.elementwise_epilogue_type, which is always rank 2. The Coord
carries its own rank.
Structs
-
ConvAlgorithm: Tags the convolution algorithm selected for a given operation. -
ConvInfoStatic: Holds statically known convolution attributes (padding, stride, dilation, groups). -
ConvPartition: Work range for a partition. -
ConvShape: A shape struct describing the convolution dimensions. -
NoConvEpilogue: Stands in for aConvEpilogueFnargument on code paths that apply no epilogue.
Functions
-
align_down_residual: Returns the remainder after aligning down value to alignment. -
append_shape: Append input shape by insertinglast2ndandlastat the end. -
extend_shape: Extend input shape by insertingfirstandlastat both ends. -
get_conv_num_partitions: Partition the workload in (batch, C, F, HOWO) dimensions. HOWO is the combination of HO and WO dimensions. The actual number of tasks are the product of return num_partitions. -
get_conv_num_tasks: Returns the number of tasks to partition the convolution into. -
get_conv_shape: Builds aConvShapefrom the output, input, and filter tile tensors. -
get_conv_tile_shape: Compute the (c, f) tile shape in L2. -
get_conv_tile_size: Returns the convolution L2 cache tile size in elements for the target. -
get_direct_conv_micro_kernel_height: Returns the micro-kernel height for direct convolution on the target CPU. -
get_direct_conv_micro_kernel_width: Returns the micro-kernel width for direct convolution on the target CPU. -
get_micro_kernel_shape: Selects the(height, width)micro-kernel tile shape for the target. -
get_partition: Computes theConvPartitionwork range for a given task id. -
reorder_padding: Reorders padding entries into(lower, upper)pairs per dimension.