<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreAI",
  "identifier" : "/documentation/CoreAI/NDArray/init(shape:scalarType:strides:interleaveLayout:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core AI",
      "CoreAI"
    ],
    "preciseIdentifier" : "s:13CoreAIRuntime7NDArrayV5shape10scalarType7strides16interleaveLayoutACSaySiG_AC06ScalarF0OAhC010InterleaveI0Vtcfc"
  },
  "title" : "init(shape:scalarType:strides:interleaveLayout:)"
}
-->

# init(shape:scalarType:strides:interleaveLayout:)

Initialize an NDArray with the provided shape, scalar type, strides, and interleaved dimension.

```
init(shape: [Int], scalarType: NDArray.ScalarType, strides: [Int], interleaveLayout: NDArray.InterleaveLayout)
```

## Parameters

`shape`

The length of each dimension of the ndArray.

`scalarType`

The type of elements in the ndArray.

`strides`

The strides of the ndArray.

`interleaveLayout`

Which dimension is interleaved and by what factor.
See [`NDArray.InterleaveLayout`](/documentation/CoreAI/NDArray/InterleaveLayout-swift.struct).

## Discussion

`shape` and `strides` must have the same number of elements.

---

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)