<!--
{
  "availability" : [
    "iOS: 15.0.0 - 17.0.0",
    "iPadOS: 15.0.0 - 17.0.0",
    "macCatalyst: 15.0.0 - 17.0.0",
    "macOS: 12.0.0 - 14.0.0",
    "tvOS: 15.0.0 - 17.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "MLCompute",
  "identifier" : "/documentation/MLCompute/MLCTrainingGraph/executeGradient(batchSize:options:outputsData:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "ML Compute",
      "MLCompute"
    ],
    "preciseIdentifier" : "s:So16MLCTrainingGraphC9MLComputeE15executeGradient9batchSize7options11outputsDataSdSi_So19MLCExecutionOptionsVSDySSSo09MLCTensorJ0CGSgtYaKF"
  },
  "title" : "executeGradient(batchSize:options:outputsData:)"
}
-->

# executeGradient(batchSize:options:outputsData:)

Executes the gradient pass of the training graph with the batch size, execution options, and output data you specify.

```
@discardableResult func executeGradient(batchSize: Int, options: MLCExecutionOptions = [], outputsData: [String : MLCTensorData]? = nil) async throws -> TimeInterval
```

## Parameters

`batchSize`

The batch size.

`options`

The execution options.

`outputsData`

A dictionary that contains output data.

## Return Value

The execution time if you specify [`profiling`](/documentation/MLCompute/MLCExecutionOptions/profiling).

---

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)