<!--
{
  "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/resolvingDynamicDimensions(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core AI"
    ],
    "preciseIdentifier" : "s:13CoreAIRuntime17NDArrayDescriptorV26resolvingDynamicDimensionsyACSaySiGF"
  },
  "title" : "resolvingDynamicDimensions(_:)"
}
-->

# resolvingDynamicDimensions(_:)

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

```
func resolvingDynamicDimensions(_ newShape: [Int]) -> NDArrayDescriptor
```

## Discussion

If the original model contained ndArray arguments with dynamic shapes, then the `NDArrayDescriptor` returned for that argument
from the `InferenceFunctionDescriptor` will contain the value `-1` in the dimensions with dynamic sizes.

This method allows you to provide a resolved shape and obtain a new descriptor with that adjusted shape.

```swift
let functionDescriptor = model.functionDescriptor(for: "main")
guard case .ndArray(let ndArrayDescriptor) = functionDescriptor.inputDescriptor(of: "dynamic_shape_input") else {
  // Handle input not found or not ndArray
}

// The 'dynamic_shape_input' argument is a rank 3 ndArray with a dynamic shape for the final dimension.
// ndArrayDescriptor.shape == [128, 128, -1]

// Make a resolved descriptor which fills in the -1 dimension with the concrete value 10
let resolvedDescriptor = ndArrayDescriptor.resolvingDynamicDimensions([128, 128, 10])
```

> Note: `newShape` must be the same size as the `shape` of the descriptor it is called on.
> Also for each dimension, it must hold true that the provided new shape either matches the existing shape, or the existing shape is `-1`.

---

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)