---
title: "ClikaRT::ops::split_with_sizes"
sidebar_label: "split_with_sizes"
description: "Split along dim into chunks of the given lengths; sizes must sum to the dim's extent. Each length is a literal or a 0-D integer Tensor."
---

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

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

## split\_with\_sizes() {#split_with_sizes}

<div class="api-signature">

`std::vector<`[`Tensor`](../Tensor.md)`>` **`split_with_sizes`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const` [`ScalarOrTensor`](../ScalarOrTensor.md)`>` `sizes`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`int64_t` `dim` `=` `0`<br />
)

</div>

Split along `dim` into chunks of the given lengths; `sizes` must sum to the dim's extent. Each length is a literal or a 0-D integer [Tensor](../Tensor.md).

Returns VIEWS; every chunk shares the source's storage (no copy).

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when the sizes do not sum to the dim's extent (`code_name()` carries the reason).

**Returns:** one view per requested chunk.

```cpp
auto qkv = ClikaRT::ops::split_with_sizes(fused, {dq, dk, dv}, -1);
```

<div class="api-declared">

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

</div>
