<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLBuffer/makeTensor(descriptor:offset:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLBuffer(im)newTensorWithDescriptor:offset:error:"
  },
  "title" : "makeTensor(descriptor:offset:)"
}
-->

# makeTensor(descriptor:offset:)

Creates a single-plane tensor with the specified descriptor that shares storage with this buffer.

```
func makeTensor(descriptor: MTLTensorDescriptor, offset: Int) throws -> any MTLTensor
```

## Parameters

`descriptor`

The tensor descriptor configuring the data plane.

`offset`

The byte offset into the buffer where tensor data begins.

## Return Value

A tensor, or `nil` if validation fails.

## Discussion

This method validates the constraints documented on [`MTLTensorDescriptor`](/documentation/Metal/MTLTensorDescriptor),
and additionally requires:

- `offset` is 0 when [`usage`](/documentation/Metal/MTLTensorDescriptor/usage) contains
  [`machineLearning`](/documentation/Metal/MTLTensorUsage/machineLearning).
- `offset` is aligned to 128 bytes if the data plane uses a format
  [`MTLTensorDataType`](/documentation/Metal/MTLTensorDataType).
- `offset` is aligned to the size of the data type in bytes otherwise.

This method doesn’t create tensors that contain auxiliary planes. Use
[`makeTensor(descriptor:attachments:)`](/documentation/Metal/MTLDevice/makeTensor(descriptor:attachments:))
instead to create a multi-plane tensor with per-plane buffer backing storage.

---

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)