IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
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 struct

DefaultEngine

struct DefaultEngine[*, element_width: Int = Int(1)]

Implements TensorOps backed by a raw Pointer.

DefaultEngine is the default engine for TileTensor. Its StorageType handle is a plain Pointer, and every operation is expressed directly in terms of the underlying pointer.

Parameters​

  • ​element_width (Int): Number of scalar elements per logical element. A value of 1 (the default) is a non-vectorized tensor; larger values describe a vectorized view whose logical elements are SIMD vectors.

Implemented traits​

AnyType, Deinitable, Movable, TensorEngine, TensorOps

comptime members​

element_size​

comptime element_size = element_width

Number of scalar elements per logical element (alias of element_width).

OffsetResultType​

comptime OffsetResultType[offset_types: TypeList[values]] = DefaultEngine[element_width=element_width]

The storage type produced by offsetting with a given coordinate.

Offsetting never changes the engine, so this is Self.

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] = Pointer[SIMD[dtype, element_width], origin, address_space=address_space]

A raw Pointer to Scalar[dtype] borrowing the storage.

Parameters​

  • ​mut (Bool): The mutability of the borrowed storage, inferred from origin.
  • ​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.

Methods​

write_type_name_to​

static def write_type_name_to(mut writer: T)

Writes the engine type name representation to the writer.

Args:

  • ​writer (T): The Writer to output to.

unsafe_cast​

static def unsafe_cast[to_mut: Bool, //, to_dtype: DType, to_origin: Origin[mut=to_mut], to_address_space: AddressSpace](storage: Pointer[SIMD[dtype, element_width], address_space=storage.address_space]) -> Pointer[SIMD[to_dtype, element_width], to_origin, address_space=to_address_space]

Reinterprets a storage handle with new type parameters.

Parameters:

  • ​to_mut (Bool): The mutability of the origin.
  • ​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:

Returns:

Pointer[SIMD[to_dtype, element_width], to_origin, address_space=to_address_space]: A handle referring to the same storage, viewed with the new type parameters.

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: Pointer[SIMD[offset_dtype, element_width], offset_origin, address_space=offset_address_space], var offset_coord: Coord[*offset_types]) -> Pointer[SIMD[offset_dtype, element_width], offset_origin, address_space=offset_address_space]

Returns a storage handle offset by a number of scalar elements.

The returned handle refers to the same externally owned storage, advanced by the scalar-element offset in offset_coord. The offset is measured in scalar elements (not logical SIMD elements) so that it matches the scalar-unit offsets produced by a tensor's layout and applied to the pointer unsafe_ptr returns; for a vectorized storage (element_width > 1) advancing the raw SIMD-typed handle directly would over-advance by element_width.

Parameters:

  • ​offset_mut (Bool): The mutability of the storage, inferred from offset_origin.
  • ​offset_types (TypeList[values]): The coordinate element types of offset_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:

Returns:

Pointer[SIMD[offset_dtype, element_width], offset_origin, address_space=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, OtherEngine: TensorEngine](storage: Tuple[Pointer[SIMD[dst_dtype, element_width], self_origin, address_space=self_address_space], SelfLayoutType], other: Tuple[OtherEngine.StorageType[src_dtype, other_origin, other_address_space], OtherLayoutType])

Copies the elements of other into storage, in place.

Loads each logical element from other through its (possibly different) engine and stores it into storage through DefaultEngine, casting to the destination dtype. Delegates to the shared _copy_from loop.

  • 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.
  • ​OtherEngine (TensorEngine): The engine of the source. May differ from Self as long as the two engines are copy-compatible (same logical element size).

Args:

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, OtherEngine: TensorEngine](storage: Tuple[Pointer[SIMD[dtype, element_width], self_origin, address_space=self_address_space], SelfLayoutType], other: Tuple[OtherEngine.StorageType[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.
  • ​OtherEngine (TensorEngine): The engine of the right-hand operand. May differ from Self as long as the two engines have the same logical element size.

Args:

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, OtherEngine: TensorEngine](storage: Tuple[Pointer[SIMD[dtype, element_width], self_origin, address_space=self_address_space], SelfLayoutType], other: Tuple[OtherEngine.StorageType[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.
  • ​OtherEngine (TensorEngine): The engine of the right-hand operand. May differ from Self as long as the two engines have the same logical element size.

Args:

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, OtherEngine: TensorEngine](storage: Tuple[Pointer[SIMD[dtype, element_width], self_origin, address_space=self_address_space], SelfLayoutType], other: Tuple[OtherEngine.StorageType[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.
  • ​OtherEngine (TensorEngine): The engine of the right-hand operand. May differ from Self as long as the two engines have the same logical element size.

Args:

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, OtherEngine: TensorEngine](storage: Tuple[Pointer[SIMD[dtype, element_width], self_origin, address_space=self_address_space], SelfLayoutType], other: Tuple[OtherEngine.StorageType[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.
  • ​OtherEngine (TensorEngine): The engine of the right-hand operand. May differ from Self as long as the two engines have the same logical element size.

Args:

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, OtherEngine: TensorEngine](storage: Tuple[Pointer[SIMD[dtype, element_width], self_origin, address_space=self_address_space], SelfLayoutType], other: Tuple[OtherEngine.StorageType[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.
  • ​OtherEngine (TensorEngine): The engine of the right-hand operand. May differ from Self as long as the two engines have the same logical element size.

Args:

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, OtherEngine: TensorEngine](storage: Tuple[Pointer[SIMD[dtype, element_width], self_origin, address_space=self_address_space], SelfLayoutType], other: Tuple[OtherEngine.StorageType[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.
  • ​OtherEngine (TensorEngine): The engine of the right-hand operand. May differ from Self as long as the two engines have the same logical element size.

Args:

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, OtherEngine: TensorEngine](storage: Tuple[Pointer[SIMD[dtype, element_width], self_origin, address_space=self_address_space], SelfLayoutType], other: Tuple[OtherEngine.StorageType[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.
  • ​OtherEngine (TensorEngine): The engine of the right-hand operand. May differ from Self as long as the two engines have the same logical element size.

Args:

iabs​

static def iabs[dtype: DType, //](storage: Pointer[SIMD[dtype, element_width], address_space=storage.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:

irecip​

static def irecip[dtype: DType, //](storage: Pointer[SIMD[dtype, element_width], address_space=storage.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:

iexp​

static def iexp[dtype: DType, scale_dtype: DType = dtype, //, scale: Scalar[scale_dtype]](storage: Pointer[SIMD[dtype, element_width], address_space=storage.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 to dtype; the scale is cast to dtype before the multiplication.
  • ​scale (Scalar[scale_dtype]): The compile-time factor each element is multiplied by before exponentiation.

Args:

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, LhsEngine: TensorEngine, RhsEngine: TensorEngine](*, dst: Tuple[Pointer[SIMD[dtype, element_width], dst_origin, address_space=dst_address_space], DstLayoutType], lhs: Tuple[LhsEngine.StorageType[dtype, lhs_origin, lhs_address_space], LhsLayoutType], rhs: Tuple[RhsEngine.StorageType[dtype, rhs_origin, rhs_address_space], RhsLayoutType])

Out-of-place elementwise add 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.
  • ​LhsEngine (TensorEngine): The engine of the left-hand operand. May differ from Self as long as the engines have the same logical element size.
  • ​RhsEngine (TensorEngine): The engine of the right-hand operand. May differ from Self as long as the engines have the same logical element size.

Args:

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, LhsEngine: TensorEngine, RhsEngine: TensorEngine](*, dst: Tuple[Pointer[SIMD[dtype, element_width], dst_origin, address_space=dst_address_space], DstLayoutType], lhs: Tuple[LhsEngine.StorageType[dtype, lhs_origin, lhs_address_space], LhsLayoutType], rhs: Tuple[RhsEngine.StorageType[dtype, rhs_origin, rhs_address_space], RhsLayoutType])

Out-of-place elementwise mul 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.
  • ​LhsEngine (TensorEngine): The engine of the left-hand operand. May differ from Self as long as the engines have the same logical element size.
  • ​RhsEngine (TensorEngine): The engine of the right-hand operand. May differ from Self as long as the engines have the same logical element size.

Args:

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, LhsEngine: TensorEngine, RhsEngine: TensorEngine](*, dst: Tuple[Pointer[SIMD[dtype, element_width], dst_origin, address_space=dst_address_space], DstLayoutType], lhs: Tuple[LhsEngine.StorageType[dtype, lhs_origin, lhs_address_space], LhsLayoutType], rhs: Tuple[RhsEngine.StorageType[dtype, rhs_origin, rhs_address_space], RhsLayoutType])

Out-of-place elementwise sub 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.
  • ​LhsEngine (TensorEngine): The engine of the left-hand operand. May differ from Self as long as the engines have the same logical element size.
  • ​RhsEngine (TensorEngine): The engine of the right-hand operand. May differ from Self as long as the engines have the same logical element size.

Args:

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, LhsEngine: TensorEngine, RhsEngine: TensorEngine](*, dst: Tuple[Pointer[SIMD[dtype, element_width], dst_origin, address_space=dst_address_space], DstLayoutType], lhs: Tuple[LhsEngine.StorageType[dtype, lhs_origin, lhs_address_space], LhsLayoutType], rhs: Tuple[RhsEngine.StorageType[dtype, rhs_origin, rhs_address_space], RhsLayoutType])

Out-of-place elementwise floordiv 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.
  • ​LhsEngine (TensorEngine): The engine of the left-hand operand. May differ from Self as long as the engines have the same logical element size.
  • ​RhsEngine (TensorEngine): The engine of the right-hand operand. May differ from Self as long as the engines have the same logical element size.

Args:

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, LhsEngine: TensorEngine, RhsEngine: TensorEngine](*, dst: Tuple[Pointer[SIMD[dtype, element_width], dst_origin, address_space=dst_address_space], DstLayoutType], lhs: Tuple[LhsEngine.StorageType[dtype, lhs_origin, lhs_address_space], LhsLayoutType], rhs: Tuple[RhsEngine.StorageType[dtype, rhs_origin, rhs_address_space], RhsLayoutType])

Out-of-place elementwise truediv 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.
  • ​LhsEngine (TensorEngine): The engine of the left-hand operand. May differ from Self as long as the engines have the same logical element size.
  • ​RhsEngine (TensorEngine): The engine of the right-hand operand. May differ from Self as long as the engines have the same logical element size.

Args:

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, LhsEngine: TensorEngine, RhsEngine: TensorEngine](*, dst: Tuple[Pointer[SIMD[dtype, element_width], dst_origin, address_space=dst_address_space], DstLayoutType], lhs: Tuple[LhsEngine.StorageType[dtype, lhs_origin, lhs_address_space], LhsLayoutType], rhs: Tuple[RhsEngine.StorageType[dtype, rhs_origin, rhs_address_space], RhsLayoutType])

Out-of-place elementwise min 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.
  • ​LhsEngine (TensorEngine): The engine of the left-hand operand. May differ from Self as long as the engines have the same logical element size.
  • ​RhsEngine (TensorEngine): The engine of the right-hand operand. May differ from Self as long as the engines have the same logical element size.

Args:

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, LhsEngine: TensorEngine, RhsEngine: TensorEngine](*, dst: Tuple[Pointer[SIMD[dtype, element_width], dst_origin, address_space=dst_address_space], DstLayoutType], lhs: Tuple[LhsEngine.StorageType[dtype, lhs_origin, lhs_address_space], LhsLayoutType], rhs: Tuple[RhsEngine.StorageType[dtype, rhs_origin, rhs_address_space], RhsLayoutType])

Out-of-place elementwise max 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.
  • ​LhsEngine (TensorEngine): The engine of the left-hand operand. May differ from Self as long as the engines have the same logical element size.
  • ​RhsEngine (TensorEngine): The engine of the right-hand operand. May differ from Self as long as the engines have the same logical element size.

Args:

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, SrcEngine: TensorEngine](*, dst: Tuple[Pointer[SIMD[dtype, element_width], dst_origin, address_space=dst_address_space], DstLayoutType], src: Tuple[SrcEngine.StorageType[dtype, src_origin, src_address_space], SrcLayoutType])

Out-of-place elementwise abs 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.
  • ​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.
  • ​SrcEngine (TensorEngine): The engine of the source. May differ from Self as long as the two engines have the same logical element size.

Args:

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, SrcEngine: TensorEngine](*, dst: Tuple[Pointer[SIMD[dtype, element_width], dst_origin, address_space=dst_address_space], DstLayoutType], src: Tuple[SrcEngine.StorageType[dtype, src_origin, src_address_space], SrcLayoutType])

Out-of-place elementwise recip 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.
  • ​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.
  • ​SrcEngine (TensorEngine): The engine of the source. May differ from Self as long as the two engines have the same logical element size.

Args:

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, SrcEngine: TensorEngine, scale_dtype: DType = dtype, //, scale: Scalar[scale_dtype] = 1](*, dst: Tuple[Pointer[SIMD[dtype, element_width], dst_origin, address_space=dst_address_space], DstLayoutType], src: Tuple[SrcEngine.StorageType[dtype, src_origin, src_address_space], SrcLayoutType])

Writes exp(scale * x) for each element x of src 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.
  • ​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.
  • ​SrcEngine (TensorEngine): The engine of the source. May differ from Self as long as the two engines have the same logical element size.
  • ​scale_dtype (DType): The data type of the scale factor. Defaults to dtype; the scale is cast to dtype before the multiplication.
  • ​scale (Scalar[scale_dtype]): The compile-time factor each element is multiplied by before exponentiation.

Args:

Was this page helpful?