<!--
{
  "availability" : [
    "iOS: 14.5.0 - 17.4.0",
    "iPadOS: 14.5.0 - 17.4.0",
    "macCatalyst: 14.5.0 - 17.4.0",
    "macOS: 11.3.0 - 14.3.0",
    "tvOS: 14.5.0 - 17.4.0"
  ],
  "documentType" : "symbol",
  "framework" : "MLCompute",
  "identifier" : "/documentation/MLCompute/MLCTrainingGraph/compile(options:device:inputTensors:inputTensorsData:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "ML Compute"
    ],
    "preciseIdentifier" : "c:objc(cs)MLCTrainingGraph(im)compileWithOptions:device:inputTensors:inputTensorsData:"
  },
  "title" : "compile(options:device:inputTensors:inputTensorsData:)"
}
-->

# compile(options:device:inputTensors:inputTensorsData:)

Compiles the training graph for the options, device, and input tensors you specify.

```
func compile(options: MLCGraphCompilationOptions = [], device: MLCDevice, inputTensors: [String : MLCTensor]?, inputTensorsData: [String : MLCTensorData]?) -> Bool
```

## Parameters

`options`

The compiler options.

`device`

The device.

`inputTensors`

The list of input tensors that are constants.

`inputTensorsData`

The tensor data to use with the input tensors.

## Return Value

A Boolean that indicates success or failure.

## Discussion

If you specify the list of constant tensors before the framework compiles the graph, then the framework can perform additional optimizations during the compilation.

---

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)