<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/BNNSGraphContextGetWorkspaceSize(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "c:@F@BNNSGraphContextGetWorkspaceSize"
  },
  "title" : "BNNSGraphContextGetWorkspaceSize(_:_:)"
}
-->

# BNNSGraphContextGetWorkspaceSize(_:_:)

Returns the minimum size, in bytes, of the workspace that graph context execution requires.

```
func BNNSGraphContextGetWorkspaceSize(_ context: bnns_graph_context_t, _ function: UnsafePointer<CChar>?) -> Int
```

## Parameters

`context`

The graph context.

`function`

The function. Specify as `nil` if the graph only contains one function.

## Return Value

The minimum size, in bytes, for the workspace, or `SIZE_T_MAX` if the query fails.

## Discussion

Call this function to obtain the minimum size of the workspace that the BNNSGraphContextExecute function requires. If you call either [`BNNSGraphContextSetBatchSize(_:_:_:)`](/documentation/Accelerate/BNNSGraphContextSetBatchSize(_:_:_:)) or [`BNNSGraphContextSetDynamicShapes(_:_:_:_:)`](/documentation/Accelerate/BNNSGraphContextSetDynamicShapes(_:_:_:_:)), call this function afterwards to obtain the new workspace size.

Note that the workspace size may not be proportional with the dynamic size. That is, smaller input and output tensors may require a larger workspace.

---

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)