---
title: "ClikaRT::ops::max_pool2d"
sidebar_label: "max_pool2d"
description: "2-D max pooling over [N, H, W, C] (channels-last). Each output element is the max over its kernel_size window; stride empty defaults to kernel_size (non-overlapping windows); dilation spaces the windo…"
---

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

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

## max\_pool2d() {#max_pool2d}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`max_pool2d`**(<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` `=` `{0, 0}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const std::int64_t>` `dilation` `=` `{1, 1}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`bool` `ceil_mode` `=` `false`<br />
)

</div>

2-D max pooling over `[N, H, W, C]` (channels-last).

Each output element is the max over its `kernel_size` window; `stride` empty defaults to `kernel_size` (non-overlapping windows); `dilation` spaces the window's taps; `ceil_mode` rounds the output extents up.

**Parameters**

- `input`: the input, `[N, H, W, C]`.
- `kernel_size`: `{kH, kW}`.
- `stride`: `{sH, sW}`; empty = `kernel_size`.
- `padding`: `{pH, pW}`; default `{0, 0}`.
- `dilation`: `{dH, dW}`; default `{1, 1}`.
- `ceil_mode`: round output extents up; default false.

**Returns:** `[N, H', W', C]`, dtype of `input`.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) on mismatched parameter ranks.

```cpp
auto y = ClikaRT::ops::max_pool2d(x, {3, 3}, {2, 2}, {1, 1});
```

<div class="api-declared">

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

</div>
