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

# init(shape:dataType:)

Creates a multidimensional array with a shape and type.

## Declaration

```swift
init(shape: [NSNumber], dataType: MLMultiArrayDataType) throws
```

## Parameters

- `shape`: An integer array that has an element for each dimension in a multiarray that represents its length.
- `dataType`: An element type defined by doc://com.apple.coreml/documentation/CoreML/MLMultiArrayDataType.

## Discussion

Discussion This method allocates a contiguous region of memory for the multiarray’s shape. You must set the contents of memory. The multiarray frees the memory in its deinitializer (Swift) or dealloc method (Objective-C). The following code creates a 3 x 3 multiarray and sets its contents to the value 3.14159.

## See Also

### Creating a multiarray

- [init(_:)](coreml/mlmultiarray/init(_:).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)
- [init(pixelBuffer:shape:)](coreml/mlmultiarray/init(pixelbuffer:shape:).md)
- [MLMultiArrayDataType](coreml/mlmultiarraydatatype.md)
