Skip to main content

ClikaRT::ops::take_along_dim

function

take_along_dim()

Tensor take_along_dim(
    Tensor x,
    Tensor index,
    std::optional<int64_t> dim = std::nullopt
)

gather with broadcasting between x and index on the other dims.

With dim absent both operands are treated as flattened 1-D. Same index dtype law as gather (Int32/Int64).

Parameters

  • x: the source.
  • index: integer positions; broadcasts against x off the chosen dim.
  • dim: the addressed axis; absent = flattened. Default: absent.

Throws

  • ClikaRT::Error: (INVALID_ARGUMENT) when the shapes do not broadcast or the index dtype is wrong (code_name() carries the reason).

Returns: a new tensor of the broadcast shape, dtype of x.

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