<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreML",
  "identifier" : "/documentation/CoreML/MLMultiArray/init(dataPointer:shape:dataType:strides:deallocator:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core ML",
      "CoreML"
    ],
    "preciseIdentifier" : "c:objc(cs)MLMultiArray(im)initWithDataPointer:shape:dataType:strides:deallocator:error:"
  },
  "title" : "init(dataPointer:shape:dataType:strides:deallocator:)"
}
-->

# init(dataPointer:shape:dataType:strides:deallocator:)

Creates a multiarray from a data pointer.

```
init(dataPointer: UnsafeMutableRawPointer, shape: [NSNumber], dataType: MLMultiArrayDataType, strides: [NSNumber], deallocator: ((UnsafeMutableRawPointer) -> Void)? = nil) throws
```

## Parameters

`dataPointer`

A pointer to data in memory.

`shape`

An integer array with an element for each dimension. An element represents the size of the corresponding dimension.

`dataType`

An [`MLMultiArrayDataType`](/documentation/CoreML/MLMultiArrayDataType) instance that represents the pointer’s data type.

`strides`

An integer array with an element for each dimension. An element represents the number of memory locations that span the length of the corresponding dimension.

`deallocator`

In Swift, a closure the multiarray calls in its deinitializer. In Objective-C, a block the multiarray calls in its <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/dealloc> method.

## Discussion

The caller is responsible for freeing the memory the `dataPointer` points to, by providing a `deallocator` closure.

---

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)