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

# init(device:data:shape:dataType:)

Initializes the tensor data with an NSData on a device.

## Declaration

```swift
init(device: MPSGraphDevice, data: Data, shape: [NSNumber], dataType: MPSDataType)
```

## Parameters

- `device`: MPSDevice on which the MPSGraphTensorData exists
- `data`: NSData from which to copy the contents
- `shape`: Shape of the output tensor
- `dataType`: dataType of the placeholder tensor

## Return Value

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