Skip to main content

ClikaRT::ops::index_select

function

index_select()

Tensor index_select(
    Tensor x,
    int64_t dim,
    Tensor index
)

Select whole rows of x at index positions along dim.

Output = x's shape with the dim extent replaced by index's length; rows may repeat and appear in any order. index is 1-D Int32/Int64; prefer Int32 where the extents allow (half the index bytes).

Throws

  • ClikaRT::Error: (INVALID_ARGUMENT) when dim is out of range or the index dtype is wrong (code_name() carries the reason).

Returns: a new tensor: x's shape with dim resized to index's length.

auto rows = ClikaRT::ops::index_select(table, 0, ids); // [n_ids, ..]

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