For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo module
managed_tensor_slice
ManagedTensorSlice and the types kernel authors compose against.
A custom kernel's entry-point signature uses these:
ManagedTensorSlice: view of a tensor argument.IOSpec(andIO): input/output/mutability annotations.StaticTensorSpec: runtime + compile-time tensor metadata.- Fusion traits (
InputFusion,OutputFusion, ...) and their_NoFusion*sentinels.
The decorators that register a kernel (register, register_internal,
view_kernel) live next to this file in register.mojo.
comptime valuesβ
DynamicTensorβ
comptime DynamicTensor[dtype: DType, rank: Int] = ManagedTensorSlice[IOSpec[_, _].Unknown, static_spec=_get_unknown_tensor_spec[dtype, rank]()]
Parametersβ
InputTensorβ
comptime InputTensor = ManagedTensorSlice[IOSpec[_, _].Input, static_spec=_]
InputVariadicTensorsβ
comptime InputVariadicTensors = VariadicTensors[_, IOSpec[_, _].Input, static_specs=_]
OutputTensorβ
comptime OutputTensor = ManagedTensorSlice[IOSpec[_, _].Output, static_spec=_]
OutputVariadicTensorsβ
comptime OutputVariadicTensors = VariadicTensors[_, IOSpec[_, _].Output, static_specs=_]
Structsβ
- β
IO: Tags the direction and fusion kind of a tensor argument to a DPS kernel. - β
IOSpec: Parameter used to encode whether a particular tensor argument to a DPS kernel is an output, input, or mutable input. - β
ManagedTensorSlice: A view of a tensor that does not own the underlying allocated pointer. When the object lifetime ends it does not free the underlying pointer. Conversely, if aManagedTensorSliceis created, it will not extend the life of the underlying pointer. - β
StaticTensorSpec: Carries the compile-time and runtime metadata describing a tensor argument. - β
StaticTensorSpecInternal: Stores the runtime-only portion of aStaticTensorSpec. - β
StaticTensorSpecList: A statically indexable list of data that can be assembled into a StaticTensorSpecList on demand. This handles the complexities that arise with heterogenous specs. - β
VariadicTensors: A tuple-like container of tensors representing variadic arguments from the graph compiler.
Traitsβ
- β
ComputeOutputFusion: Trait for compute-output fusion structs that transform values before storing. - β
ComputeOutputFusionTile: Trait for tile-based compute-output fusion structs that transform a TileTensor before storing. - β
ElementwiseFusion: Trait for pure elementwise fusion structs emitted by the graph compiler. - β
ElementwiseFusionTile: TheTileTensorvariant ofElementwiseFusion: a tile-based pure elementwise fusion struct emitted by the graph compiler. - β
InputFusion: Trait for input fusion structs that provide custom load behavior. - β
OutputFusion: Trait for output fusion structs that provide custom store behavior. - β
OutputFusionTile: Trait for tile-based output fusion structs that provide custom store behavior for aTileTensor.
Functionsβ
- β
foreach: Apply the functionfuncto each element of the tensor slice. - β
get_row_major_tensor_spec_static: Returns a row-major StaticTensorSpec from compile-time Int dimensions. - β
trace_slice_arg: Helper to stringify the type and shape of a kernel argument for tracing.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!