---
title: "init(_:rank:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Initializer
path: "metalperformanceshadersgraph/mpsgraphtensordata/init(_:rank:)-1lnxg"
---

# init(_:rank:)

Initializes a tensor data with an MPS matrix enforcing rank of the result.

## Declaration

```swift
init(_ matrix: MPSMatrix, rank: Int)
```

## Parameters

- `matrix`: MPSMatrix to be used within the MPSGraphTensorData
- `rank`: The rank of the resulting TensorData tensor. NOTE: must be within { 1, … ,16 }.

## Return Value

Return Value A valid MPSGraphTensorData of given rank, or nil if allocation failure.

## Discussion

Discussion The device of the MPSMatrix will be used to get the MPSDevice for this MPSGraphTensorData.
