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
zero_output
def zero_output[c_type: DType, *, output_tile_shape: Coord[*output_tile_shape.element_types], c_stride: Int, c_N: Int, ComputeFnType: ElementwiseComputeFn = inflated$def[comptime[dtype: DType, width: SIMDLength, *, alignment: Int] #kgen.func.symbol<@linalg::@utils::@"identity_compute_fn[::DType,::SIMDLength,::SIMD[DType.int, 1],KGENParamList[::Intable & ::Defaultable & ::RegisterPassable & ::TrivialRegisterPassable & ::Writable & ::AnyType & ::Copyable & ::ImplicitlyCopyable & ::Deinitable & ::Movable & ::CoordLike],::TypeList[::Intable & ::Defaultable & ::RegisterPassable & ::TrivialRegisterPassable & ::Writable & ::AnyType & ::Copyable & ::ImplicitlyCopyable & ::Deinitable & ::Movable & ::CoordLike, $3]](::Coord[$3, $4],::SIMD[$0, $1])"<:!lit.struct<@std::@builtin::@dtype::@DType> dtype, :!lit.struct<@std::@builtin::@simd_length::@SIMDLength> width, :!lit.struct<@std::@simd::@SIMD<:!lit.struct<@std::@builtin::@dtype::@DType> {:dtype index}, :!lit.struct<@std::@builtin::@simd_length::@SIMDLength> {1}>> alignment, :param_list<trait<@std::@builtin::@int::@Intable, @std::@builtin::@value::@Defaultable, @std::@builtin::@value::@RegisterPassable, @std::@builtin::@value::@TrivialRegisterPassable, @std::@format::@__init__::@Writable, @std::@traits::@anytype::@AnyType, @std::@traits::@copyable::@Copyable, @std::@traits::@copyable::@ImplicitlyCopyable, @std::@traits::@deinitable::@Deinitable, @std::@traits::@movable::@Movable, @std::@utils::@coord::@CoordLike>> *?, :!lit.struct<@std::@builtin::@variadics::@TypeList<:meta<!lit.trait<@std::@traits::@anytype::@AnyType>> trait<@std::@builtin::@int::@Intable, @std::@builtin::@value::@Defaultable, @std::@builtin::@value::@RegisterPassable, @std::@builtin::@value::@TrivialRegisterPassable, @std::@format::@__init__::@Writable, @std::@traits::@anytype::@AnyType, @std::@traits::@copyable::@Copyable, @std::@traits::@copyable::@ImplicitlyCopyable, @std::@traits::@deinitable::@Deinitable, @std::@traits::@movable::@Movable, @std::@utils::@coord::@CoordLike>, :param_list<trait<@std::@builtin::@int::@Intable, @std::@builtin::@value::@Defaultable, @std::@builtin::@value::@RegisterPassable, @std::@builtin::@value::@TrivialRegisterPassable, @std::@format::@__init__::@Writable, @std::@traits::@anytype::@AnyType, @std::@traits::@copyable::@Copyable, @std::@traits::@copyable::@ImplicitlyCopyable, @std::@traits::@deinitable::@Deinitable, @std::@traits::@movable::@Movable, @std::@utils::@coord::@CoordLike>> *?>> *?>>], has_compute_fn: Bool = False](c_ptr: MutPointer[Scalar[c_type], MutAnyOrigin], coord: Tuple[UInt32, UInt32], group_end_idx: UInt32, compute_fn: ComputeFnType)
Zero-fills an output tile for skipped or invalid expert assignments.
Each thread stores a SIMD vector of zeros per row across the output tile width, masking out threads and rows that fall outside the valid tile or group boundary.
Parameters:
- c_type (
DType): Element type of the C output tensor. - output_tile_shape (
Coord[*element_types]): Tile shape[rows, cols]of the output region to zero-fill, where index 0 bounds the row count and index 1 bounds the column count. - c_stride (
Int): Row stride of the C output tensor in elements; the store pointer advances by this amount per row. - c_N (
Int): Total width of the C output tensor in elements; bounds the column offsetcoord[0]to mask out-of-bound stores. - ComputeFnType (
ElementwiseComputeFn): Type ofcompute_fn. - has_compute_fn (
Bool): Whethercompute_fnmaps the zeros before they are stored, as it would an unfused zero output (defaults to False).
Args:
- c_ptr (
MutPointer[Scalar[c_type], MutAnyOrigin]): Base pointer to the C output tensor in global memory. - coord (
Tuple[UInt32, UInt32]):(m, n)element coordinates of the output tile origin, wherecoord[0]is the column offset andcoord[1]is the row offset. - group_end_idx (
UInt32): Exclusive end of the current group's valid row range; bounds the number of rows zeroed. - compute_fn (
ComputeFnType): Maps each zero vector whenhas_compute_fnis set.