<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreML",
  "identifier" : "/documentation/CoreML/MLShapedArray/squeezingShape()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core ML",
      "CoreML"
    ],
    "preciseIdentifier" : "s:6CoreML13MLShapedArrayV14squeezingShapeACyxGyF"
  },
  "title" : "squeezingShape()"
}
-->

# squeezingShape()

Returns a new squeezed shaped array.

```
func squeezingShape() -> MLShapedArray<Scalar>
```

## Discussion

The new shape removes 1s in the original shape.

```swift
let original = MLShapedArray<Int32>(scalars: 0..., shape: [1, 2, 1, 2])
let squeezed = original.squeezingShape()
squeezed.shape // [2, 2]
```

When all the dimensions of the original shape is one, the resultant
shaped array is a scalar.

```swift
let original = MLShapedArray<Int32>(scalars: 42, shape: [1, 1])
let squeezed = original.squeezingShape()
squeezed.scalar // 42
```

---

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)