<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShaders",
  "identifier" : "/documentation/MetalPerformanceShaders/MPSRNNSingleGateDescriptor",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Metal Performance Shaders"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSRNNSingleGateDescriptor"
  },
  "title" : "MPSRNNSingleGateDescriptor"
}
-->

# MPSRNNSingleGateDescriptor

A description of a simple recurrent block or layer.

```
class MPSRNNSingleGateDescriptor
```

## Overview

The recurrent neural network (RNN) layer initialized with a [`MPSRNNSingleGateDescriptor`](/documentation/MetalPerformanceShaders/MPSRNNSingleGateDescriptor) transforms the input data (image or matrix) and previous output with a set of filters. Each produces one feature map in the new output data.

You may provide the RNN unit with a single input or a sequence of inputs.

### Description of Operation

1. Let `x_j` be the input data (at time index `t` of sequence, `j` index containing quadruplet: batch index, `x,y` and feature index (`x = y = 0` for matrices)).
2. Let `h0_j` be the recurrent input (previous output) data from previous time step (at time index `t-1` of sequence).
3. Let `h1_i` be the output data produced at this time step.
4. Let `W_ij, U_ij` be the weights for input and recurrent input data, respectively.
5. Let `b_i` be a bias term.
6. Let `gi(x)` be a neuron activation function.

The new output image `h1_i` data is computed as follows:

```other
h1_i = gi( W_ij * x_j + U_ij * h0_j  + b_i )
```

The `*` stands for convolution (see [`MPSRNNImageInferenceLayer`](/documentation/MetalPerformanceShaders/MPSRNNImageInferenceLayer)) or matrix-vector/matrix multiplication (see [`MPSRNNMatrixInferenceLayer`](/documentation/MetalPerformanceShaders/MPSRNNMatrixInferenceLayer)).

Summation is over index `j` (except for the batch index), but there’s no summation over repeated index `i` (the output index).

Note that for validity, all intermediate images must be of same size, and the `U` matrix must be square (that is, [`outputFeatureChannels`](/documentation/MetalPerformanceShaders/MPSRNNDescriptor/outputFeatureChannels) `==` [`inputFeatureChannels`](/documentation/MetalPerformanceShaders/MPSRNNDescriptor/inputFeatureChannels)). Also, the bias terms are scalars with regard to spatial dimensions.

## Topics

### Instance Properties

[`inputWeights`](/documentation/MetalPerformanceShaders/MPSRNNSingleGateDescriptor/inputWeights)

[`recurrentWeights`](/documentation/MetalPerformanceShaders/MPSRNNSingleGateDescriptor/recurrentWeights)

[`MPSCNNConvolutionDataSource`](/documentation/MetalPerformanceShaders/MPSCNNConvolutionDataSource)

The protocol that provides convolution filter weights and bias terms.

### Type Methods

[`+  createRNNSingleGateDescriptorWithInputFeatureChannels:outputFeatureChannels:`](/documentation/MetalPerformanceShaders/MPSRNNSingleGateDescriptor/createRNNSingleGateDescriptor(withInputFeatureChannels:outputFeatureChannels:))

## Relationships

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

### Inherits From

[`MPSRNNDescriptor`](/documentation/MetalPerformanceShaders/MPSRNNDescriptor)

---

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)