init(pixelBuffer:shape:)
Creates a multiarray sharing the surface of a pixel buffer.
Declaration
init(pixelBuffer: CVPixelBuffer, shape: [NSNumber])Parameters
- pixelBuffer:
The pixel buffer owned by the instance.
- shape:
The shape of the
MLMultiArray. The last dimension ofshapemust 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 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.