---
title: "ClikaRT::ops::split_by_size"
sidebar_label: "split_by_size"
description: "Split along dim into pieces of chunk_size, ceil(extent / chunk_size) of them, the last possibly shorter. Returns VIEWS sharing the source's storage (no copy)."
---

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

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

## split\_by\_size() {#split_by_size}

<div class="api-signature">

`std::vector<`[`Tensor`](../Tensor.md)`>` **`split_by_size`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`int64_t` `chunk_size`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`int64_t` `dim` `=` `0`<br />
)

</div>

Split along `dim` into pieces of `chunk_size`, [`ceil`](./ceil.md#ceil)`(extent / chunk_size)` of them, the last possibly shorter. Returns VIEWS sharing the source's storage (no copy).

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when `chunk_size` is not positive (`code_name()` carries the reason).

**Returns:** the per-piece views.

<div class="api-declared">

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

</div>
