---
title: InferenceFunction
framework: coreai
role: symbol
role_heading: Structure
path: coreai/inferencefunction
---

# InferenceFunction

A function that performs inference on input values and produces output values.

## Declaration

```swift
struct InferenceFunction
```

## Mentioned in

Integrating on-device AI models in your app with Core AI

## Overview

Overview An InferenceFunction owns the resources needed for inference, including model weights and intermediate buffers. You load a function from an AIModel and call run(inputs:states:outputViews:) to perform inference. This type is Sendable, so you can run it concurrently from multiple tasks. The function automatically allocates additional intermediate buffers as needed to support concurrency.

## Topics

### Inspecting a function

- [descriptor](coreai/inferencefunction/descriptor.md)

### Supporting types

- [InferenceFunction.Inputs](coreai/inferencefunction/inputs.md)
- [InferenceFunction.Outputs](coreai/inferencefunction/outputs.md)

### Classes

- [InferenceFunction.AsyncValue](coreai/inferencefunction/asyncvalue.md)

### Structures

- [InferenceFunction.AsyncMutableValue](coreai/inferencefunction/asyncmutablevalue.md)
- [InferenceFunction.AsyncMutableViews](coreai/inferencefunction/asyncmutableviews.md)
- [InferenceFunction.MutableViews](coreai/inferencefunction/mutableviews.md)

### Instance Methods

- [encode(inputs:states:outputViews:to:)](coreai/inferencefunction/encode(inputs:states:outputviews:to:).md)
- [run(inputs:states:outputViews:)](coreai/inferencefunction/run(inputs:states:outputviews:)-14emi.md)
- [run(inputs:states:outputViews:)](coreai/inferencefunction/run(inputs:states:outputviews:)-mqfb.md)

## Relationships

### Conforms To

- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Inference

- [InferenceFunctionDescriptor](coreai/inferencefunctiondescriptor.md)
- [InferenceValue](coreai/inferencevalue.md)
- [ImageDescriptor](coreai/imagedescriptor.md)
- [ComputeStream](coreai/computestream.md)
