<!--
{
  "availability" : [
    "iOS: 17.4.0 -",
    "iPadOS: 17.4.0 -",
    "macCatalyst: 17.4.0 -",
    "macOS: 14.4.0 -",
    "tvOS: 17.4.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreML",
  "identifier" : "/documentation/CoreML/MLComputePlan-1w21n",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core ML"
    ],
    "preciseIdentifier" : "s:6CoreML13MLComputePlanC"
  },
  "title" : "MLComputePlan"
}
-->

# MLComputePlan

A class representing the compute plan of a model.

```
class MLComputePlan
```

## Overview

The application can use the compute plan to estimate the necessary cost
and resources of the model before running the predictions.

```
// Load the compute plan of an ML Program model.
let computePlan = try await MLComputePlan.load(contentsOf: modelURL, configuration: configuration)
guard case let .program(program) = computePlan.modelStructure else {
   fatalError("Unexpected model type.")
}
 // Get the main function.
guard let mainFunction = program.functions["main"] else {
   fatalError("Missing main function.")
}

let operations = mainFunction.block.operations
for operation in operations {
   // Get the compute device usage for the operation.
   let computeDeviceUsage = computePlan.deviceUsage(for: operation)
   // Get the estimated cost of executing the operation.
   let estimatedCost = computePlan.estimatedCost(of: operation)
}
```

## Topics

### Loading a compute plan

[`load(asset:configuration:)`](/documentation/CoreML/MLComputePlan-1w21n/load(asset:configuration:))

Construct the compute plan of a model asynchronously given the model asset.

[`load(contentsOf:configuration:)`](/documentation/CoreML/MLComputePlan-1w21n/load(contentsOf:configuration:))

Construct the compute plan of a model asynchronously given the location of its on-disk representation.

### Getting the model structure

[`modelStructure`](/documentation/CoreML/MLComputePlan-1w21n/modelStructure)

The model structure.

### Getting the device usage

[`deviceUsage(for:)`](/documentation/CoreML/MLComputePlan-1w21n/deviceUsage(for:))

Returns the anticipated compute devices that would be used for executing a NeuralNetwork layer.

[`deviceUsage(for:)`](/documentation/CoreML/MLComputePlan-1w21n/deviceUsage(for:)-9em1q)

Returns the anticipated compute devices that would be used for executing a NeuralNetwork layer.

[`deviceUsage(for:)`](/documentation/CoreML/MLComputePlan-1w21n/deviceUsage(for:)-7cdlm)

Returns the anticipated compute devices that would be used for executing a MLProgram operation.

[`MLComputePlan.DeviceUsage`](/documentation/CoreML/MLComputePlan-1w21n/DeviceUsage)

The anticipated compute devices that would be used for executing a layer/operation.

### Getting the estimated cost

[`estimatedCost(of:)`](/documentation/CoreML/MLComputePlan-1w21n/estimatedCost(of:))

Returns the estimated cost of executing a MLProgram operation.

[`MLComputePlan.Cost`](/documentation/CoreML/MLComputePlan-1w21n/Cost)

A struct containing information on the estimated cost of executing a layer/operation.



---

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)