Skip to main content

ClikaRT::ops::arange

function

arange()

Tensor arange(
    ScalarOrTensor start,
    ScalarOrTensor end,
    ScalarOrTensor step = 1,
    DataType dtype = DataType::Int64,
    StreamOrDevice s = {}
)

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. Each bound is an int/float literal OR a 0-D Tensor (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.
  • s: 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((end - start) / step) elements.

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);

Declared in ClikaRT/compute/ops.h, line 2186