---
title: "setBuffer(_:offset:for:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtltensorbufferattachments/setbuffer(_:offset:for:)"
---

# setBuffer(_:offset:for:)

Sets the buffer and byte offset to use as backing storage for the given plane.

## Declaration

```swift
func setBuffer(_ buffer: any MTLBuffer, offset: Int, for plane: MTLTensorPlaneType)
```

## Parameters

- `buffer`: The buffer to back the plane.
- `offset`: The byte offset into the buffer.
- `plane`: The plane type to associate the buffer with.

## Discussion

Discussion The buffer must not be nil. The offset must be aligned to 128 bytes if the plane uses a format MTLTensorDataType, otherwise it must be aligned to the size of the plane’s data type in bytes.
