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 trait
TensorOps
Extends TensorStorage with elementwise arithmetic.
A conforming type provides the same non-owning storage handle as
TensorStorage, plus families of in-place (i*) and out-of-place
elementwise operations. Binary and out-of-place unary operations take
their operands as (storage, layout) tuples, so the layout describing a
handle travels alongside it. Out-of-place operations are keyword-only
with dst first.
Implemented traitsβ
comptime membersβ
element_sizeβ
comptime element_size = Int(1)
OffsetResultTypeβ
comptime OffsetResultType[offset_types: TypeList[values]]
The storage type produced by offsetting with a given coordinate.
Parametersβ
- βoffset_types (
TypeList[values]): The coordinate element types of the applied offset.
StorageTypeβ
comptime StorageType[mut: Bool, //, dtype: DType, origin: Origin[mut=mut], address_space: AddressSpace]
The concrete, register-passable handle to the borrowed storage.
Every operation in this trait acts on values of this type. It is
parameterized on the element dtype, the origin that tracks the lifetime
and mutability of the borrowed storage, and the address_space the storage
resides in, so a single conforming type describes a whole family of handles.
Parametersβ
- βmut (
Bool): The mutability of the borrowed storage, inferred fromorigin. - βdtype (
DType): The element data type of the borrowed storage. - βorigin (
Origin[mut=mut]): The origin tracking the lifetime of the borrowed storage. - βaddress_space (
AddressSpace): The address space the borrowed storage resides in.
Required methodsβ
iaddβ
static def iadd[SelfLayoutType: TensorLayout, self_origin: MutOrigin, self_address_space: AddressSpace, OtherLayoutType: TensorLayout, other_mut: Bool, other_origin: Origin[mut=other_mut], other_address_space: AddressSpace, //, dtype: DType, OtherStorage: TensorStorage](storage: Tuple[Self.StorageType[True, origin_of(self_origin), dtype, self_origin, self_address_space], SelfLayoutType], other: Tuple[OtherStorage.StorageType[other_mut, origin_of(other_origin), dtype, other_origin, other_address_space], OtherLayoutType])
Adds other into storage elementwise, in place.
Parameters:
- βSelfLayoutType (
TensorLayout): The layout type of the destination storage. - βself_origin (
MutOrigin): The origin of the destination storage. - βself_address_space (
AddressSpace): The address space of the destination storage. - βOtherLayoutType (
TensorLayout): The layout type of the right-hand storage operand. - βother_mut (
Bool): The mutability of the right-hand storage operand. - βother_origin (
Origin[mut=other_mut]): The origin of the right-hand storage operand. - βother_address_space (
AddressSpace): The address space of the right-hand storage operand. - βdtype (
DType): The element data type of both storages. - βOtherStorage (
TensorStorage): The storage policy of the right-hand operand. May differ fromSelfas long as the two policies have the same logical element size.
Args:
- βstorage (
Tuple[_Self.StorageType[True, origin_of(self_origin), dtype, self_origin, self_address_space], SelfLayoutType]): A tuple of the destination storage (modified in place) and its layout. - βother (
Tuple[OtherStorage.StorageType[other_mut, origin_of(other_origin), dtype, other_origin, other_address_space], OtherLayoutType]): A tuple of the right-hand storage operand and its layout.
imulβ
static def imul[SelfLayoutType: TensorLayout, self_origin: MutOrigin, self_address_space: AddressSpace, OtherLayoutType: TensorLayout, other_mut: Bool, other_origin: Origin[mut=other_mut], other_address_space: AddressSpace, //, dtype: DType, OtherStorage: TensorStorage](storage: Tuple[Self.StorageType[True, origin_of(self_origin), dtype, self_origin, self_address_space], SelfLayoutType], other: Tuple[OtherStorage.StorageType[other_mut, origin_of(other_origin), dtype, other_origin, other_address_space], OtherLayoutType])
Multiplies storage by other elementwise, in place.
Parameters:
- βSelfLayoutType (
TensorLayout): The layout type of the destination storage. - βself_origin (
MutOrigin): The origin of the destination storage. - βself_address_space (
AddressSpace): The address space of the destination storage. - βOtherLayoutType (
TensorLayout): The layout type of the right-hand storage operand. - βother_mut (
Bool): The mutability of the right-hand storage operand. - βother_origin (
Origin[mut=other_mut]): The origin of the right-hand storage operand. - βother_address_space (
AddressSpace): The address space of the right-hand storage operand. - βdtype (
DType): The element data type of both storages. - βOtherStorage (
TensorStorage): The storage policy of the right-hand operand. May differ fromSelfas long as the two policies have the same logical element size.
Args:
- βstorage (
Tuple[_Self.StorageType[True, origin_of(self_origin), dtype, self_origin, self_address_space], SelfLayoutType]): A tuple of the destination storage (modified in place) and its layout. - βother (
Tuple[OtherStorage.StorageType[other_mut, origin_of(other_origin), dtype, other_origin, other_address_space], OtherLayoutType]): A tuple of the right-hand storage operand and its layout.
isubβ
static def isub[SelfLayoutType: TensorLayout, self_origin: MutOrigin, self_address_space: AddressSpace, OtherLayoutType: TensorLayout, other_mut: Bool, other_origin: Origin[mut=other_mut], other_address_space: AddressSpace, //, dtype: DType, OtherStorage: TensorStorage](storage: Tuple[Self.StorageType[True, origin_of(self_origin), dtype, self_origin, self_address_space], SelfLayoutType], other: Tuple[OtherStorage.StorageType[other_mut, origin_of(other_origin), dtype, other_origin, other_address_space], OtherLayoutType])
Subtracts other from storage elementwise, in place.
Parameters:
- βSelfLayoutType (
TensorLayout): The layout type of the destination storage. - βself_origin (
MutOrigin): The origin of the destination storage. - βself_address_space (
AddressSpace): The address space of the destination storage. - βOtherLayoutType (
TensorLayout): The layout type of the right-hand storage operand. - βother_mut (
Bool): The mutability of the right-hand storage operand. - βother_origin (
Origin[mut=other_mut]): The origin of the right-hand storage operand. - βother_address_space (
AddressSpace): The address space of the right-hand storage operand. - βdtype (
DType): The element data type of both storages. - βOtherStorage (
TensorStorage): The storage policy of the right-hand operand. May differ fromSelfas long as the two policies have the same logical element size.
Args:
- βstorage (
Tuple[_Self.StorageType[True, origin_of(self_origin), dtype, self_origin, self_address_space], SelfLayoutType]): A tuple of the destination storage (modified in place) and its layout. - βother (
Tuple[OtherStorage.StorageType[other_mut, origin_of(other_origin), dtype, other_origin, other_address_space], OtherLayoutType]): A tuple of the right-hand storage operand and its layout.
ifloordivβ
static def ifloordiv[SelfLayoutType: TensorLayout, self_origin: MutOrigin, self_address_space: AddressSpace, OtherLayoutType: TensorLayout, other_mut: Bool, other_origin: Origin[mut=other_mut], other_address_space: AddressSpace, //, dtype: DType, OtherStorage: TensorStorage](storage: Tuple[Self.StorageType[True, origin_of(self_origin), dtype, self_origin, self_address_space], SelfLayoutType], other: Tuple[OtherStorage.StorageType[other_mut, origin_of(other_origin), dtype, other_origin, other_address_space], OtherLayoutType])
Floor-divides storage by other elementwise, in place.
Parameters:
- βSelfLayoutType (
TensorLayout): The layout type of the destination storage. - βself_origin (
MutOrigin): The origin of the destination storage. - βself_address_space (
AddressSpace): The address space of the destination storage. - βOtherLayoutType (
TensorLayout): The layout type of the right-hand storage operand. - βother_mut (
Bool): The mutability of the right-hand storage operand. - βother_origin (
Origin[mut=other_mut]): The origin of the right-hand storage operand. - βother_address_space (
AddressSpace): The address space of the right-hand storage operand. - βdtype (
DType): The element data type of both storages. - βOtherStorage (
TensorStorage): The storage policy of the right-hand operand. May differ fromSelfas long as the two policies have the same logical element size.
Args:
- βstorage (
Tuple[_Self.StorageType[True, origin_of(self_origin), dtype, self_origin, self_address_space], SelfLayoutType]): A tuple of the destination storage (modified in place) and its layout. - βother (
Tuple[OtherStorage.StorageType[other_mut, origin_of(other_origin), dtype, other_origin, other_address_space], OtherLayoutType]): A tuple of the right-hand storage operand and its layout.
itruedivβ
static def itruediv[SelfLayoutType: TensorLayout, self_origin: MutOrigin, self_address_space: AddressSpace, OtherLayoutType: TensorLayout, other_mut: Bool, other_origin: Origin[mut=other_mut], other_address_space: AddressSpace, //, dtype: DType, OtherStorage: TensorStorage](storage: Tuple[Self.StorageType[True, origin_of(self_origin), dtype, self_origin, self_address_space], SelfLayoutType], other: Tuple[OtherStorage.StorageType[other_mut, origin_of(other_origin), dtype, other_origin, other_address_space], OtherLayoutType])
True-divides storage by other elementwise, in place.
Parameters:
- βSelfLayoutType (
TensorLayout): The layout type of the destination storage. - βself_origin (
MutOrigin): The origin of the destination storage. - βself_address_space (
AddressSpace): The address space of the destination storage. - βOtherLayoutType (
TensorLayout): The layout type of the right-hand storage operand. - βother_mut (
Bool): The mutability of the right-hand storage operand. - βother_origin (
Origin[mut=other_mut]): The origin of the right-hand storage operand. - βother_address_space (
AddressSpace): The address space of the right-hand storage operand. - βdtype (
DType): The element data type of both storages. - βOtherStorage (
TensorStorage): The storage policy of the right-hand operand. May differ fromSelfas long as the two policies have the same logical element size.
Args:
- βstorage (
Tuple[_Self.StorageType[True, origin_of(self_origin), dtype, self_origin, self_address_space], SelfLayoutType]): A tuple of the destination storage (modified in place) and its layout. - βother (
Tuple[OtherStorage.StorageType[other_mut, origin_of(other_origin), dtype, other_origin, other_address_space], OtherLayoutType]): A tuple of the right-hand storage operand and its layout.
iminβ
static def imin[SelfLayoutType: TensorLayout, self_origin: MutOrigin, self_address_space: AddressSpace, OtherLayoutType: TensorLayout, other_mut: Bool, other_origin: Origin[mut=other_mut], other_address_space: AddressSpace, //, dtype: DType, OtherStorage: TensorStorage](storage: Tuple[Self.StorageType[True, origin_of(self_origin), dtype, self_origin, self_address_space], SelfLayoutType], other: Tuple[OtherStorage.StorageType[other_mut, origin_of(other_origin), dtype, other_origin, other_address_space], OtherLayoutType])
Takes the elementwise minimum of storage and other, in place.
Parameters:
- βSelfLayoutType (
TensorLayout): The layout type of the destination storage. - βself_origin (
MutOrigin): The origin of the destination storage. - βself_address_space (
AddressSpace): The address space of the destination storage. - βOtherLayoutType (
TensorLayout): The layout type of the right-hand storage operand. - βother_mut (
Bool): The mutability of the right-hand storage operand. - βother_origin (
Origin[mut=other_mut]): The origin of the right-hand storage operand. - βother_address_space (
AddressSpace): The address space of the right-hand storage operand. - βdtype (
DType): The element data type of both storages. - βOtherStorage (
TensorStorage): The storage policy of the right-hand operand. May differ fromSelfas long as the two policies have the same logical element size.
Args:
- βstorage (
Tuple[_Self.StorageType[True, origin_of(self_origin), dtype, self_origin, self_address_space], SelfLayoutType]): A tuple of the destination storage (modified in place) and its layout. - βother (
Tuple[OtherStorage.StorageType[other_mut, origin_of(other_origin), dtype, other_origin, other_address_space], OtherLayoutType]): A tuple of the right-hand storage operand and its layout.
imaxβ
static def imax[SelfLayoutType: TensorLayout, self_origin: MutOrigin, self_address_space: AddressSpace, OtherLayoutType: TensorLayout, other_mut: Bool, other_origin: Origin[mut=other_mut], other_address_space: AddressSpace, //, dtype: DType, OtherStorage: TensorStorage](storage: Tuple[Self.StorageType[True, origin_of(self_origin), dtype, self_origin, self_address_space], SelfLayoutType], other: Tuple[OtherStorage.StorageType[other_mut, origin_of(other_origin), dtype, other_origin, other_address_space], OtherLayoutType])
Takes the elementwise maximum of storage and other, in place.
Parameters:
- βSelfLayoutType (
TensorLayout): The layout type of the destination storage. - βself_origin (
MutOrigin): The origin of the destination storage. - βself_address_space (
AddressSpace): The address space of the destination storage. - βOtherLayoutType (
TensorLayout): The layout type of the right-hand storage operand. - βother_mut (
Bool): The mutability of the right-hand storage operand. - βother_origin (
Origin[mut=other_mut]): The origin of the right-hand storage operand. - βother_address_space (
AddressSpace): The address space of the right-hand storage operand. - βdtype (
DType): The element data type of both storages. - βOtherStorage (
TensorStorage): The storage policy of the right-hand operand. May differ fromSelfas long as the two policies have the same logical element size.
Args:
- βstorage (
Tuple[_Self.StorageType[True, origin_of(self_origin), dtype, self_origin, self_address_space], SelfLayoutType]): A tuple of the destination storage (modified in place) and its layout. - βother (
Tuple[OtherStorage.StorageType[other_mut, origin_of(other_origin), dtype, other_origin, other_address_space], OtherLayoutType]): A tuple of the right-hand storage operand and its layout.
iabsβ
static def iabs[dtype: DType, //](storage: Self.StorageType[True, origin_of(origin), dtype, origin, address_space], layout: T)
Takes the elementwise absolute value of storage, in place.
For unsigned dtypes this is the identity.
Parameters:
- βdtype (
DType): The element data type of the storage.
Args:
- βstorage (
_Self.StorageType[True, origin_of(origin), dtype, origin, address_space]): The storage to modify in place. - βlayout (
T): The layout describing the storage's elements.
irecipβ
static def irecip[dtype: DType, //](storage: Self.StorageType[True, origin_of(origin), dtype, origin, address_space], layout: T)
Replaces each element of storage with its reciprocal, in place.
Elements equal to zero produce infinity, following IEEE 754 division semantics.
Parameters:
- βdtype (
DType): The element data type of the storage. Must be a floating-point type.
Args:
- βstorage (
_Self.StorageType[True, origin_of(origin), dtype, origin, address_space]): The storage to modify in place. - βlayout (
T): The layout describing the storage's elements.
iexpβ
static def iexp[dtype: DType, scale_dtype: DType = dtype, //, scale: Scalar[scale_dtype]](storage: Self.StorageType[True, origin_of(origin), dtype, origin, address_space], layout: T)
Replaces each element x of storage with exp(scale * x), in place.
The scale factor is applied before exponentiation so that scaled
exponentials (for example softmax logit scaling) fuse into a single
pass over the elements. Pass a scale of 1 for a plain exponential.
Parameters:
- βdtype (
DType): The element data type of the storage. Must be a floating-point type. - βscale_dtype (
DType): The data type of the scale factor. Defaults todtype; the scale is cast todtypebefore the multiplication. - βscale (
Scalar[scale_dtype]): The compile-time factor each element is multiplied by before exponentiation.
Args:
- βstorage (
_Self.StorageType[True, origin_of(origin), dtype, origin, address_space]): The storage to modify in place. - βlayout (
T): The layout describing the storage's elements.
addβ
static def add[DstLayoutType: TensorLayout, dst_origin: MutOrigin, dst_address_space: AddressSpace, LhsLayoutType: TensorLayout, lhs_mut: Bool, lhs_origin: Origin[mut=lhs_mut], lhs_address_space: AddressSpace, RhsLayoutType: TensorLayout, rhs_mut: Bool, rhs_origin: Origin[mut=rhs_mut], rhs_address_space: AddressSpace, //, dtype: DType, LhsStorage: TensorStorage, RhsStorage: TensorStorage](*, dst: Tuple[Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType], lhs: Tuple[LhsStorage.StorageType[lhs_mut, origin_of(lhs_origin), dtype, lhs_origin, lhs_address_space], LhsLayoutType], rhs: Tuple[RhsStorage.StorageType[rhs_mut, origin_of(rhs_origin), dtype, rhs_origin, rhs_address_space], RhsLayoutType])
Adds lhs and rhs elementwise, writing into dst.
Parameters:
- βDstLayoutType (
TensorLayout): The layout type of the destination storage. - βdst_origin (
MutOrigin): The origin of the destination storage. - βdst_address_space (
AddressSpace): The address space of the destination storage. - βLhsLayoutType (
TensorLayout): The layout type of the left-hand storage operand. - βlhs_mut (
Bool): The mutability of the left-hand storage operand. - βlhs_origin (
Origin[mut=lhs_mut]): The origin of the left-hand storage operand. - βlhs_address_space (
AddressSpace): The address space of the left-hand storage operand. - βRhsLayoutType (
TensorLayout): The layout type of the right-hand storage operand. - βrhs_mut (
Bool): The mutability of the right-hand storage operand. - βrhs_origin (
Origin[mut=rhs_mut]): The origin of the right-hand storage operand. - βrhs_address_space (
AddressSpace): The address space of the right-hand storage operand. - βdtype (
DType): The element data type of all three storages. - βLhsStorage (
TensorStorage): The storage policy of the left-hand operand. May differ fromSelfas long as the policies have the same logical element size. - βRhsStorage (
TensorStorage): The storage policy of the right-hand operand. May differ fromSelfas long as the policies have the same logical element size.
Args:
- βdst (
Tuple[_Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType]): A tuple of the destination storage and its layout. - βlhs (
Tuple[LhsStorage.StorageType[lhs_mut, origin_of(lhs_origin), dtype, lhs_origin, lhs_address_space], LhsLayoutType]): A tuple of the left-hand storage operand and its layout. - βrhs (
Tuple[RhsStorage.StorageType[rhs_mut, origin_of(rhs_origin), dtype, rhs_origin, rhs_address_space], RhsLayoutType]): A tuple of the right-hand storage operand and its layout.
mulβ
static def mul[DstLayoutType: TensorLayout, dst_origin: MutOrigin, dst_address_space: AddressSpace, LhsLayoutType: TensorLayout, lhs_mut: Bool, lhs_origin: Origin[mut=lhs_mut], lhs_address_space: AddressSpace, RhsLayoutType: TensorLayout, rhs_mut: Bool, rhs_origin: Origin[mut=rhs_mut], rhs_address_space: AddressSpace, //, dtype: DType, LhsStorage: TensorStorage, RhsStorage: TensorStorage](*, dst: Tuple[Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType], lhs: Tuple[LhsStorage.StorageType[lhs_mut, origin_of(lhs_origin), dtype, lhs_origin, lhs_address_space], LhsLayoutType], rhs: Tuple[RhsStorage.StorageType[rhs_mut, origin_of(rhs_origin), dtype, rhs_origin, rhs_address_space], RhsLayoutType])
Multiplies lhs by rhs elementwise, writing into dst.
Parameters:
- βDstLayoutType (
TensorLayout): The layout type of the destination storage. - βdst_origin (
MutOrigin): The origin of the destination storage. - βdst_address_space (
AddressSpace): The address space of the destination storage. - βLhsLayoutType (
TensorLayout): The layout type of the left-hand storage operand. - βlhs_mut (
Bool): The mutability of the left-hand storage operand. - βlhs_origin (
Origin[mut=lhs_mut]): The origin of the left-hand storage operand. - βlhs_address_space (
AddressSpace): The address space of the left-hand storage operand. - βRhsLayoutType (
TensorLayout): The layout type of the right-hand storage operand. - βrhs_mut (
Bool): The mutability of the right-hand storage operand. - βrhs_origin (
Origin[mut=rhs_mut]): The origin of the right-hand storage operand. - βrhs_address_space (
AddressSpace): The address space of the right-hand storage operand. - βdtype (
DType): The element data type of all three storages. - βLhsStorage (
TensorStorage): The storage policy of the left-hand operand. May differ fromSelfas long as the policies have the same logical element size. - βRhsStorage (
TensorStorage): The storage policy of the right-hand operand. May differ fromSelfas long as the policies have the same logical element size.
Args:
- βdst (
Tuple[_Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType]): A tuple of the destination storage and its layout. - βlhs (
Tuple[LhsStorage.StorageType[lhs_mut, origin_of(lhs_origin), dtype, lhs_origin, lhs_address_space], LhsLayoutType]): A tuple of the left-hand storage operand and its layout. - βrhs (
Tuple[RhsStorage.StorageType[rhs_mut, origin_of(rhs_origin), dtype, rhs_origin, rhs_address_space], RhsLayoutType]): A tuple of the right-hand storage operand and its layout.
subβ
static def sub[DstLayoutType: TensorLayout, dst_origin: MutOrigin, dst_address_space: AddressSpace, LhsLayoutType: TensorLayout, lhs_mut: Bool, lhs_origin: Origin[mut=lhs_mut], lhs_address_space: AddressSpace, RhsLayoutType: TensorLayout, rhs_mut: Bool, rhs_origin: Origin[mut=rhs_mut], rhs_address_space: AddressSpace, //, dtype: DType, LhsStorage: TensorStorage, RhsStorage: TensorStorage](*, dst: Tuple[Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType], lhs: Tuple[LhsStorage.StorageType[lhs_mut, origin_of(lhs_origin), dtype, lhs_origin, lhs_address_space], LhsLayoutType], rhs: Tuple[RhsStorage.StorageType[rhs_mut, origin_of(rhs_origin), dtype, rhs_origin, rhs_address_space], RhsLayoutType])
Subtracts rhs from lhs elementwise, writing into dst.
Parameters:
- βDstLayoutType (
TensorLayout): The layout type of the destination storage. - βdst_origin (
MutOrigin): The origin of the destination storage. - βdst_address_space (
AddressSpace): The address space of the destination storage. - βLhsLayoutType (
TensorLayout): The layout type of the left-hand storage operand. - βlhs_mut (
Bool): The mutability of the left-hand storage operand. - βlhs_origin (
Origin[mut=lhs_mut]): The origin of the left-hand storage operand. - βlhs_address_space (
AddressSpace): The address space of the left-hand storage operand. - βRhsLayoutType (
TensorLayout): The layout type of the right-hand storage operand. - βrhs_mut (
Bool): The mutability of the right-hand storage operand. - βrhs_origin (
Origin[mut=rhs_mut]): The origin of the right-hand storage operand. - βrhs_address_space (
AddressSpace): The address space of the right-hand storage operand. - βdtype (
DType): The element data type of all three storages. - βLhsStorage (
TensorStorage): The storage policy of the left-hand operand. May differ fromSelfas long as the policies have the same logical element size. - βRhsStorage (
TensorStorage): The storage policy of the right-hand operand. May differ fromSelfas long as the policies have the same logical element size.
Args:
- βdst (
Tuple[_Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType]): A tuple of the destination storage and its layout. - βlhs (
Tuple[LhsStorage.StorageType[lhs_mut, origin_of(lhs_origin), dtype, lhs_origin, lhs_address_space], LhsLayoutType]): A tuple of the left-hand storage operand and its layout. - βrhs (
Tuple[RhsStorage.StorageType[rhs_mut, origin_of(rhs_origin), dtype, rhs_origin, rhs_address_space], RhsLayoutType]): A tuple of the right-hand storage operand and its layout.
floordivβ
static def floordiv[DstLayoutType: TensorLayout, dst_origin: MutOrigin, dst_address_space: AddressSpace, LhsLayoutType: TensorLayout, lhs_mut: Bool, lhs_origin: Origin[mut=lhs_mut], lhs_address_space: AddressSpace, RhsLayoutType: TensorLayout, rhs_mut: Bool, rhs_origin: Origin[mut=rhs_mut], rhs_address_space: AddressSpace, //, dtype: DType, LhsStorage: TensorStorage, RhsStorage: TensorStorage](*, dst: Tuple[Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType], lhs: Tuple[LhsStorage.StorageType[lhs_mut, origin_of(lhs_origin), dtype, lhs_origin, lhs_address_space], LhsLayoutType], rhs: Tuple[RhsStorage.StorageType[rhs_mut, origin_of(rhs_origin), dtype, rhs_origin, rhs_address_space], RhsLayoutType])
Floor-divides lhs by rhs elementwise, writing into dst.
Parameters:
- βDstLayoutType (
TensorLayout): The layout type of the destination storage. - βdst_origin (
MutOrigin): The origin of the destination storage. - βdst_address_space (
AddressSpace): The address space of the destination storage. - βLhsLayoutType (
TensorLayout): The layout type of the left-hand storage operand. - βlhs_mut (
Bool): The mutability of the left-hand storage operand. - βlhs_origin (
Origin[mut=lhs_mut]): The origin of the left-hand storage operand. - βlhs_address_space (
AddressSpace): The address space of the left-hand storage operand. - βRhsLayoutType (
TensorLayout): The layout type of the right-hand storage operand. - βrhs_mut (
Bool): The mutability of the right-hand storage operand. - βrhs_origin (
Origin[mut=rhs_mut]): The origin of the right-hand storage operand. - βrhs_address_space (
AddressSpace): The address space of the right-hand storage operand. - βdtype (
DType): The element data type of all three storages. - βLhsStorage (
TensorStorage): The storage policy of the left-hand operand. May differ fromSelfas long as the policies have the same logical element size. - βRhsStorage (
TensorStorage): The storage policy of the right-hand operand. May differ fromSelfas long as the policies have the same logical element size.
Args:
- βdst (
Tuple[_Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType]): A tuple of the destination storage and its layout. - βlhs (
Tuple[LhsStorage.StorageType[lhs_mut, origin_of(lhs_origin), dtype, lhs_origin, lhs_address_space], LhsLayoutType]): A tuple of the left-hand storage operand and its layout. - βrhs (
Tuple[RhsStorage.StorageType[rhs_mut, origin_of(rhs_origin), dtype, rhs_origin, rhs_address_space], RhsLayoutType]): A tuple of the right-hand storage operand and its layout.
truedivβ
static def truediv[DstLayoutType: TensorLayout, dst_origin: MutOrigin, dst_address_space: AddressSpace, LhsLayoutType: TensorLayout, lhs_mut: Bool, lhs_origin: Origin[mut=lhs_mut], lhs_address_space: AddressSpace, RhsLayoutType: TensorLayout, rhs_mut: Bool, rhs_origin: Origin[mut=rhs_mut], rhs_address_space: AddressSpace, //, dtype: DType, LhsStorage: TensorStorage, RhsStorage: TensorStorage](*, dst: Tuple[Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType], lhs: Tuple[LhsStorage.StorageType[lhs_mut, origin_of(lhs_origin), dtype, lhs_origin, lhs_address_space], LhsLayoutType], rhs: Tuple[RhsStorage.StorageType[rhs_mut, origin_of(rhs_origin), dtype, rhs_origin, rhs_address_space], RhsLayoutType])
True-divides lhs by rhs elementwise, writing into dst.
Parameters:
- βDstLayoutType (
TensorLayout): The layout type of the destination storage. - βdst_origin (
MutOrigin): The origin of the destination storage. - βdst_address_space (
AddressSpace): The address space of the destination storage. - βLhsLayoutType (
TensorLayout): The layout type of the left-hand storage operand. - βlhs_mut (
Bool): The mutability of the left-hand storage operand. - βlhs_origin (
Origin[mut=lhs_mut]): The origin of the left-hand storage operand. - βlhs_address_space (
AddressSpace): The address space of the left-hand storage operand. - βRhsLayoutType (
TensorLayout): The layout type of the right-hand storage operand. - βrhs_mut (
Bool): The mutability of the right-hand storage operand. - βrhs_origin (
Origin[mut=rhs_mut]): The origin of the right-hand storage operand. - βrhs_address_space (
AddressSpace): The address space of the right-hand storage operand. - βdtype (
DType): The element data type of all three storages. - βLhsStorage (
TensorStorage): The storage policy of the left-hand operand. May differ fromSelfas long as the policies have the same logical element size. - βRhsStorage (
TensorStorage): The storage policy of the right-hand operand. May differ fromSelfas long as the policies have the same logical element size.
Args:
- βdst (
Tuple[_Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType]): A tuple of the destination storage and its layout. - βlhs (
Tuple[LhsStorage.StorageType[lhs_mut, origin_of(lhs_origin), dtype, lhs_origin, lhs_address_space], LhsLayoutType]): A tuple of the left-hand storage operand and its layout. - βrhs (
Tuple[RhsStorage.StorageType[rhs_mut, origin_of(rhs_origin), dtype, rhs_origin, rhs_address_space], RhsLayoutType]): A tuple of the right-hand storage operand and its layout.
minβ
static def min[DstLayoutType: TensorLayout, dst_origin: MutOrigin, dst_address_space: AddressSpace, LhsLayoutType: TensorLayout, lhs_mut: Bool, lhs_origin: Origin[mut=lhs_mut], lhs_address_space: AddressSpace, RhsLayoutType: TensorLayout, rhs_mut: Bool, rhs_origin: Origin[mut=rhs_mut], rhs_address_space: AddressSpace, //, dtype: DType, LhsStorage: TensorStorage, RhsStorage: TensorStorage](*, dst: Tuple[Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType], lhs: Tuple[LhsStorage.StorageType[lhs_mut, origin_of(lhs_origin), dtype, lhs_origin, lhs_address_space], LhsLayoutType], rhs: Tuple[RhsStorage.StorageType[rhs_mut, origin_of(rhs_origin), dtype, rhs_origin, rhs_address_space], RhsLayoutType])
Takes the elementwise minimum of lhs and rhs, writing into dst.
Parameters:
- βDstLayoutType (
TensorLayout): The layout type of the destination storage. - βdst_origin (
MutOrigin): The origin of the destination storage. - βdst_address_space (
AddressSpace): The address space of the destination storage. - βLhsLayoutType (
TensorLayout): The layout type of the left-hand storage operand. - βlhs_mut (
Bool): The mutability of the left-hand storage operand. - βlhs_origin (
Origin[mut=lhs_mut]): The origin of the left-hand storage operand. - βlhs_address_space (
AddressSpace): The address space of the left-hand storage operand. - βRhsLayoutType (
TensorLayout): The layout type of the right-hand storage operand. - βrhs_mut (
Bool): The mutability of the right-hand storage operand. - βrhs_origin (
Origin[mut=rhs_mut]): The origin of the right-hand storage operand. - βrhs_address_space (
AddressSpace): The address space of the right-hand storage operand. - βdtype (
DType): The element data type of all three storages. - βLhsStorage (
TensorStorage): The storage policy of the left-hand operand. May differ fromSelfas long as the policies have the same logical element size. - βRhsStorage (
TensorStorage): The storage policy of the right-hand operand. May differ fromSelfas long as the policies have the same logical element size.
Args:
- βdst (
Tuple[_Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType]): A tuple of the destination storage and its layout. - βlhs (
Tuple[LhsStorage.StorageType[lhs_mut, origin_of(lhs_origin), dtype, lhs_origin, lhs_address_space], LhsLayoutType]): A tuple of the left-hand storage operand and its layout. - βrhs (
Tuple[RhsStorage.StorageType[rhs_mut, origin_of(rhs_origin), dtype, rhs_origin, rhs_address_space], RhsLayoutType]): A tuple of the right-hand storage operand and its layout.
maxβ
static def max[DstLayoutType: TensorLayout, dst_origin: MutOrigin, dst_address_space: AddressSpace, LhsLayoutType: TensorLayout, lhs_mut: Bool, lhs_origin: Origin[mut=lhs_mut], lhs_address_space: AddressSpace, RhsLayoutType: TensorLayout, rhs_mut: Bool, rhs_origin: Origin[mut=rhs_mut], rhs_address_space: AddressSpace, //, dtype: DType, LhsStorage: TensorStorage, RhsStorage: TensorStorage](*, dst: Tuple[Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType], lhs: Tuple[LhsStorage.StorageType[lhs_mut, origin_of(lhs_origin), dtype, lhs_origin, lhs_address_space], LhsLayoutType], rhs: Tuple[RhsStorage.StorageType[rhs_mut, origin_of(rhs_origin), dtype, rhs_origin, rhs_address_space], RhsLayoutType])
Takes the elementwise maximum of lhs and rhs, writing into dst.
Parameters:
- βDstLayoutType (
TensorLayout): The layout type of the destination storage. - βdst_origin (
MutOrigin): The origin of the destination storage. - βdst_address_space (
AddressSpace): The address space of the destination storage. - βLhsLayoutType (
TensorLayout): The layout type of the left-hand storage operand. - βlhs_mut (
Bool): The mutability of the left-hand storage operand. - βlhs_origin (
Origin[mut=lhs_mut]): The origin of the left-hand storage operand. - βlhs_address_space (
AddressSpace): The address space of the left-hand storage operand. - βRhsLayoutType (
TensorLayout): The layout type of the right-hand storage operand. - βrhs_mut (
Bool): The mutability of the right-hand storage operand. - βrhs_origin (
Origin[mut=rhs_mut]): The origin of the right-hand storage operand. - βrhs_address_space (
AddressSpace): The address space of the right-hand storage operand. - βdtype (
DType): The element data type of all three storages. - βLhsStorage (
TensorStorage): The storage policy of the left-hand operand. May differ fromSelfas long as the policies have the same logical element size. - βRhsStorage (
TensorStorage): The storage policy of the right-hand operand. May differ fromSelfas long as the policies have the same logical element size.
Args:
- βdst (
Tuple[_Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType]): A tuple of the destination storage and its layout. - βlhs (
Tuple[LhsStorage.StorageType[lhs_mut, origin_of(lhs_origin), dtype, lhs_origin, lhs_address_space], LhsLayoutType]): A tuple of the left-hand storage operand and its layout. - βrhs (
Tuple[RhsStorage.StorageType[rhs_mut, origin_of(rhs_origin), dtype, rhs_origin, rhs_address_space], RhsLayoutType]): A tuple of the right-hand storage operand and its layout.
absβ
static def abs[DstLayoutType: TensorLayout, dst_origin: MutOrigin, dst_address_space: AddressSpace, SrcLayoutType: TensorLayout, src_mut: Bool, src_origin: Origin[mut=src_mut], src_address_space: AddressSpace, //, dtype: DType, SrcStorage: TensorStorage](*, dst: Tuple[Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType], src: Tuple[SrcStorage.StorageType[src_mut, origin_of(src_origin), dtype, src_origin, src_address_space], SrcLayoutType])
Takes the elementwise absolute value of src, writing into dst.
For unsigned dtypes this is the identity.
Parameters:
- βDstLayoutType (
TensorLayout): The layout type of the destination storage. - βdst_origin (
MutOrigin): The origin of the destination storage. - βdst_address_space (
AddressSpace): The address space of the destination storage. - βSrcLayoutType (
TensorLayout): The layout type of the source storage. - βsrc_mut (
Bool): The mutability of the source storage. - βsrc_origin (
Origin[mut=src_mut]): The origin of the source storage. - βsrc_address_space (
AddressSpace): The address space of the source storage. - βdtype (
DType): The element data type of both storages. - βSrcStorage (
TensorStorage): The storage policy of the source. May differ fromSelfas long as the two policies have the same logical element size.
Args:
- βdst (
Tuple[_Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType]): A tuple of the destination storage and its layout. - βsrc (
Tuple[SrcStorage.StorageType[src_mut, origin_of(src_origin), dtype, src_origin, src_address_space], SrcLayoutType]): A tuple of the source storage and its layout.
recipβ
static def recip[DstLayoutType: TensorLayout, dst_origin: MutOrigin, dst_address_space: AddressSpace, SrcLayoutType: TensorLayout, src_mut: Bool, src_origin: Origin[mut=src_mut], src_address_space: AddressSpace, //, dtype: DType, SrcStorage: TensorStorage](*, dst: Tuple[Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType], src: Tuple[SrcStorage.StorageType[src_mut, origin_of(src_origin), dtype, src_origin, src_address_space], SrcLayoutType])
Writes the reciprocal of each element of src into dst.
Elements equal to zero produce infinity, following IEEE 754 division semantics.
Parameters:
- βDstLayoutType (
TensorLayout): The layout type of the destination storage. - βdst_origin (
MutOrigin): The origin of the destination storage. - βdst_address_space (
AddressSpace): The address space of the destination storage. - βSrcLayoutType (
TensorLayout): The layout type of the source storage. - βsrc_mut (
Bool): The mutability of the source storage. - βsrc_origin (
Origin[mut=src_mut]): The origin of the source storage. - βsrc_address_space (
AddressSpace): The address space of the source storage. - βdtype (
DType): The element data type of both storages. - βSrcStorage (
TensorStorage): The storage policy of the source. May differ fromSelfas long as the two policies have the same logical element size.
Args:
- βdst (
Tuple[_Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType]): A tuple of the destination storage and its layout. - βsrc (
Tuple[SrcStorage.StorageType[src_mut, origin_of(src_origin), dtype, src_origin, src_address_space], SrcLayoutType]): A tuple of the source storage and its layout.
expβ
static def exp[DstLayoutType: TensorLayout, dst_origin: MutOrigin, dst_address_space: AddressSpace, SrcLayoutType: TensorLayout, src_mut: Bool, src_origin: Origin[mut=src_mut], src_address_space: AddressSpace, dtype: DType, SrcStorage: TensorStorage, scale_dtype: DType = dtype, //, scale: Scalar[scale_dtype] = 1](*, dst: Tuple[Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType], src: Tuple[SrcStorage.StorageType[src_mut, origin_of(src_origin), dtype, src_origin, src_address_space], SrcLayoutType])
Writes exp(scale * x) for each element x of src into dst.
The scale factor is applied before exponentiation so that scaled
exponentials (for example softmax logit scaling) fuse into a single
pass over the elements. Pass a scale of 1 for a plain exponential.
Parameters:
- βDstLayoutType (
TensorLayout): The layout type of the destination storage. - βdst_origin (
MutOrigin): The origin of the destination storage. - βdst_address_space (
AddressSpace): The address space of the destination storage. - βSrcLayoutType (
TensorLayout): The layout type of the source storage. - βsrc_mut (
Bool): The mutability of the source storage. - βsrc_origin (
Origin[mut=src_mut]): The origin of the source storage. - βsrc_address_space (
AddressSpace): The address space of the source storage. - βdtype (
DType): The element data type of both storages. Must be a floating-point type. - βSrcStorage (
TensorStorage): The storage policy of the source. May differ fromSelfas long as the two policies have the same logical element size. - βscale_dtype (
DType): The data type of the scale factor. Defaults todtype; the scale is cast todtypebefore the multiplication. - βscale (
Scalar[scale_dtype]): The compile-time factor each element is multiplied by before exponentiation.
Args:
- βdst (
Tuple[_Self.StorageType[True, origin_of(dst_origin), dtype, dst_origin, dst_address_space], DstLayoutType]): A tuple of the destination storage and its layout. - βsrc (
Tuple[SrcStorage.StorageType[src_mut, origin_of(src_origin), dtype, src_origin, src_address_space], SrcLayoutType]): A tuple of the source storage and its layout.
unsafe_castβ
static def unsafe_cast[to_mut: Bool, //, to_dtype: DType, to_origin: Origin[mut=to_mut], to_address_space: AddressSpace](storage: Self.StorageType[origin.mut, origin_of(origin), dtype, origin, address_space]) -> Self.StorageType[to_mut, origin_of(to_origin), to_dtype, to_origin, to_address_space]
Reinterprets a storage handle with new type parameters.
This performs an unchecked reinterpretation of the underlying reference;
no conversion of the stored elements takes place. The caller is
responsible for ensuring the new dtype, origin, and address_space
are valid for the referenced storage.
Parameters:
- βto_mut (
Bool): The mutability to reinterpret the storage as. - βto_dtype (
DType): The element data type to reinterpret the storage as. - βto_origin (
Origin[mut=to_mut]): The origin to reinterpret the storage as. - βto_address_space (
AddressSpace): The address space to reinterpret the storage as.
Args:
- βstorage (
_Self.StorageType[origin.mut, origin_of(origin), dtype, origin, address_space]): The storage to reinterpret.
Returns:
_Self.StorageType[to_mut, origin_of(to_origin), to_dtype, to_origin, to_address_space]: A handle referring to the same storage, viewed with the new type
parameters.
loadβ
static def load[dtype: DType, //, width: SIMDLength, alignment: Int, invariant: Bool = False, non_temporal: Bool = False](storage: Self.StorageType[False, origin_of(origin), dtype, origin, address_space]) -> SIMD[dtype, width]
Loads a SIMD value from the storage.
Parameters:
- βdtype (
DType): The element data type of the storage. - βwidth (
SIMDLength): The number of elements to load. - βalignment (
Int): The alignment guarantee for the load. - βinvariant (
Bool): If True, the compiler may assume the memory won't be modified during the kernel, enabling load hoisting and caching. - βnon_temporal (
Bool): If True, indicates the data will not be reused soon, allowing the hardware to bypass caches (e.g., streaming loads).
Args:
- βstorage (
_Self.StorageType[False, origin_of(origin), dtype, origin, address_space]): The storage to load from.
Returns:
SIMD[dtype, width]: The loaded SIMD value.
static def load[dtype: DType, //, width: SIMDLength, alignment: Int, invariant: Bool = False, non_temporal: Bool = False](storage: Self.StorageType[False, origin_of(origin), dtype, origin, address_space], offset: T) -> SIMD[dtype, width]
Loads a SIMD value at a scalar-element offset from the storage.
Parameters:
- βdtype (
DType): The element data type of the storage. - βwidth (
SIMDLength): The number of elements to load. - βalignment (
Int): The alignment guarantee for the load. - βinvariant (
Bool): If True, the compiler may assume the memory won't be modified during the kernel, enabling load hoisting and caching. - βnon_temporal (
Bool): If True, indicates the data will not be reused soon, allowing the hardware to bypass caches (e.g., streaming loads).
Args:
- βstorage (
_Self.StorageType[False, origin_of(origin), dtype, origin, address_space]): The storage to load from. - βoffset (
T): The scalar-element offset to load at.
Returns:
SIMD[dtype, width]: The loaded SIMD value.
storeβ
static def store[dtype: DType, alignment: Int, *, non_temporal: Bool = False](storage: Self.StorageType[True, origin_of(origin), dtype, origin, address_space], value: SIMD[dtype])
Stores a SIMD value into the storage.
Parameters:
- βdtype (
DType): The element data type of the storage. - βalignment (
Int): The alignment guarantee for the store. - βnon_temporal (
Bool): If True, indicates the data will not be reused soon, allowing the hardware to bypass caches (e.g., streaming stores).
Args:
- βstorage (
_Self.StorageType[True, origin_of(origin), dtype, origin, address_space]): The storage to store into. - βvalue (
SIMD[dtype]): TheSIMDvalue to store.
static def store[dtype: DType, alignment: Int, *, non_temporal: Bool = False](storage: Self.StorageType[True, origin_of(origin), dtype, origin, address_space], offset: T, value: SIMD[dtype])
Stores a SIMD value at a scalar-element offset in the storage.
The caller is responsible for ensuring the storage is actually mutable.
The dtype, origin, and address_space are inferred from the
storage argument for concrete storage types; callers using the trait
through an abstract TensorStorage bound must pass them explicitly
(before alignment).
Parameters:
- βdtype (
DType): The element data type of the storage. - βalignment (
Int): The alignment guarantee for the store. - βnon_temporal (
Bool): If True, indicates the data will not be reused soon, allowing the hardware to bypass caches (e.g., streaming stores).
Args:
- βstorage (
_Self.StorageType[True, origin_of(origin), dtype, origin, address_space]): The storage to store into. - βoffset (
T): The scalar-element offset to store at. - βvalue (
SIMD[dtype]): TheSIMDvalue to store.
offsetβ
static def offset[offset_mut: Bool, offset_types: TypeList[offset_types.values], //, offset_dtype: DType, offset_origin: Origin[mut=offset_mut], offset_address_space: AddressSpace](var storage: Self.StorageType[offset_mut, origin_of(offset_origin), offset_dtype, offset_origin, offset_address_space], var offset_coord: Coord[offset_types]) -> Self.OffsetResultType[offset_types.values, offset_types].StorageType[offset_mut, origin_of(offset_origin), offset_dtype, offset_origin, offset_address_space]
Returns a storage handle offset by a number of scalar elements.
Parameters:
- βoffset_mut (
Bool): The mutability of the storage, inferred fromoffset_origin. - βoffset_types (
TypeList[offset_types.values]): The coordinate element types ofoffset_coord. - βoffset_dtype (
DType): The element data type of the storage. - βoffset_origin (
Origin[mut=offset_mut]): The origin tracking the lifetime of the storage. - βoffset_address_space (
AddressSpace): The address space the storage resides in.
Args:
- βstorage (
_Self.StorageType[offset_mut, origin_of(offset_origin), offset_dtype, offset_origin, offset_address_space]): The storage to offset from. - βoffset_coord (
Coord[offset_types]): A rank-1 coordinate holding the number of scalar elements to advance the handle by.
Returns:
_Self.OffsetResultType[offset_types.values, offset_types].StorageType[offset_mut, origin_of(offset_origin), offset_dtype, offset_origin, offset_address_space]: A handle of the same type starting the given number of scalar
elements into the referenced storage.
copy_fromβ
static def copy_from[SelfLayoutType: TensorLayout, self_origin: MutOrigin, self_address_space: AddressSpace, OtherLayoutType: TensorLayout, other_mut: Bool, other_origin: Origin[mut=other_mut], other_address_space: AddressSpace, //, dst_dtype: DType, src_dtype: DType, OtherStorage: TensorStorage](storage: Tuple[Self.StorageType[True, origin_of(self_origin), dst_dtype, self_origin, self_address_space], SelfLayoutType], other: Tuple[OtherStorage.StorageType[other_mut, origin_of(other_origin), src_dtype, other_origin, other_address_space], OtherLayoutType])
Copies the elements of other into storage, in place.
Performs an element-by-element copy from other into storage,
respecting the layouts of both operands. Each logical element is loaded
from other using its layout and stored into storage using its own
layout, so the copy works correctly even when the two sides have
different shapes or strides (as long as they agree on total element
count). When both operands have fully static, row-major layouts and a
scalar logical element, the copy widens to SIMD load + cast + SIMD
store using the narrower of the two dtypes' native SIMD widths.
- Both operands must have statically known shapes with matching total element count.
- Both operands must have the same logical element size.
- Source and destination dtypes may differ; each logical element is cast to the destination dtype.
Parameters:
- βSelfLayoutType (
TensorLayout): The layout type of the destination storage. - βself_origin (
MutOrigin): The origin of the destination storage. - βself_address_space (
AddressSpace): The address space of the destination storage. - βOtherLayoutType (
TensorLayout): The layout type of the source storage. - βother_mut (
Bool): The mutability of the source storage. - βother_origin (
Origin[mut=other_mut]): The origin of the source storage. - βother_address_space (
AddressSpace): The address space of the source storage. - βdst_dtype (
DType): The element data type of the destination storage. - βsrc_dtype (
DType): The element data type of the source storage. - βOtherStorage (
TensorStorage): The storage policy of the source. May differ fromSelfas long as the two policies are copy-compatible (same logical element size).
Args:
- βstorage (
Tuple[_Self.StorageType[True, origin_of(self_origin), dst_dtype, self_origin, self_address_space], SelfLayoutType]): A tuple of the destination storage (modified in place) and its layout. - βother (
Tuple[OtherStorage.StorageType[other_mut, origin_of(other_origin), src_dtype, other_origin, other_address_space], OtherLayoutType]): A tuple of the source storage and its layout.
distanceβ
static def distance[dtype: DType, address_space: AddressSpace, //](storage: Self.StorageType[False, origin_of(origin), dtype, origin, address_space], other: Self.StorageType[False, origin_of(origin), dtype, origin, address_space]) -> Int
Returns the scalar-element distance from other to storage.
Parameters:
- βdtype (
DType): The storages'DType. - βaddress_space (
AddressSpace): The storages'AddressSpace.
Args:
- βstorage (
_Self.StorageType[False, origin_of(origin), dtype, origin, address_space]): The storage to measure the distance to. - βother (
_Self.StorageType[False, origin_of(origin), dtype, origin, address_space]): The storage to measure the distance from.
Returns:
Int: The number of scalar elements separating the two handles. The
value is positive when storage is ahead of other and negative
when it precedes other.
Provided methodsβ
write_type_name_toβ
static def write_type_name_to(mut writer: T)
Writes the storage type name representation to the writer.
Args:
- βwriter (
T): TheWriterto output to.