---
title: MPSGraphWhileBeforeBlock
framework: metalperformanceshadersgraph
role: symbol
role_heading: Type Alias
path: metalperformanceshadersgraph/mpsgraphwhilebeforeblock
---

# MPSGraphWhileBeforeBlock

The block that executes before the condition evaluates for each iteration.

## Declaration

```swift
typealias MPSGraphWhileBeforeBlock = ([MPSGraphTensor], NSMutableArray) -> MPSGraphTensor
```

## Parameters

- `inputTensors`: Input tensors to the whileConditionBlock, for the first iteration will be same as initialInputs passed to the while loop.
- `resultTensors`: A valid MPSGraphTensor array with results forwarded to after block or returned from the while loop depending on the predicate tensor. It will be empty and the caller block should fill it up before returning.

## Return Value

Return Value Tensor MUST be set and have a single scalar value, used to decide between executing the body block or returning from the while loop.
