Contents

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 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, and additionally requires:

  • offset is 0 when usage contains machineLearning.

  • offset is aligned to 128 bytes if the data plane uses a format 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:) instead to create a multi-plane tensor with per-plane buffer backing storage.