---
title: "setDynamicShapes(_:forFunction:)"
framework: accelerate
role: symbol
role_heading: Instance Method
path: "accelerate/bnnsgraph/context/setdynamicshapes(_:forfunction:)"
---

# setDynamicShapes(_:forFunction:)

Specifies the dynamic shapes for a graph and, if possible, infers the output shapes.

## Declaration

```swift
func setDynamicShapes(_ shapes: [BNNSGraph.Shape], forFunction function: String? = nil) async throws -> [BNNSGraph.Shape]
```

## Parameters

- `shapes`: An array of input shapes in the same order as you pass to doc://com.apple.accelerate/documentation/Accelerate/BNNSGraphContextExecute(_:_:_:_:_:_:). This function reads input shapes with a nonzero rank, and uses the constant or default value from the source model for input shapes with a zero rank. The function generates an error for shapes with a nonzero value that doesn’t match the source model.
- `function`: The function. Specify as nil if the graph only contains one function.

## See Also

### Related Documentation

- [BNNSGraphContextSetDynamicShapes(_:_:_:_:)](accelerate/bnnsgraphcontextsetdynamicshapes(_:_:_:_:).md)

### Specifying and querying a graph context’s properties

- [BNNSGraph.Shape](accelerate/bnnsgraph/shape.md)
- [argumentCount(forFunction:)](accelerate/bnnsgraph/context/argumentcount(forfunction:).md)
- [argumentNames(forFunction:)](accelerate/bnnsgraph/context/argumentnames(forfunction:).md)
- [argumentPosition(forFunction:argument:)](accelerate/bnnsgraph/context/argumentposition(forfunction:argument:).md)
- [functionCount](accelerate/bnnsgraph/context/functioncount.md)
- [functionNames](accelerate/bnnsgraph/context/functionnames.md)
- [checkForNaNsAndInfinities](accelerate/bnnsgraph/context/checkfornansandinfinities.md)
