---
title: "compile(options:device:inputTensors:inputTensorsData:)"
framework: ML Compute
role: symbol
role_heading: Instance Method
platforms: [iOS 14.5+, iPadOS 14.5+, Mac Catalyst 14.5+, macOS 11.3+, tvOS 14.5+]
path: "mlcompute/mlctraininggraph/compile(options:device:inputtensors:inputtensorsdata:)"
---

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

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

## Declaration

```swift
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

Return Value A Boolean that indicates success or failure.

## Discussion

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.

## See Also

### Preparing Training Graphs

- [addInputs(_:lossLabels:)](mlcompute/mlctraininggraph/addinputs(_:losslabels:).md)
- [addInputs(_:lossLabels:lossLabelWeights:)](mlcompute/mlctraininggraph/addinputs(_:losslabels:losslabelweights:).md)
- [addOutputs(_:)](mlcompute/mlctraininggraph/addoutputs(_:).md)
- [stopGradient(for:)](mlcompute/mlctraininggraph/stopgradient(for:).md)
- [compileOptimizer(_:)](mlcompute/mlctraininggraph/compileoptimizer(_:).md)
- [compile(options:device:)](mlcompute/mlctraininggraph/compile(options:device:).md)
- [link(with:)](mlcompute/mlctraininggraph/link(with:).md)
- [allocateUserGradient(for:)](mlcompute/mlctraininggraph/allocateusergradient(for:).md)
- [MLCGraphCompilationOptions](mlcompute/mlcgraphcompilationoptions.md)
