---
title: "init(pixelBuffer:shape:)"
framework: coreml
role: symbol
role_heading: Initializer
path: "coreml/mlmultiarray/init(pixelbuffer:shape:)"
---

# init(pixelBuffer:shape:)

Creates a multiarray sharing the surface of a pixel buffer.

## Declaration

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

Discussion Use this initializer to create an 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 kCVPixelFormatType_OneComponent16Half. The MLMultiArray data type is MLMultiArrayDataType.float16.

## See Also

### Creating a multiarray

- [init(_:)](coreml/mlmultiarray/init(_:).md)
- [init(shape:dataType:)](coreml/mlmultiarray/init(shape:datatype:).md)
- [init(shape:dataType:strides:)](coreml/mlmultiarray/init(shape:datatype:strides:).md)
- [init(dataPointer:shape:dataType:strides:deallocator:)](coreml/mlmultiarray/init(datapointer:shape:datatype:strides:deallocator:).md)
- [init(byConcatenatingMultiArrays:alongAxis:dataType:)](coreml/mlmultiarray/init(byconcatenatingmultiarrays:alongaxis:datatype:).md)
- [MLMultiArrayDataType](coreml/mlmultiarraydatatype.md)
