<!--
{
  "availability" : [
    "iOS: 14.0.0 - 17.4.0",
    "iPadOS: 14.0.0 - 17.4.0",
    "macCatalyst: 14.0.0 - 17.4.0",
    "macOS: 11.0.0 - 14.3.0",
    "tvOS: 14.0.0 - 17.4.0"
  ],
  "documentType" : "symbol",
  "framework" : "MLCompute",
  "identifier" : "/documentation/MLCompute/MLCTensorDescriptor",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "ML Compute"
    ],
    "preciseIdentifier" : "c:objc(cs)MLCTensorDescriptor"
  },
  "title" : "MLCTensorDescriptor"
}
-->

# MLCTensorDescriptor

A configuration object you use to create a tensor.

```
class MLCTensorDescriptor
```

## Overview

This class contains the mathematical properties of a tensor, such as data type and shape. It also includes initializers that help you create a tensor descriptor for common use cases, such as convolutional neural networks and recurrent neural networks.

## Topics

### Creating Tensor Descriptors

[`init(shape:dataType:)`](/documentation/MLCompute/MLCTensorDescriptor/init(shape:dataType:))

Creates a tensor descriptor with the shape and data type you specify.

[`init(shape:sequenceLengths:sortedSequences:dataType:)`](/documentation/MLCompute/MLCTensorDescriptor/init(shape:sequenceLengths:sortedSequences:dataType:))

Creates a tensor descriptor with the shape, variable sequence lengths, sorting indicator, and data type you specify.

[`descriptorWithShape:dataType:`](/documentation/MLCompute/MLCTensorDescriptor/descriptorWithShape:dataType:)

Creates a tensor descriptor with the shape and data type you specify.

[`descriptorWithShape:sequenceLengths:sortedSequences:dataType:`](/documentation/MLCompute/MLCTensorDescriptor/descriptorWithShape:sequenceLengths:sortedSequences:dataType:)

Creates a tensor descriptor with the shape, variable sequence lengths, sorting indicator, and data type you specify.

[`init(width:height:featureChannelCount:batchSize:)`](/documentation/MLCompute/MLCTensorDescriptor/init(width:height:featureChannelCount:batchSize:))

Creates a tensor descriptor with the width and height, number of feature channels, and batch size you specify.

[`init(width:height:featureChannelCount:batchSize:dataType:)`](/documentation/MLCompute/MLCTensorDescriptor/init(width:height:featureChannelCount:batchSize:dataType:))

Creates a tensor descriptor with the width and height, number of feature channels, batch size, and data type you specify.

[`init(convolutionWeightsWithInputFeatureChannelCount:outputFeatureChannelCount:dataType:)`](/documentation/MLCompute/MLCTensorDescriptor/init(convolutionWeightsWithInputFeatureChannelCount:outputFeatureChannelCount:dataType:))

Creates a tensor descriptor with the number of feature channels and data type you specify.

[`init(convolutionWeightsWithWidth:height:inputFeatureChannelCount:outputFeatureChannelCount:dataType:)`](/documentation/MLCompute/MLCTensorDescriptor/init(convolutionWeightsWithWidth:height:inputFeatureChannelCount:outputFeatureChannelCount:dataType:))

Creates a tensor descriptor with the sizing, number of feature channels, and data type you specify.

[`init(convolutionBiasesWithFeatureChannelCount:dataType:)`](/documentation/MLCompute/MLCTensorDescriptor/init(convolutionBiasesWithFeatureChannelCount:dataType:))

Creates a tensor descriptor with the number of feature channels and data type you specify.

[`maxTensorDimensions`](/documentation/MLCompute/MLCTensorDescriptor/maxTensorDimensions)

The maximum number of tensor dimensions.

### Inspecting Tensor Descriptors

[`dataType`](/documentation/MLCompute/MLCTensorDescriptor/dataType)

The tensor data type.

[`dimensionCount`](/documentation/MLCompute/MLCTensorDescriptor/dimensionCount)

The number of dimensions in the tensor.

[`shape`](/documentation/MLCompute/MLCTensorDescriptor/shape-7i1rw)

An array that contains the size in each dimension.

[`stride`](/documentation/MLCompute/MLCTensorDescriptor/stride-5mzlt)

An array that contains the stride, in bytes, in each dimension.

[`shape`](/documentation/MLCompute/MLCTensorDescriptor/shape-91vng)

An array that contains the size in each dimension.

[`stride`](/documentation/MLCompute/MLCTensorDescriptor/stride-3ydik)

An array that contains the stride, in bytes, in each dimension.

[`tensorAllocationSizeInBytes`](/documentation/MLCompute/MLCTensorDescriptor/tensorAllocationSizeInBytes)

The allocation size, in bytes, for a tensor.

[`sequenceLengths`](/documentation/MLCompute/MLCTensorDescriptor/sequenceLengths-3jdab)

An array that contains the variable lengths of sequences stored in the tensor.

[`sequenceLengths`](/documentation/MLCompute/MLCTensorDescriptor/sequenceLengths-3ntsa)

An array that contains the variable lengths of sequences stored in the tensor.

[`sortedSequences`](/documentation/MLCompute/MLCTensorDescriptor/sortedSequences)

A Boolean that indicates whether you provided the sequence lengths sorted in descending order.

[`batchSizePerSequenceStep`](/documentation/MLCompute/MLCTensorDescriptor/batchSizePerSequenceStep-6iz59)

The batch size for each sequence.

[`batchSizePerSequenceStep`](/documentation/MLCompute/MLCTensorDescriptor/batchSizePerSequenceStep-55mp8)

The batch size for each sequence.



---

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)