<!--
{
  "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(_:)-511a",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Metal Performance Shaders Graph"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSGraphTensorData(im)initWithMPSImageBatch:"
  },
  "title" : "init(_:)"
}
-->

# init(_:)

Initializes a tensor data with an MPS image batch.

```
init(_ imageBatch: [MPSImage])
```

## Parameters

`imageBatch`

The device on which the kernel will run, unorm8 and unorm16 images will create a float32 tensorData

## Return Value

A valid MPSGraphTensorData, or nil if allocation failure.

## Discussion

The dataLayout used will be NHWC, call a transpose or permute to change to a layout of your choice.

---

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)