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

# split(count:alongAxis:)

Splits a tensor into multiple tensors. The tensor is split along dimension `axis` into `count` smaller tensors.

```
func split(count: Int, alongAxis axis: Int = 0) -> [MLTensor]
```

## Parameters

`count`

The number of splits to create, must divide the size of dimension `axis` evenly.

`axis`

The dimension along which to split this tensor. The `axis` must be in the range `[-rank, rank)`.

## Return Value

An array containing the tensor parts.

## Discussion

For example:

```
// 'value' is a tensor with shape [5, 30]
// Split 'value' into 3 tensors along dimension 1:
let parts = value.split(count: 3, alongAxis: 1)
parts[0] // has shape [5, 10]
parts[1] // has shape [5, 10]
parts[2] // has shape [5, 10]
```

---

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)