makeTensor(descriptor:offset:)
Creates a single-plane tensor with the specified descriptor that shares storage with this buffer.
Declaration
func makeTensor(descriptor: MTLTensorDescriptor, offset: Int) throws -> any MTLTensorParameters
- 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, and additionally requires:
offsetis 0 when usage contains machineLearning.offsetis aligned to 128 bytes if the data plane uses a format MTLTensorDataType.offsetis 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:) instead to create a multi-plane tensor with per-plane buffer backing storage.