---
title: "ClikaRT::ops::max_pool"
sidebar_label: "max_pool"
description: "Rank-generic max pooling, channels-last. input is [N, D1..Dn, C]; the window rank is read from kernel_size's length. Each output element is the maximum over its window; padding never wins."
---

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

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

## max\_pool() {#max_pool}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`max_pool`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const std::int64_t>` `kernel_size`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const std::int64_t>` `stride`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const std::int64_t>` `padding`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const std::int64_t>` `dilation`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`bool` `ceil_mode`<br />
)

</div>

Rank-generic max pooling, channels-last.

`input` is `[N, D1..Dn, C]`; the window rank is read from `kernel_size`'s length. Each output element is the maximum over its window; padding never wins. A window holding any NaN element yields NaN, and a window lying wholly in the padding yields -inf for a float dtype and the type minimum for an integer one.

**Parameters**

- `input`: the input, `[N, D1..Dn, C]`.
- `kernel_size`: window extent per spatial dim.
- `stride`: window step per spatial dim; empty = `kernel_size`.
- `padding`: implicit padding per spatial dim.
- `dilation`: element spacing inside the window.
- `ceil_mode`: round output extents up instead of down; default false.

**Returns:** the pooled tensor, `[N, D1'..Dn', C]`, dtype of `input`.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when the parameter ranks disagree or a window over-runs the padded input.

<div class="api-declared">

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

</div>
