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

# init(_:shape:dataType:)

Initializes an tensor data with a metal buffer.

## Declaration

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

## Parameters

- `buffer`: MTLBuffer to be used within the MPSGraphTensorData
- `shape`: Shape of the output tensor
- `dataType`: dataType of the placeholder tensor

## 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.
