---
title: "ClikaRT::ops::argmax"
sidebar_label: "argmax"
description: "Index of the maximum of input over dims. Empty dims reduces every dimension (the index is then into the flattened tensor)."
---

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

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

## argmax() {#argmax}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`argmax`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const std::int64_t>` `dims` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`bool` `keepdim` `=` `false`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`DataType`](../../index.md#DataType) `index_dtype` `=` [`DataType::Int64`](../../index.md#DataType)<br />
)

</div>

Index of the maximum of `input` over `dims`.

Empty `dims` reduces every dimension (the index is then into the flattened tensor). The index dtype is `Int64` by default; `Int32` narrows it (an Int32 index addresses a reduced extent of at most INT32\_MAX elements).

**Parameters**

- `input`: the input tensor.
- `dims`: axes to reduce; empty = all axes.
- `keepdim`: keep reduced axes as size-1 dims; default false.
- `index_dtype`: [`DataType::Int64`](../../index.md#DataType) (default) or [`DataType::Int32`](../../index.md#DataType).

**Returns:** indices of the maxima in `index_dtype`; shape = `input` minus `dims`.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) on an out-of-range `dims` entry, an `index_dtype` other than Int64 / Int32, or an Int32 index over a reduced extent past INT32\_MAX elements.

<div class="api-declared">

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

</div>
