---
title: "ClikaRT::ops::avg_pool"
sidebar_label: "avg_pool"
description: "Rank-generic average pooling, channels-last. input is [N, D1..Dn, C]; the window rank is read from kernel_size's length."
---

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

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

## avg\_pool() {#avg_pool}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`avg_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;`bool` `ceil_mode`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`bool` `count_include_pad`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::optional<int64_t>` `divisor_override`<br />
)

</div>

Rank-generic average pooling, channels-last.

`input` is `[N, D1..Dn, C]`; the window rank is read from `kernel_size`'s length. Each output element averages its window; `count_include_pad` decides whether padded positions count in the divisor, and `divisor_override` replaces the divisor outright.

**Parameters**

- `input`: the input, `[N, D1..Dn, C]`.
- `kernel_size`: window extent per spatial dim.
- `stride`: window step; empty = `kernel_size`.
- `padding`: implicit zero padding per spatial dim.
- `ceil_mode`: round output extents up; default false.
- `count_include_pad`: count padding in the mean's divisor.
- `divisor_override`: fixed divisor instead of the window count; absent = the window count.

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

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when the parameter ranks disagree.

<div class="api-declared">

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

</div>
