<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreML",
  "identifier" : "/documentation/CoreML/MLMultiArray/init(pixelBuffer:shape:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core ML",
      "CoreML"
    ],
    "preciseIdentifier" : "c:objc(cs)MLMultiArray(im)initWithPixelBuffer:shape:"
  },
  "title" : "init(pixelBuffer:shape:)"
}
-->

# init(pixelBuffer:shape:)

Creates a multiarray sharing the surface of a pixel buffer.

```
init(pixelBuffer: CVPixelBuffer, shape: [NSNumber])
```

## Parameters

`pixelBuffer`

The pixel buffer owned by the instance.

`shape`

The shape of the `MLMultiArray`. The last dimension of `shape` must match the pixel buffer’s width. The product of the rest of the dimensions must match the height.

## Discussion

Use this initializer to create an <doc://com.apple.documentation/documentation/IOSurface>-backed `MLMultiArray` that reduces the inference latency by avoiding the buffer copy to and from some compute units.

The instance will own the pixel buffer and release it on the deallocation.

The pixel buffer’s pixel format type must be <doc://com.apple.documentation/documentation/CoreVideo/kCVPixelFormatType_OneComponent16Half>. The `MLMultiArray` data type is [`MLMultiArrayDataType.float16`](/documentation/CoreML/MLMultiArrayDataType/float16).

---

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)