<!--
{
  "availability" : [
    "iOS: 11.2.0 -",
    "iPadOS: 11.2.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.2 -",
    "tvOS: 11.2.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.2.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreML",
  "identifier" : "/documentation/CoreML/MLCustomLayer",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Core ML"
    ],
    "preciseIdentifier" : "c:objc(pl)MLCustomLayer"
  },
  "title" : "MLCustomLayer"
}
-->

# MLCustomLayer

An interface that defines the behavior of a custom layer in your neural network model.

```
protocol MLCustomLayer
```

## Overview

You use the [`MLCustomLayer`](/documentation/CoreML/MLCustomLayer) protocol to define the behavior of your own neural network layers in Core ML models. You can deploy novel or proprietary models on your own release schedule. Custom layers also provide a mechanism for pre- or post-processing during model evaluation.

## Topics

### Creating a layer

[`init(parameters:)`](/documentation/CoreML/MLCustomLayer/init(parameters:))

Initializes the custom layer implementation.

### Integrating a layer

[`setWeightData(_:)`](/documentation/CoreML/MLCustomLayer/setWeightData(_:))

Assigns the weights for the connections within the layer.

[`outputShapes(forInputShapes:)`](/documentation/CoreML/MLCustomLayer/outputShapes(forInputShapes:))

Calculates the shapes of the output of this layer for the given input shapes.

### Evaluating a layer

[`evaluate(inputs:outputs:)`](/documentation/CoreML/MLCustomLayer/evaluate(inputs:outputs:))

Evaluates the custom layer with the given inputs.

[`encode(commandBuffer:inputs:outputs:)`](/documentation/CoreML/MLCustomLayer/encode(commandBuffer:inputs:outputs:))

Encodes GPU commands to evaluate the custom layer.



---

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)