Skip to main content

ClikaRT::ops::unflatten

function

unflatten()

Tensor unflatten(
    Tensor x,
    int64_t dim,
    ClikaRT::Span<const std::int64_t> sizes
)

Split the dim at dim into sizes, the inverse of flatten. The product of sizes must equal that dim's extent.

Returns a view sharing storage when the layout permits; copies otherwise.

Throws

  • ClikaRT::Error: (INVALID_ARGUMENT) when the product of sizes mismatches the dim's extent (code_name() carries the reason).

Returns: the reshaped tensor, a view when the layout permits.

auto heads = ClikaRT::ops::unflatten(x, -1, {n_heads, head_dim});

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