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

# MPSMatrix

A 2D array of data that stores the data’s values.

```
class MPSMatrix
```

## Overview

[`MPSMatrix`](/documentation/MetalPerformanceShaders/MPSMatrix) objects serve as inputs and outputs of [`MPSMatrixMultiplication`](/documentation/MetalPerformanceShaders/MPSMatrixMultiplication) objects. Matrix data is assumed to be stored in row-major order.

> Note:
> An ``doc://com.apple.metalperformanceshaders/documentation/MetalPerformanceShaders/MPSMatrix`` object maintains its internal storage using a <doc://com.apple.documentation/documentation/Metal/MTLBuffer> object. Thus, the same rules for maintaining coherency of the buffer’s data between CPU memory and GPU memory also apply to an ``doc://com.apple.metalperformanceshaders/documentation/MetalPerformanceShaders/MPSMatrix`` object.

## Topics

### Methods

[`init(buffer:descriptor:)`](/documentation/MetalPerformanceShaders/MPSMatrix/init(buffer:descriptor:))

Initializes a matrix with a buffer.

### Properties

[`device`](/documentation/MetalPerformanceShaders/MPSMatrix/device)

The device on which the matrix will be used.

[`rows`](/documentation/MetalPerformanceShaders/MPSMatrix/rows)

The number of rows in the matrix.

[`columns`](/documentation/MetalPerformanceShaders/MPSMatrix/columns)

The number of columns in the matrix.

[`dataType`](/documentation/MetalPerformanceShaders/MPSMatrix/dataType)

The type of the values in the matrix.

[`rowBytes`](/documentation/MetalPerformanceShaders/MPSMatrix/rowBytes)

The stride, in bytes, between corresponding elements of consecutive rows in the matrix.

[`data`](/documentation/MetalPerformanceShaders/MPSMatrix/data)

The buffer that stores the matrix data.

[`matrices`](/documentation/MetalPerformanceShaders/MPSMatrix/matrices)

[`matrixBytes`](/documentation/MetalPerformanceShaders/MPSMatrix/matrixBytes)



---

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)