<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTL4MachineLearningCommandEncoder",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTL4MachineLearningCommandEncoder"
  },
  "title" : "MTL4MachineLearningCommandEncoder"
}
-->

# MTL4MachineLearningCommandEncoder

Encodes machine learning model inference commands for a single pass.

```
protocol MTL4MachineLearningCommandEncoder : MTL4CommandEncoder
```

## Overview

Create a machine learning encoder by calling a factory method of an [`MTL4CommandBuffer`](/documentation/Metal/MTL4CommandBuffer) instance,
such as [`makeMachineLearningCommandEncoder()`](/documentation/Metal/MTL4CommandBuffer/makeMachineLearningCommandEncoder()).

The [`dispatchNetwork(intermediatesHeap:)`](/documentation/Metal/MTL4MachineLearningCommandEncoder/dispatchNetwork(intermediatesHeap:)) method applies to the
[`machineLearning`](/documentation/Metal/MTLStages/machineLearning) stage of a machine learning pass.
For more information about stages and synchronization, see [`MTLStages`](/documentation/Metal/MTLStages) and [Resource synchronization](/documentation/Metal/resource-synchronization).

## Topics

### Configuring the pass

[`setPipelineState(_:)`](/documentation/Metal/MTL4MachineLearningCommandEncoder/setPipelineState(_:))

Configures the encoder with a machine learning pipeline state instance.

[`setArgumentTable(_:)`](/documentation/Metal/MTL4MachineLearningCommandEncoder/setArgumentTable(_:))

Sets an argument table for the command encoder’s machine learning shader stage.

### Running machine learning networks

[`dispatchNetwork(intermediatesHeap:)`](/documentation/Metal/MTL4MachineLearningCommandEncoder/dispatchNetwork(intermediatesHeap:))

Dispatches a machine learning network using the current pipeline state and argument table.



---

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)