<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShadersGraph",
  "identifier" : "/documentation/MetalPerformanceShadersGraph/MPSGraph/resizeNearest(_:sizeTensor:scaleTensor:offsetTensor:nearestRoundingMode:name:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal Performance Shaders Graph",
      "MetalPerformanceShadersGraph"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSGraph(im)resizeNearestWithTensor:sizeTensor:scaleTensor:offsetTensor:nearestRoundingMode:name:"
  },
  "title" : "resizeNearest(_:sizeTensor:scaleTensor:offsetTensor:nearestRoundingMode:name:)"
}
-->

# resizeNearest(_:sizeTensor:scaleTensor:offsetTensor:nearestRoundingMode:name:)

Creates a Resize operation and returns the result tensor.

```
func resizeNearest(_ imagesTensor: MPSGraphTensor, sizeTensor size: MPSGraphTensor, scaleTensor scale: MPSGraphTensor, offsetTensor offset: MPSGraphTensor, nearestRoundingMode: MPSGraphResizeNearestRoundingMode, name: String?) -> MPSGraphTensor
```

## Parameters

`imagesTensor`

Tensor containing input images.

`size`

The target size of the result tensor.  1D Int32 or Int64 tensor of size equal to rank of input.

`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

A valid MPSGraphTensor object

## Discussion

Resamples input images to given size using the provided scale and offset and nearest neighbor sampling.
Destination indices are computed using

```md
dst_indices = (src_indices * scale) + offset
```

For most use cases passing the scale and offset directly is unnecessary, and it is
preferable to use the API specifying centerResult and alignCorners.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)