<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreML",
  "identifier" : "/documentation/CoreML/MLMultiArray/init(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core ML",
      "CoreML"
    ],
    "preciseIdentifier" : "s:So12MLMultiArrayC6CoreMLEyABxKcSlRzs17FixedWidthInteger7ElementRpzlufc::OverloadGroup"
  },
  "title" : "init(_:)"
}
-->

# init(_:)

An MLMultiArray constructed with the FixedWidthInteger elements of the collection
converted to Int32.

```
convenience init<C>(_ data: C) throws where C : Collection, C.Element : FixedWidthInteger
```

## Discussion

```
let v:[Int32] = [3, 2, 1]
let m = try MLMultiArray(v)
print(m)
Int32 3 vector
[3,2,1]
```

This initializer will trap if called with data containing FixedWidthInteger elements
that cannot be safely converted to Int32, but it is safe to use with
wider types so long as the actual data is within range.

```
let a = try MLMultiArray([Int.max]) // trap!
let b = try MLMultiArray([Int(Int32.max), Int(Int32.min)]) // This is fine.
```

---

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)