---
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/mlcinferencegraph/compile(options:device:inputtensors:inputtensorsdata:)"
---

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

Compiles the inference 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 Inference Graphs

- [addInputs(_:)](mlcompute/mlcinferencegraph/addinputs(_:).md)
- [addInputs(_:lossLabels:lossLabelWeights:)](mlcompute/mlcinferencegraph/addinputs(_:losslabels:losslabelweights:).md)
- [addOutputs(_:)](mlcompute/mlcinferencegraph/addoutputs(_:).md)
- [compile(options:device:)](mlcompute/mlcinferencegraph/compile(options:device:).md)
- [link(with:)](mlcompute/mlcinferencegraph/link(with:).md)
- [MLCGraphCompilationOptions](mlcompute/mlcgraphcompilationoptions.md)
