<!--
{
  "availability" : [
    "iOS: 17.4.0 -",
    "iPadOS: 17.4.0 -",
    "macCatalyst: 17.4.0 -",
    "macOS: 14.4.0 -",
    "tvOS: 17.4.0 -",
    "visionOS: 1.1.0 -",
    "watchOS: 10.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreML",
  "identifier" : "/documentation/CoreML/MLComputePlan-85vdw",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core ML"
    ],
    "preciseIdentifier" : "c:objc(cs)MLComputePlan"
  },
  "title" : "MLComputePlan"
}
-->

# MLComputePlan

A class describing the plan for executing a model.

```
@interface MLComputePlan : NSObject
```

## Overview

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

```
// Load the compute plan of an ML Program model.
[MLComputePlan loadContentsOfURL:modelURL configuration:configuration completionHandler:^(MLComputePlan * _Nullable computePlan, NSError * _Nullable error) {
   if (!computePlan) {
       // Handle error.
       return;
   }
   MLModelStructureProgram *program = computePlan.modelStructure.program;
   if (!program) {
       [NSException raise:NSInternalInconsistencyException format:@"Unexpected model type."];
   }

   MLModelStructureFunction *mainFunction = program.functions["main"];
   if (!mainFunction) {
       [NSException raise:NSInternalInconsistencyException format:@"Missing main function."];
   }

   NSArray<MLModelStructureProgramOperation *> *operations = mainFunction.block.operations;
   for (MLModelStructureProgramOperation *operation in operations) {
       // Get the compute device usage for the operation.
       MLComputeDeviceUsage *computeDeviceUsage = [computePlan computeDeviceUsageForMLProgramOperation:operation];
       // Get the estimated cost of executing the operation.
       MLComputePlanCost *estimatedCost = [computePlan estimatedCostOfMLProgramOperation:operation];

   }
}];
```

## Topics

### Loading a compute plan

[`loadContentsOfURL:configuration:completionHandler:`](/documentation/CoreML/MLComputePlan-85vdw/loadContentsOfURL:configuration:completionHandler:)

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

[`loadModelAsset:configuration:completionHandler:`](/documentation/CoreML/MLComputePlan-85vdw/loadModelAsset:configuration:completionHandler:)

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

### Getting the model structure

[`modelStructure`](/documentation/CoreML/MLComputePlan-85vdw/modelStructure)

The model structure.

### Getting the device usage

[`computeDeviceUsageForMLProgramOperation:`](/documentation/CoreML/MLComputePlan-85vdw/computeDeviceUsageForMLProgramOperation:)

Returns The anticipated compute devices that would be used for executing an ML Program operation.

[`computeDeviceUsageForNeuralNetworkLayer:`](/documentation/CoreML/MLComputePlan-85vdw/computeDeviceUsageForNeuralNetworkLayer:)

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

[`MLComputePlanDeviceUsage`](/documentation/CoreML/MLComputePlanDeviceUsage)

The anticipated compute devices to use for executing a layer or operation.

### Getting the estimated cost

[`estimatedCostOfMLProgramOperation:`](/documentation/CoreML/MLComputePlan-85vdw/estimatedCostOfMLProgramOperation:)

Returns the estimated cost of executing an ML Program operation.

[`MLComputePlanCost`](/documentation/CoreML/MLComputePlanCost)

A class that represents the estimated cost of executing a layer or 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)