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 function

arange_shape

def arange_shape[dtype: DType](start: Scalar[dtype], stop: Scalar[dtype], step: Scalar[dtype]) -> Int

Computes the output shape (number of elements) for the arange operation.

Validates that step is non-zero and consistent with the start/stop ordering, then returns the element count as a single Int.

Parameters:

  • ​dtype (DType): Element type of the range values.

Args:

  • ​start (Scalar[dtype]): First value of the range.
  • ​stop (Scalar[dtype]): Exclusive upper (or lower) bound of the range.
  • ​step (Scalar[dtype]): Spacing between consecutive values.

Returns:

Int: A single Int holding the number of generated values.

Raises:

Error: If step is zero, or if the start/stop/step ordering is invalid.

Was this page helpful?