<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShadersGraph",
  "identifier" : "/documentation/MetalPerformanceShadersGraph/MPSGraphTensorData/init(device:data:shape:dataType:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Metal Performance Shaders Graph"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSGraphTensorData(im)initWithDevice:data:shape:dataType:"
  },
  "title" : "init(device:data:shape:dataType:)"
}
-->

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

Initializes the tensor data with an `NSData` on a device.

```
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

A valid MPSGraphTensorData, or nil if allocation failure.

---

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)