---
title: MLComputePlan
framework: coreml
role: symbol
role_heading: Class
path: coreml/mlcomputeplan-1w21n
---

# MLComputePlan

A class representing the compute plan of a model.

## Declaration

```swift
class MLComputePlan
```

## Overview

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:)](coreml/mlcomputeplan-1w21n/load(asset:configuration:).md)
- [load(contentsOf:configuration:)](coreml/mlcomputeplan-1w21n/load(contentsof:configuration:).md)

### Getting the model structure

- [modelStructure](coreml/mlcomputeplan-1w21n/modelstructure.md)

### Getting the device usage

- [deviceUsage(for:)](coreml/mlcomputeplan-1w21n/deviceusage(for:).md)
- [deviceUsage(for:)](coreml/mlcomputeplan-1w21n/deviceusage(for:)-9em1q.md)
- [deviceUsage(for:)](coreml/mlcomputeplan-1w21n/deviceusage(for:)-7cdlm.md)
- [MLComputePlan.DeviceUsage](coreml/mlcomputeplan-1w21n/deviceusage.md)

### Getting the estimated cost

- [estimatedCost(of:)](coreml/mlcomputeplan-1w21n/estimatedcost(of:).md)
- [MLComputePlan.Cost](coreml/mlcomputeplan-1w21n/cost.md)

## See Also

### Compute plan

- [MLModelStructure](coreml/mlmodelstructure-swift.enum.md)
- [MLComputePolicy](coreml/mlcomputepolicy.md)
- [withMLTensorComputePolicy(_:_:)](coreml/withmltensorcomputepolicy(_:_:)-8stx9.md)
- [withMLTensorComputePolicy(_:_:)](coreml/withmltensorcomputepolicy(_:_:)-6z33x.md)
