---
title: "maxPooling2DGradient(withGradientTensor:sourceTensor:descriptor:name:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/maxpooling2dgradient(withgradienttensor:sourcetensor:descriptor:name:)"
---

# maxPooling2DGradient(withGradientTensor:sourceTensor:descriptor:name:)

Creates a max-pooling gradient operation and returns the result tensor.

## Declaration

```swift
func maxPooling2DGradient(withGradientTensor gradient: MPSGraphTensor, sourceTensor source: MPSGraphTensor, descriptor: MPSGraphPooling2DOpDescriptor, name: String?) -> MPSGraphTensor
```

## Parameters

- `gradient`: A 2D input gradient tensor - must be of rank=4. The layout is defined by descriptor.dataLayout.
- `source`: The input tensor for the forward pass.
- `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
