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.RuntimeTensorSpec/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[IOUnknown, static_spec=_get_unknown_tensor_spec[dtype, rank]()]
Parametersβ
- βdtype (
DType): - βrank (
Int):
FusedInputβ
comptime FusedInput = IOSpec()
FusedOutputβ
comptime FusedOutput = IOSpec()
Inputβ
comptime Input = IOSpec()
InputTensorβ
comptime InputTensor = ManagedTensorSlice[Input, static_spec=?]
InputVariadicTensorsβ
comptime InputVariadicTensors = VariadicTensors[?, Input, static_specs=?]
IOUnknownβ
comptime IOUnknown = IOSpec()
MutableInputβ
comptime MutableInput = IOSpec()
Outputβ
comptime Output = IOSpec()
OutputTensorβ
comptime OutputTensor = ManagedTensorSlice[Output, static_spec=?]
OutputVariadicTensorsβ
comptime OutputVariadicTensors = VariadicTensors[?, Output, static_specs=?]
Structsβ
- β
IO: - β
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. - β
RuntimeTensorSpec: - β
StaticTensorSpec: - β
StaticTensorSpecInternal: - β
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. - β
ElementwiseFusion: Trait for pure elementwise fusion structs 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.
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!