---
title: "setBatchSize(_:forFunction:)"
framework: accelerate
role: symbol
role_heading: Instance Method
path: "accelerate/bnnsgraph/context/setbatchsize(_:forfunction:)-4872x"
---

# setBatchSize(_:forFunction:)

Sets the batch size for a graph.

## Declaration

```swift
func setBatchSize(_ batchSize: Int, forFunction function: String? = nil) async
```

## Parameters

- `batchSize`: The batch size.
- `function`: The specific function to set shapes for. You may set this to nil if there is only one function.

## Discussion

Discussion This is a special case of setDynamicShapes(_:forFunction:) where the only dynamic sizes that occur are the first index of their tensor (that is, the batch dimension) and are all equal. This allows just passing a single batchSize constant. This function has no effect if you pass a batchSize value that’s less than zero. note: BNNSGraphContextSetBatchSize
