<!--
{
  "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/NDArrayDescriptor",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Core AI"
    ],
    "preciseIdentifier" : "s:13CoreAIRuntime17NDArrayDescriptorV"
  },
  "title" : "NDArrayDescriptor"
}
-->

# NDArrayDescriptor

A description of an array’s shape, scalar type, and memory layout expectations.

```
struct NDArrayDescriptor
```

## Overview

You obtain an `NDArrayDescriptor` from an [`InferenceFunctionDescriptor`](/documentation/CoreAI/InferenceFunctionDescriptor) by querying
the descriptor of a specific input or output:

```swift
let valueDescriptor = functionDescriptor.inputDescriptor(of: "x")!
guard case .ndArray(let ndArrayDescriptor) = valueDescriptor else { ... }
```

The descriptor contains the expectations for an array value that you provide to an
[`InferenceFunction`](/documentation/CoreAI/InferenceFunction). Most expectations are strict: for example, if the descriptor
specifies [`scalarType`](/documentation/CoreAI/NDArrayDescriptor/scalarType) as `.float32`, the array you provide must use `.float32`.

## Topics

### Inspecting descriptor properties

[`shape`](/documentation/CoreAI/NDArrayDescriptor/shape)

The length of each dimension of the array.

[`scalarType`](/documentation/CoreAI/NDArrayDescriptor/scalarType)

The scalar type of the array.

[`rank`](/documentation/CoreAI/NDArrayDescriptor/rank)

The number of dimensions in the array.

[`hasDynamicShape`](/documentation/CoreAI/NDArrayDescriptor/hasDynamicShape)

A Boolean value that indicates whether the shape has any dynamic dimensions.

[`interleaveLayout`](/documentation/CoreAI/NDArrayDescriptor/interleaveLayout)

Returns the interleaved layout of this ndArray, or `nil` if there is no interleave.

### Computing layout

[`minimumByteCount`](/documentation/CoreAI/NDArrayDescriptor/minimumByteCount)

The minimum number of bytes needed for storage with this
descriptor’s shape and preferred strides.

[`preferredStrides`](/documentation/CoreAI/NDArrayDescriptor/preferredStrides)

The strides that avoid data layout transformations during inference.

### Resolving dynamic shapes

[`resolvingDynamicDimensions(_:)`](/documentation/CoreAI/NDArrayDescriptor/resolvingDynamicDimensions(_:))

Returns a new descriptor with all dynamic dimensions replaced by concrete values.

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

---

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)