<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreAI",
  "identifier" : "/documentation/CoreAI/InferenceFunction/run(inputs:states:outputViews:)-mqfb",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core AI",
      "CoreAI"
    ],
    "preciseIdentifier" : "s:13CoreAIRuntime17InferenceFunctionV3run6inputs6states11outputViewsAC7OutputsVSDySSAA7NDArrayVG_AC07MutableI0VnANntYaKF"
  },
  "title" : "run(inputs:states:outputViews:)"
}
-->

# run(inputs:states:outputViews:)

Runs the function on the provided input arrays and returns the output values.

```
func run(inputs: [String : NDArray], states: consuming InferenceFunction.MutableViews = MutableViews(), outputViews: consuming InferenceFunction.MutableViews = MutableViews()) async throws -> InferenceFunction.Outputs
```

## Parameters

`inputs`

A dictionary that maps input names to their [`NDArray`](/documentation/CoreAI/NDArray) values.

`states`

The in-out arguments of the function, which the function reads and writes
during inference. You must provide views for all states; omitting any state
produces an error.

`outputViews`

Pre-allocated output values that the function updates during inference.
Outputs with a provided view are updated in-place and are not included in the
returned [`InferenceFunction.Outputs`](/documentation/CoreAI/InferenceFunction/Outputs). Outputs without a provided view produce new values in
the returned [`InferenceFunction.Outputs`](/documentation/CoreAI/InferenceFunction/Outputs).

## Return Value

The outputs from the function.

## Discussion

This is a convenience overload that accepts a dictionary of [`NDArray`](/documentation/CoreAI/NDArray) values
instead of an [`InferenceFunction.Inputs`](/documentation/CoreAI/InferenceFunction/Inputs) collection.

Any [`NDArray`](/documentation/CoreAI/NDArray) values in the returned outputs have a row-major contiguous layout.

---

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)