---
title: "ClikaRT::ops::clamp_max"
sidebar_label: "clamp_max"
description: "Elementwise upper bound. \\[ \\min(x_i,\\; \\mathrm{max}) \\] max is a scalar or a tensor broadcast against input (numpy rules). input the input tensor."
---

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

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

## clamp\_max() {#clamp_max}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`clamp_max`**([`Tensor`](../Tensor.md) `input`, [`ScalarOrTensor`](../ScalarOrTensor.md) `max`)

</div>

Elementwise upper bound.

$$
\min(x_i,\; \mathrm{max})
$$

[`max`](./max.md#max) is a scalar or a tensor broadcast against `input` (numpy rules).

**Parameters**

- `input`: the input tensor.
- `max`: the upper bound; scalar or broadcastable tensor.

**Throws**

- `ClikaRT::Error`: when a tensor bound does not broadcast against `input`, or when the dtype is not served (`code_name()` carries the reason).

**Returns:** a new tensor, same shape and dtype as `input`.

```cpp
auto y = ClikaRT::ops::clamp_max(x, 6.0);
```

<div class="api-declared">

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

</div>
