---
title: "ClikaRT::ops::arange"
sidebar_label: "arange"
description: "Evenly stepped 1-D range over the half-open interval [start, end). out[i] = start + i * step, for ceil((end - start) / step) elements; end itself is never included."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--function">function</span>

## arange() {#arange}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`arange`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ScalarOrTensor`](../ScalarOrTensor.md) `start`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ScalarOrTensor`](../ScalarOrTensor.md) `end`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ScalarOrTensor`](../ScalarOrTensor.md) `step` `=` `1`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`DataType`](../../index.md#DataType) `dtype` `=` [`DataType::Int64`](../../index.md#DataType),<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`StreamOrDevice`](../StreamOrDevice.md) `device` `=` `{}`<br />
)

</div>

Evenly stepped 1-D range over the half-open interval `[start, end)`.

`out[i] = start + i * step`, for [`ceil`](./ceil.md#ceil)`((end - start) / step)` elements; `end` itself is never included. Each bound is an int/float literal OR a 0-D [Tensor](../Tensor.md) (a tensor bound traces symbolically, never syncing to the host).

**Parameters**

- `start`: first value of the range.
- `end`: exclusive upper bound.
- `step`: increment between consecutive values; nonzero. Default `1`.
- `dtype`: element type of the result. Default [`DataType::Int64`](../../index.md#DataType).
- `device`: stream or device to allocate on. Default: the default device.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when `step` is zero or the bounds are inconsistent (`code_name()` carries the reason).

**Returns:** a new 1-D tensor of [`ceil`](./ceil.md#ceil)`((end - start) / step)` elements.

```cpp
auto ids  = ClikaRT::ops::arange(0, n);   // Int64: 0, 1, .., n-1
auto grid = ClikaRT::ops::arange(0.0, 1.0, 0.25, ClikaRT::DataType::Float32);
```

<div class="api-declared">

Declared in `ClikaRT/compute/ops.h`, line 2266

</div>
