<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/BNNSGraph/Context/executeFunction(_:arguments:)-52eh3",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate9BNNSGraphO7ContextC15executeFunction_9argumentsySSSg_SaySo10BNNSTensoraGztKF"
  },
  "title" : "executeFunction(_:arguments:)"
}
-->

# executeFunction(_:arguments:)

Synchronously executes the specified function with the provided context.

```
func executeFunction(_ function: String? = nil, arguments: inout [BNNSTensor]) throws
```

## Parameters

`function`

The specific function to execute. You may set this to `nil` if there is only one function.

`arguments`

The output and input arguments.

## Discussion

If the underlying model contains dynamic shaped inputs or outputs, these must be set prior to calling this routine through a call
to either `setDynamicShapes(_:forFunction:)` or `setBatchSize(_:forFunction:)`.
Don’t modify the shapes again until this routine has returned.

The same context must only be used by a single thread at a time.

> SeeAlso: `BNNSGraphContextExecute`

---

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)