---
title: "resizeNearest(withGradientTensor:input:scale:offsetTensor:nearestRoundingMode:name:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/resizenearest(withgradienttensor:input:scale:offsettensor:nearestroundingmode:name:)"
---

# resizeNearest(withGradientTensor:input:scale:offsetTensor:nearestRoundingMode:name:)

Creates a Resize gradient operation and returns the result tensor.

## Declaration

```swift
func resizeNearest(withGradientTensor gradient: MPSGraphTensor, input: MPSGraphTensor, scale: MPSGraphTensor, offsetTensor offset: MPSGraphTensor, nearestRoundingMode: MPSGraphResizeNearestRoundingMode, name: String?) -> MPSGraphTensor
```

## Parameters

- `gradient`: Incoming gradient tensor
- `input`: Forward pass input tensor
- `scale`: 1D float tensor of size equal to rank of input.
- `offset`: 1D float tensor of size equal to rank of input.
- `nearestRoundingMode`: The rounding mode to use when using nearest resampling. Default is roundPreferCeil.
- `name`: The name for the operation.

## Return Value

Return Value A valid MPSGraphTensor object

## Discussion

Discussion Computes the gradient for the forward pass Resize op with nearest neighbor sampling and identical parameters. See discussion of resizeTensor for more in depth description of resize paramters.
