---
title: "init(_:shape:dataType:rowBytes:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Initializer
path: "metalperformanceshadersgraph/mpsgraphtensordata/init(_:shape:datatype:rowbytes:)"
---

# init(_:shape:dataType:rowBytes:)

Initializes an tensor data with a metal buffer.

## Declaration

```swift
init(_ buffer: any MTLBuffer, shape: [NSNumber], dataType: MPSDataType, rowBytes: Int)
```

## Parameters

- `buffer`: MTLBuffer to be used within the MPSGraphTensorData
- `shape`: Shape of the output tensor
- `dataType`: dataType of the placeholder tensor
- `rowBytes`: rowBytes for the fastest moving dimension, must be larger than or equal to sizeOf(dataType)shape[rank - 1] and must be a multiple of sizeOf(dataType)

## Return Value

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

## Discussion

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