---
title: MLCGramMatrixLayer
framework: ML Compute
role: symbol
role_heading: Class
platforms: [iOS 14.0+, iPadOS 14.0+, Mac Catalyst 14.0+, macOS 11.0+, tvOS 14.0+]
path: mlcompute/mlcgrammatrixlayer
---

# MLCGramMatrixLayer

A layer that computes the uncentered cross-correlation values between the spacial planes of each feature channel of a tensor.

## Declaration

```swift
class MLCGramMatrixLayer
```

## Overview

Overview For example, if the input tensor batch function is: x = x[b, y, x, c] The computation performed by this layer is: y = y[b, 1, f, c] = alpha * sum_{x, y} x[b, y, x, f] * x[b, y, x, c] Interpret this operation as computing all combinations of fully connected layers between the different spatial planes of the input tensor. The layer performs this operation independently for each tensor in a batch. Then the layer stores these results in the feature channel and x-coordinate indices of the output batch. Legend:

## Topics

### Creating Gram Matrix Layers

- [init(scale:)](mlcompute/mlcgrammatrixlayer/init(scale:).md)

### Inspecting Gram Matrix Layers

- [scale](mlcompute/mlcgrammatrixlayer/scale.md)

## Relationships

### Inherits From

- [MLCLayer](mlcompute/mlclayer.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Math Layers

- [MLCArithmeticLayer](mlcompute/mlcarithmeticlayer.md)
- [MLCReductionLayer](mlcompute/mlcreductionlayer.md)
- [MLCMatMulLayer](mlcompute/mlcmatmullayer.md)
- [MLCFullyConnectedLayer](mlcompute/mlcfullyconnectedlayer.md)
- [MLCComparisonLayer](mlcompute/mlccomparisonlayer.md)
