<!--
{
  "availability" : [
    "iOS: 14.0.0 - 17.4.0",
    "iPadOS: 14.0.0 - 17.4.0",
    "macCatalyst: 14.0.0 - 17.4.0",
    "macOS: 11.0.0 - 14.3.0",
    "tvOS: 14.0.0 - 17.4.0"
  ],
  "documentType" : "symbol",
  "framework" : "MLCompute",
  "identifier" : "/documentation/MLCompute/MLCGraph",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "ML Compute"
    ],
    "preciseIdentifier" : "c:objc(cs)MLCGraph"
  },
  "title" : "MLCGraph"
}
-->

# MLCGraph

A graph of layers you use to build a training or inference graph.

```
class MLCGraph
```

## Topics

### Creating Graphs

[`graph`](/documentation/MLCompute/MLCGraph/graph)

Creates a new graph.

### Adding Layers to Graphs

[`node(with:source:)`](/documentation/MLCompute/MLCGraph/node(with:source:))

Adds the layer and source tensor that you specify to the graph.

[`node(with:sources:)`](/documentation/MLCompute/MLCGraph/node(with:sources:))

Adds the layer and source tensors that you specify to the graph.

[`node(with:sources:disableUpdate:)`](/documentation/MLCompute/MLCGraph/node(with:sources:disableUpdate:))

Adds the layer, source tensors, and option to disable optimizer updates that you specify to the graph.

[`node(with:sources:lossLabels:)`](/documentation/MLCompute/MLCGraph/node(with:sources:lossLabels:))

Adds the layer, sources, and loss labels tensors that you specify to the graph.

### Adding New Layers to Graphs

[`split(source:splitCount:dimension:)`](/documentation/MLCompute/MLCGraph/split(source:splitCount:dimension:))

Adds a new split layer to the graph using the source tensor, number of splits, and dimension to split the source tensor that you specify.

[`split(source:splitSectionLengths:dimension:)`](/documentation/MLCompute/MLCGraph/split(source:splitSectionLengths:dimension:))

Adds a new split layer to the graph using the source tensor, lengths of each split section, and dimension to split the source tensor that you specify.

[`splitWithSource:splitSectionLengths:dimension:`](/documentation/MLCompute/MLCGraph/splitWithSource:splitSectionLengths:dimension:)

Adds a new split layer to the graph using the source tensor, lengths of each split section, and dimension to split the source tensor that you specify.

[`selectWithSources:condition:`](/documentation/MLCompute/MLCGraph/selectWithSources:condition:)

Adds a select layer to the graph using the condition mask and source tensors you specify.

[`concatenate(sources:dimension:)`](/documentation/MLCompute/MLCGraph/concatenate(sources:dimension:))

Adds a new concatenation layer to the graph using the source tensors and concatenation dimension you specify.

[`reshape(shape:source:)`](/documentation/MLCompute/MLCGraph/reshape(shape:source:))

Adds a new reshape layer to the graph using the shape and source tensor you specify.

[`reshapeWithShape:source:`](/documentation/MLCompute/MLCGraph/reshapeWithShape:source:)

Adds a new reshape layer to the graph using the shape and source tensor you specify.

[`gather(withDimension:source:indices:)`](/documentation/MLCompute/MLCGraph/gather(withDimension:source:indices:))

Adds a gather layer to the graph using the source tensor, dimension along which to index, and the indices you specify.

[`scatter(withDimension:source:indices:copyFrom:reductionType:)`](/documentation/MLCompute/MLCGraph/scatter(withDimension:source:indices:copyFrom:reductionType:))

Adds a scatter layer to the graph.

[`transpose(dimensions:source:)`](/documentation/MLCompute/MLCGraph/transpose(dimensions:source:))

Adds a new transpose layer to the graph using the dimensions and source tensor you specify.

[`transposeWithDimensions:source:`](/documentation/MLCompute/MLCGraph/transposeWithDimensions:source:)

Adds a new transpose layer to the graph using the dimensions and source tensor you specify.

### Associating Data with Input Tensors

[`bindAndWriteData(_:forInputs:to:batchSize:synchronous:)`](/documentation/MLCompute/MLCGraph/bindAndWriteData(_:forInputs:to:batchSize:synchronous:))

Associates the given data with the input tensors, and if the device is a GPU, also copies the data to the device memory.

[`bindAndWriteData(_:forInputs:to:synchronous:)`](/documentation/MLCompute/MLCGraph/bindAndWriteData(_:forInputs:to:synchronous:))

Associates the given data with the input tensors, and if the device is a GPU, also copies the data to the device memory.

### Inspecting Graphs

[`sourceTensors(for:)`](/documentation/MLCompute/MLCGraph/sourceTensors(for:))

Gets the source tensors for a layer in the training graph.

[`resultTensors(for:)`](/documentation/MLCompute/MLCGraph/resultTensors(for:))

Gets the result tensors for a layer in the training graph.

[`device`](/documentation/MLCompute/MLCGraph/device)

The device you’ll use for compiling and executing a graph.

[`layers`](/documentation/MLCompute/MLCGraph/layers)

An array that contains the layers in the graph.

[`summarizedDOTDescription`](/documentation/MLCompute/MLCGraph/summarizedDOTDescription)

A DOT representation of the graph.



---

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)