---
title: MLCTensor
framework: ML Compute
role: symbol
role_heading: Class
platforms: [iOS 14.0+, iPadOS 14.0+, Mac Catalyst 14.0+, macOS 11.0+, tvOS 14.0+]
path: mlcompute/mlctensor
---

# MLCTensor

The data object you use throughout the framework.

## Declaration

```swift
class MLCTensor
```

## Overview

Overview Create a tensor with or without data. For example, create a tensor with data for weights used by convolution or mean, variance, beta, and gamma parameters with batch normalization. Create a tensor without data to use as an input tensor when you build a graph.

## Topics

### Creating Tensors with Descriptors

- [init(descriptor:)](mlcompute/mlctensor/init(descriptor:).md)
- [init(descriptor:data:)](mlcompute/mlctensor/init(descriptor:data:).md)
- [init(descriptor:fillWithData:)](mlcompute/mlctensor/init(descriptor:fillwithdata:).md)
- [init(descriptor:randomInitializerType:)](mlcompute/mlctensor/init(descriptor:randominitializertype:).md)
- [MLCTensorDescriptor](mlcompute/mlctensordescriptor.md)
- [MLCDataType](mlcompute/mlcdatatype.md)
- [MLCTensorData](mlcompute/mlctensordata.md)
- [MLCRandomInitializerType](mlcompute/mlcrandominitializertype.md)

### Creating Tensors by Specifying Shape

- [init(shape:)](mlcompute/mlctensor/init(shape:).md)
- [init(shape:dataType:)](mlcompute/mlctensor/init(shape:datatype:).md)
- [init(shape:data:dataType:)](mlcompute/mlctensor/init(shape:data:datatype:).md)
- [init(shape:fillWithData:dataType:)](mlcompute/mlctensor/init(shape:fillwithdata:datatype:).md)
- [init(shape:randomInitializerType:)](mlcompute/mlctensor/init(shape:randominitializertype:).md)
- [init(width:height:featureChannelCount:batchSize:)](mlcompute/mlctensor/init(width:height:featurechannelcount:batchsize:).md)
- [init(width:height:featureChannelCount:batchSize:data:)](mlcompute/mlctensor/init(width:height:featurechannelcount:batchsize:data:).md)
- [init(width:height:featureChannelCount:batchSize:data:dataType:)](mlcompute/mlctensor/init(width:height:featurechannelcount:batchsize:data:datatype:).md)
- [init(width:height:featureChannelCount:batchSize:fillWithData:dataType:)](mlcompute/mlctensor/init(width:height:featurechannelcount:batchsize:fillwithdata:datatype:).md)
- [init(width:height:featureChannelCount:batchSize:randomInitializerType:)](mlcompute/mlctensor/init(width:height:featurechannelcount:batchsize:randominitializertype:).md)

### Creating Tensors by Specifying Sequence Lengths

- [init(sequenceLength:featureChannelCount:batchSize:)](mlcompute/mlctensor/init(sequencelength:featurechannelcount:batchsize:).md)
- [init(sequenceLength:featureChannelCount:batchSize:data:)](mlcompute/mlctensor/init(sequencelength:featurechannelcount:batchsize:data:).md)
- [init(sequenceLengths:sortedSequences:featureChannelCount:batchSize:data:)](mlcompute/mlctensor/init(sequencelengths:sortedsequences:featurechannelcount:batchsize:data:).md)
- [init(sequenceLength:featureChannelCount:batchSize:randomInitializerType:)](mlcompute/mlctensor/init(sequencelength:featurechannelcount:batchsize:randominitializertype:).md)
- [init(sequenceLengths:sortedSequences:featureChannelCount:batchSize:randomInitializerType:)](mlcompute/mlctensor/init(sequencelengths:sortedsequences:featurechannelcount:batchsize:randominitializertype:).md)

### Inspecting Tensors

- [tensorID](mlcompute/mlctensor/tensorid.md)
- [descriptor](mlcompute/mlctensor/descriptor.md)
- [data](mlcompute/mlctensor/data.md)
- [label](mlcompute/mlctensor/label.md)
- [device](mlcompute/mlctensor/device.md)
- [optimizerData](mlcompute/mlctensor/optimizerdata.md)
- [optimizerDeviceData](mlcompute/mlctensor/optimizerdevicedata.md)
- [hasValidNumerics](mlcompute/mlctensor/hasvalidnumerics.md)
- [MLCTensorOptimizerDeviceData](mlcompute/mlctensoroptimizerdevicedata.md)

### Converting Tensors

- [quantized(to:scale:bias:)](mlcompute/mlctensor/quantized(to:scale:bias:).md)
- [quantized(to:scale:bias:axis:)](mlcompute/mlctensor/quantized(to:scale:bias:axis:).md)
- [dequantized(to:scale:zeroPoint:)](mlcompute/mlctensor/dequantized(to:scale:zeropoint:).md)
- [dequantized(to:scale:bias:axis:)](mlcompute/mlctensor/dequantized(to:scale:bias:axis:).md)

### Managing Tensor Data

- [synchronizeData()](mlcompute/mlctensor/synchronizedata().md)
- [synchronizeOptimizerData()](mlcompute/mlctensor/synchronizeoptimizerdata().md)
- [copyDataFromDeviceMemory(toBytes:length:synchronizeWithDevice:)](mlcompute/mlctensor/copydatafromdevicememory(tobytes:length:synchronizewithdevice:).md)
- [bindAndWriteData(_:to:)](mlcompute/mlctensor/bindandwritedata(_:to:).md)
- [bindOptimizerData(_:deviceData:)](mlcompute/mlctensor/bindoptimizerdata(_:devicedata:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Components

- [MLCPlatform](mlcompute/mlcplatform.md)
- [Layers](mlcompute/layers.md)
- [Training and Validation](mlcompute/training-and-validation.md)
