<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreML",
  "identifier" : "/documentation/CoreML/MLComputePolicy",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Core ML"
    ],
    "preciseIdentifier" : "s:6CoreML15MLComputePolicyV"
  },
  "title" : "MLComputePolicy"
}
-->

# MLComputePolicy

The compute policy determining what compute device, or compute devices, to execute ML workloads on.

```
struct MLComputePolicy
```

## Topics

### Compute policies

[`static var cpuAndGPU: MLComputePolicy`](/documentation/CoreML/MLComputePolicy/cpuAndGPU)

Execute ML workloads using the GPU if available, otherwise falling back to the CPU.

[`static var cpuOnly: MLComputePolicy`](/documentation/CoreML/MLComputePolicy/cpuOnly)

Execute ML workloads using the CPU.

### Creating a compute policy

[`init(MLComputeUnits)`](/documentation/CoreML/MLComputePolicy/init(_:))

Creates a new compute policy using the given compute units.

### Default Implementations

[CustomReflectable Implementations](/documentation/CoreML/MLComputePolicy/CustomReflectable-Implementations)

[CustomStringConvertible Implementations](/documentation/CoreML/MLComputePolicy/CustomStringConvertible-Implementations)

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Hashable`](/documentation/Swift/Hashable)

[`Sendable`](/documentation/Swift/Sendable)

[`Copyable`](/documentation/Swift/Copyable)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomReflectable`](/documentation/Swift/CustomReflectable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Escapable`](/documentation/Swift/Escapable)

---

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)