---
title: "execute(inputsData:lossLabelsData:lossLabelWeightsData:batchSize:options:completionHandler:)"
framework: ML Compute
role: symbol
role_heading: Instance Method
platforms: [iOS 14.0+, iPadOS 14.0+, Mac Catalyst 14.0+, macOS 11.0+, tvOS 14.0+]
path: "mlcompute/mlcinferencegraph/execute(inputsdata:losslabelsdata:losslabelweightsdata:batchsize:options:completionhandler:)"
---

# execute(inputsData:lossLabelsData:lossLabelWeightsData:batchSize:options:completionHandler:)

Executes the inference graph with the input data, batch size, execution options and completion handler you specify.

## Declaration

```swift
func execute(inputsData: [String : MLCTensorData], lossLabelsData: [String : MLCTensorData]?, lossLabelWeightsData: [String : MLCTensorData]?, batchSize: Int, options: MLCExecutionOptions = [], completionHandler: MLCGraphCompletionHandler? = nil) -> Bool
```

## Parameters

- `inputsData`: A dictionary that contains input data.
- `lossLabelsData`: A dictionary that contains loss label data.
- `lossLabelWeightsData`: A dictionary that contains loss label weight data.
- `batchSize`: The batch size.
- `options`: The execution options.
- `completionHandler`: The completion handler.

## Return Value

Return Value true if the execution was successful.

## Discussion

Discussion When executing an inference graph, if an optimizer is specified, the optimizer update is applied. For variable length sequences for LSTMs/RNNs, use the key “sortedSequenceLengths” and pass in tensor data created by using one of the MLCTensor sequence length initializers as the value. If synchronous is specified in options, this method returns after the graph is executed. Otherwise, this method returns after the graph is queued for execution. The completion handler is called after the graph has finished execution.

## See Also

### Executing Inference Graphs

- [execute(inputsData:batchSize:options:completionHandler:)](mlcompute/mlcinferencegraph/execute(inputsdata:batchsize:options:completionhandler:).md)
- [execute(inputsData:outputsData:batchSize:options:completionHandler:)](mlcompute/mlcinferencegraph/execute(inputsdata:outputsdata:batchsize:options:completionhandler:).md)
- [execute(inputsData:lossLabelsData:lossLabelWeightsData:outputsData:batchSize:options:completionHandler:)](mlcompute/mlcinferencegraph/execute(inputsdata:losslabelsdata:losslabelweightsdata:outputsdata:batchsize:options:completionhandler:).md)
- [execute(inputsData:lossLabelsData:lossLabelWeightsData:outputsData:batchSize:options:)](mlcompute/mlcinferencegraph/execute(inputsdata:losslabelsdata:losslabelweightsdata:outputsdata:batchsize:options:).md)
- [MLCExecutionOptions](mlcompute/mlcexecutionoptions.md)
- [MLCGraphCompletionHandler](mlcompute/mlcgraphcompletionhandler.md)
