---
title: "ClikaRT::ops::stack"
sidebar_label: "stack"
description: "Join tensors along a NEW dim at position dim: all inputs share one shape; output rank = input rank + 1, the new dim sized N. Copies."
---

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

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

## stack() {#stack}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`stack`**([`ClikaRT::Span`](../Span.md)`<const` [`Tensor`](../Tensor.md)`>` `tensors`, `int64_t` `dim` `=` `0`)

</div>

Join tensors along a NEW dim at position `dim`: all inputs share one shape; output rank = input rank + 1, the new dim sized N. Copies.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when the input shapes differ (`code_name()` carries the reason).

**Returns:** a new tensor of rank + 1.

```cpp
auto batch = ClikaRT::ops::stack({a, b, c});  // [3, ..]
```

<div class="api-declared">

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

</div>
