---
title: "init(shape:fillWithData:dataType:)"
framework: ML Compute
role: symbol
role_heading: Initializer
platforms: [iOS 14.0+, iPadOS 14.0+, Mac Catalyst 14.0+, macOS 11.0+, tvOS 14.0+]
path: "mlcompute/mlctensor/init(shape:fillwithdata:datatype:)"
---

# init(shape:fillWithData:dataType:)

Creates a tensor with the shape, scalar value, and data type you specify.

## Declaration

```swift
convenience init(shape: [Int], fillWithData fillData: NSNumber, dataType: MLCDataType)
```

## Parameters

- `shape`: An array that contains the sizes of each dimension.
- `fillData`: The scalar value with which to initialize the tensor data.
- `dataType`: The tensor data type.

## See Also

### 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: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)
