<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/BNNS/Shape",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate4BNNSO5ShapeO"
  },
  "title" : "BNNS.Shape"
}
-->

# BNNS.Shape

Constants that describe the size and data layout of an n-dimensional array descriptor.

```
enum Shape
```

## Topics

### Creating a Shape

[`init([Int], dataLayout: BNNS.DataLayout?, stride: [Int]?)`](/documentation/Accelerate/BNNS/Shape/init(_:dataLayout:stride:))

Returns a new shape with the specified size, data layout, and stride.

[`init(arrayLiteral: BNNS.Shape.ArrayLiteralElement...)`](/documentation/Accelerate/BNNS/Shape/init(arrayLiteral:))

Returns a new shape with the specified size.

### Specifying the Data Layout of a Shape

[`enum DataLayout`](/documentation/Accelerate/BNNS/DataLayout)

Constants that describe the data layout of an n-dimensional array descriptor shape.

### Shape Constants

[`case vector(Int, stride: Int)`](/documentation/Accelerate/BNNS/Shape/vector(_:stride:))

A constant that represents a shape with a 1D vector data layout.

[`case matrixColumnMajor(Int, Int, stride: (Int, Int))`](/documentation/Accelerate/BNNS/Shape/matrixColumnMajor(_:_:stride:))

A constant that represents a shape with a 2D column-major data layout.

[`case matrixRowMajor(Int, Int, stride: (Int, Int))`](/documentation/Accelerate/BNNS/Shape/matrixRowMajor(_:_:stride:))

A constant that represents a shape with a 2D row-major data layout.

[`case matrixFirstMajor(Int, Int, stride: (Int, Int))`](/documentation/Accelerate/BNNS/Shape/matrixFirstMajor(_:_:stride:))

A constant that represents a shape with a 2D first-major data layout.

[`case matrixLastMajor(Int, Int, stride: (Int, Int))`](/documentation/Accelerate/BNNS/Shape/matrixLastMajor(_:_:stride:))

A constant that represents a shape with a 2D last-major data layout.

[`case imageCHW(Int, Int, Int, stride: (Int, Int, Int))`](/documentation/Accelerate/BNNS/Shape/imageCHW(_:_:_:stride:))

A constant that represents a shape with a 3D image stack data layout.

[`case tensor3DFirstMajor(Int, Int, Int, stride: (Int, Int, Int))`](/documentation/Accelerate/BNNS/Shape/tensor3DFirstMajor(_:_:_:stride:))

A constant that represents a shape with a 3D first-major data layout.

[`case tensor3DLastMajor(Int, Int, Int, stride: (Int, Int, Int))`](/documentation/Accelerate/BNNS/Shape/tensor3DLastMajor(_:_:_:stride:))

A constant that represents a shape with a 3D last-major data layout.

[`case tensor3DNSE(Int, Int, Int, stride: (Int, Int, Int))`](/documentation/Accelerate/BNNS/Shape/tensor3DNSE(_:_:_:stride:))

A constant that represents a shape with the size elements embedding dimension, sequence length, and batch size.

[`case tensor3DSNE(Int, Int, Int, stride: (Int, Int, Int))`](/documentation/Accelerate/BNNS/Shape/tensor3DSNE(_:_:_:stride:))

A constant that represents a shape with the size elements embedding dimension, batch size, and sequence length.

[`case convolutionWeightsOIHW(Int, Int, Int, Int, stride: (Int, Int, Int, Int))`](/documentation/Accelerate/BNNS/Shape/convolutionWeightsOIHW(_:_:_:_:stride:))

A constant that represents a shape with a 4D array of convolution weights data layout.

[`case tensor4DFirstMajor(Int, Int, Int, Int, stride: (Int, Int, Int, Int))`](/documentation/Accelerate/BNNS/Shape/tensor4DFirstMajor(_:_:_:_:stride:))

A constant that represents a shape with a 4D first-major data layout.

[`case tensor4DLastMajor(Int, Int, Int, Int, stride: (Int, Int, Int, Int))`](/documentation/Accelerate/BNNS/Shape/tensor4DLastMajor(_:_:_:_:stride:))

A constant that represents a shape with a 4D last-major data layout.

[`case tensor5DFirstMajor(Int, Int, Int, Int, Int, stride: (Int, Int, Int, Int, Int))`](/documentation/Accelerate/BNNS/Shape/tensor5DFirstMajor(_:_:_:_:_:stride:))

A constant that represents a shape with a 5D first-major data layout.

[`case tensor5DLastMajor(Int, Int, Int, Int, Int, stride: (Int, Int, Int, Int, Int))`](/documentation/Accelerate/BNNS/Shape/tensor5DLastMajor(_:_:_:_:_:stride:))

A constant that represents a shape with a 5D last-major data layout.

[`case tensor6DFirstMajor(Int, Int, Int, Int, Int, Int, stride: (Int, Int, Int, Int, Int, Int))`](/documentation/Accelerate/BNNS/Shape/tensor6DFirstMajor(_:_:_:_:_:_:stride:))

A constant that represents a shape with a 6D first-major data layout.

[`case tensor6DLastMajor(Int, Int, Int, Int, Int, Int, stride: (Int, Int, Int, Int, Int, Int))`](/documentation/Accelerate/BNNS/Shape/tensor6DLastMajor(_:_:_:_:_:_:stride:))

A constant that represents a shape with a 6D last-major data layout.

[`case tensor7DFirstMajor(Int, Int, Int, Int, Int, Int, Int, stride: (Int, Int, Int, Int, Int, Int, Int))`](/documentation/Accelerate/BNNS/Shape/tensor7DFirstMajor(_:_:_:_:_:_:_:stride:))

A constant that represents a shape with a 7D first-major data layout.

[`case tensor7DLastMajor(Int, Int, Int, Int, Int, Int, Int, stride: (Int, Int, Int, Int, Int, Int, Int))`](/documentation/Accelerate/BNNS/Shape/tensor7DLastMajor(_:_:_:_:_:_:_:stride:))

A constant that represents a shape with a 7D last-major data layout.

[`case tensor8DFirstMajor(Int, Int, Int, Int, Int, Int, Int, Int, stride: (Int, Int, Int, Int, Int, Int, Int, Int))`](/documentation/Accelerate/BNNS/Shape/tensor8DFirstMajor(_:_:_:_:_:_:_:_:stride:))

A constant that represents a shape with a 8D first-major data layout.

[`case tensor8DLastMajor(Int, Int, Int, Int, Int, Int, Int, Int, stride: (Int, Int, Int, Int, Int, Int, Int, Int))`](/documentation/Accelerate/BNNS/Shape/tensor8DLastMajor(_:_:_:_:_:_:_:_:stride:))

A constant that represents a shape with a 8D last-major data layout.

### Inspecting the Properties of a Shape

[`var batchStride: Int`](/documentation/Accelerate/BNNS/Shape/batchStride)

The number of elements between each batch of data in the shape.

[`var layout: BNNSDataLayout`](/documentation/Accelerate/BNNS/Shape/layout)

The data layout of the shape.

[`var rank: Int`](/documentation/Accelerate/BNNS/Shape/rank)

The number of dimensions of the shape.

[`var size: (Int, Int, Int, Int, Int, Int, Int, Int)`](/documentation/Accelerate/BNNS/Shape/size)

The size, in elements, of each dimension of the shape.

[`var stride: (Int, Int, Int, Int, Int, Int, Int, Int)`](/documentation/Accelerate/BNNS/Shape/stride)

The stride, in elements, of each dimension of the shape.

### Default Implementations

[ExpressibleByArrayLiteral Implementations](/documentation/Accelerate/BNNS/Shape/ExpressibleByArrayLiteral-Implementations)

## Relationships

### Conforms To

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

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

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

---

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)