<!--
{
  "availability" : [
    "iOS: 14.0.0 - 17.4.0",
    "iPadOS: 14.0.0 - 17.4.0",
    "macCatalyst: 14.0.0 - 17.4.0",
    "macOS: 11.0.0 - 14.3.0",
    "tvOS: 14.0.0 - 17.4.0"
  ],
  "documentType" : "symbol",
  "framework" : "MLCompute",
  "identifier" : "/documentation/MLCompute/MLCGraphCompilationOptions/computeAllGradients",
  "metadataVersion" : "0.1.0",
  "role" : "Type Property",
  "symbol" : {
    "kind" : "Type Property",
    "modules" : [
      "ML Compute"
    ],
    "preciseIdentifier" : "c:@E@MLCGraphCompilationOptions@MLCGraphCompilationOptionsComputeAllGradients"
  },
  "title" : "computeAllGradients"
}
-->

# computeAllGradients

The option to compute all gradients during graph compilation.

```
static var computeAllGradients: MLCGraphCompilationOptions { get }
```

## Discussion

Include this option to compute gradients for layers with or without parameters that only take input tensors.

For example, if the first layer of a graph is a convolution layer, the framework only computes the gradients for weights and biases associated with the convolution layer, but not the gradients for the input. Include this option if you want to compute all gradients for the input.

---

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)