<!--
{
  "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(descriptor:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core AI",
      "CoreAI"
    ],
    "preciseIdentifier" : "s:13CoreAIRuntime7NDArrayV10descriptorAcA0C10DescriptorV_tcfc"
  },
  "title" : "init(descriptor:)"
}
-->

# init(descriptor:)

Creates an array with the shape and preferred strides from the specified descriptor.

```
init(descriptor: consuming NDArrayDescriptor)
```

## Parameters

`descriptor`

The descriptor that defines the array’s shape and scalar type.

## Discussion

The resulting array may not have a contiguous layout. The strides match the values
returned by the descriptor’s preferred strides, so `contiguousElements` on a view
of this array may return `nil`. In that case, use `withUnsafePointer` or
`withUnsafeMutablePointer` to access the data while respecting the strides.

If the descriptor has an [`NDArray.InterleaveLayout`](/documentation/CoreAI/NDArray/InterleaveLayout-swift.struct), the resulting ndArray will
carry that interleave metadata. See [`NDArray.InterleaveLayout`](/documentation/CoreAI/NDArray/InterleaveLayout-swift.struct) for details on
how interleaved layouts affect stride semantics.

The descriptor’s [`hasDynamicShape`](/documentation/CoreAI/NDArrayDescriptor/hasDynamicShape) must be `false`. If the
descriptor has dynamic shapes, call
[`resolvingDynamicDimensions(_:)`](/documentation/CoreAI/NDArrayDescriptor/resolvingDynamicDimensions(_:)) first.

---

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)