---
title: "ClikaRT::ops::triu"
sidebar_label: "triu"
description: "Zero out the entries BELOW the chosen diagonal of the last two axes; the upper-triangular part survives. diagonal: 0 = main, +k above, -k below. Copies."
---

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

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

## triu() {#triu}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`triu`**([`Tensor`](../Tensor.md) `input`, `int64_t` `diagonal` `=` `0`)

</div>

Zero out the entries BELOW the chosen diagonal of the last two axes; the upper-triangular part survives. [`diagonal`](./diagonal.md#diagonal): 0 = main, +k above, -k below. Copies.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when the input's rank is \< 2 (`code_name()` carries the reason).

**Returns:** a new tensor, `input`'s shape and dtype.

```cpp
auto causal = ClikaRT::ops::triu(scores_mask, 1);  // strict upper part
```

<div class="api-declared">

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

</div>
