---
title: "avgPooling2D(withSourceTensor:descriptor:name:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/avgpooling2d(withsourcetensor:descriptor:name:)"
---

# avgPooling2D(withSourceTensor:descriptor:name:)

Creates a 2D average-pooling operation and returns the result tensor.

## Declaration

```swift
func avgPooling2D(withSourceTensor source: MPSGraphTensor, descriptor: MPSGraphPooling2DOpDescriptor, name: String?) -> MPSGraphTensor
```

## Parameters

- `source`: A 2D Image source as tensor - must be of rank=4. The layout is defined by descriptor.dataLayout.
- `descriptor`: A pooling operation descriptor that specifies pooling window sizes, strides, dilation rates, paddings and layouts.
- `name`: The name for the operation.

## Return Value

Return Value A valid MPSGraphTensor object
