---
title: "BNNSGraphContextSetBatchSize(_:_:_:)"
framework: accelerate
role: symbol
role_heading: Function
path: "accelerate/bnnsgraphcontextsetbatchsize(_:_:_:)"
---

# BNNSGraphContextSetBatchSize(_:_:_:)

Sets the batch size for a graph.

## Declaration

```swift
func BNNSGraphContextSetBatchSize(_ context: bnns_graph_context_t, _ function: UnsafePointer<CChar>?, _ batch_size: UInt64) -> Int32
```

## Parameters

- `context`: The graph context.
- `function`: The function. Specify as nil if the graph only contains one function.
- `batch_size`: The batch size.

## Return Value

Return Value 0 on success, nonzero on failure.

## Discussion

Discussion This function provides a special case of BNNSGraphContextSetDynamicShapes(_:_:_:_:) where the only dynamic size is the first index of the tensors and that size is equal for all tensors. This function provides a simpler API because you only need to pass the common first dimension as the batch_size parameter. If your graph contains other dynamic strides, use BNNSGraphContextSetDynamicShapes(_:_:_:_:) instead. This function doesn’t set dynamic strides. Don’t call this function while existing calls to BNNSGraphContextExecute(_:_:_:_:_:_:) are running.

## See Also

### Specifying and querying a context’s properties

- [BNNSGraphContextSetStreamingAdvanceCount(_:_:)](accelerate/bnnsgraphcontextsetstreamingadvancecount(_:_:).md)
- [BNNSGraphContextSetArgumentType(_:_:)](accelerate/bnnsgraphcontextsetargumenttype(_:_:).md)
- [BNNSGraphArgumentType](accelerate/bnnsgraphargumenttype.md)
- [BNNSGraphContextSetDynamicShapes(_:_:_:_:)](accelerate/bnnsgraphcontextsetdynamicshapes(_:_:_:_:).md)
- [bnns_graph_shape_t](accelerate/bnns_graph_shape_t.md)
- [BNNSGraphContextEnableNanAndInfChecks(_:_:)](accelerate/bnnsgraphcontextenablenanandinfchecks(_:_:).md)
- [BNNSGraphContextGetWorkspaceSize(_:_:)](accelerate/bnnsgraphcontextgetworkspacesize(_:_:).md)
- [BNNSGraphContextSetStreamingAdvanceCount(_:_:)](accelerate/bnnsgraphcontextsetstreamingadvancecount(_:_:).md)
