Mojo module
functional
Implements higher-order functions.
You can import these APIs from the algorithm
package. For example:
from algorithm import map
from algorithm import map
Aliasesβ
- β
BinaryTile1DTileUnitFunc = fn[Int](Int, Int) capturing -> None
: Signature of a tiled function that performs some work with a dynamic tile size and a secondary static tile size. - β
Dynamic1DTileUnitFunc = fn(Int, Int) capturing -> None
: Signature of a 1d tiled function that performs some work with a dynamic tile size and an offset. i.e. func(offset: Int, tile_size: Int) - β
Dynamic1DTileUnswitchUnitFunc = fn[Bool](Int, Int, Int) capturing -> None
: - β
Static1DTileUnitFunc = fn[Int](Int) capturing -> None
: Signature of a 1d tiled function that performs some work with a static tile size and an offset. i.e. func<tile_size: Int> (offset: Int) - β
Static1DTileUnitFuncWithFlag = fn[Int, Bool](Int) capturing -> None
: - β
Static1DTileUnitFuncWithFlags = fn[Int, Bool, Bool](Int) capturing -> None
: - β
Static1DTileUnswitchUnitFunc = fn[Int, Bool](Int, Int) capturing -> None
: Signature of a tiled function that performs some work with a static tile size and an offset. i.e. func<tile_size: Int> (offset: Int) - β
Static2DTileUnitFunc = fn[Int, Int](Int, Int) capturing -> None
: Signature of a 2d tiled function that performs some work with a static tile size and an offset. i.e. func<tile_size_x: Int, tile_size_y: Int> (offset_x: Int, offset_y: Int) - β
SwitchedFunction = fn[Bool]() capturing -> None
: - β
SwitchedFunction2 = fn[Bool, Bool]() capturing -> None
:
Functionsβ
- β
elementwise
: Executesfunc[width, rank](indices)
, possibly as sub-tasks, for a suitable combination of width and indices so as to cover shape. Returns when all sub-tasks have completed. - β
map
: Maps a function over a range from 0 to size. - β
parallelize
: Executes func(0) ... func(num_work_items-1) as sub-tasks in parallel, and returns when all are complete. - β
parallelize_over_rows
: Parallelize func over non-axis dims of shape. - β
stencil
: Computes stencil operation in parallel. - β
sync_parallelize
: Executes func(0) ... func(num_work_items-1) as parallel sub-tasks, and returns when all are complete. - β
tile
: A generator that launches work groups in specified list of tile sizes. - β
tile_and_unswitch
: Performs time and unswitch functional transformation. - β
tile_middle_unswitch_boundaries
: Divides 1d iteration space into three parts and tiles them with different steps. - β
unswitch
: Performs a functional unswitch transformation. - β
vectorize
: Simplifies SIMD optimized loops by mapping a function across a range from 0 tosize
, incrementing bysimd_width
at each step. The remainder ofsize % simd_width
will run in separate iterations.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
π What went wrong?