Skip to main content

Mojo function

crd2idx

crd2idx[Index: CoordLike, Shape: CoordLike, Stride: CoordLike, out_type: DType = DType.int64](crd: Index, shape: Shape, stride: Stride) -> Scalar[out_type]

Calculate the linear index from a coordinate tuple.

Parameters:

  • Index (CoordLike): The coordinate type (must be CoordLike).
  • Shape (CoordLike): The shape type (must be CoordLike).
  • Stride (CoordLike): The stride type (must be CoordLike).
  • out_type (DType): The output scalar type.

Args:

  • crd (Index): The multi-dimensional coordinate.
  • shape (Shape): The shape of the tensor.
  • stride (Stride): The stride of the tensor.

Returns:

Scalar: The linear index corresponding to the coordinate.

Was this page helpful?