<!--
{
  "availability" : [
    "iOS: 14.0.0 - 17.0.0",
    "iPadOS: 14.0.0 - 17.0.0",
    "macCatalyst: 14.0.0 - 17.0.0",
    "macOS: 11.0.0 - 14.0.0",
    "tvOS: 14.0.0 - 17.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "MLCompute",
  "identifier" : "/documentation/MLCompute/MLCTensor/init(shape:fillWithData:dataType:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "ML Compute",
      "MLCompute"
    ],
    "preciseIdentifier" : "s:So9MLCTensorC9MLComputeE5shape12fillWithData8dataTypeABSaySiG_So8NSNumberCSo07MLCDataH0Vtcfc"
  },
  "title" : "init(shape:fillWithData:dataType:)"
}
-->

# init(shape:fillWithData:dataType:)

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

```
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.

---

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)