Contents

scaledDotProductAttention(query:key:value:descriptor:name:)

Creates a scaled dot product attention (SDPA) operation using a descriptor and returns the result tensor.

Declaration

func scaledDotProductAttention(query queryTensor: MPSGraphTensor, key keyTensor: MPSGraphTensor, value valueTensor: MPSGraphTensor, descriptor: MPSGraphSDPADescriptor, name: String?) -> MPSGraphTensor

Parameters

  • queryTensor:

    A tensor that represents the query projection.

  • keyTensor:

    A tensor that represents the key projection.

  • valueTensor:

    A tensor that represents the value projection.

  • descriptor:

    A descriptor specifying scale and optional features (mask, isCausal, sinks).

  • name:

    The name for the operation.

Return Value

A valid MPSGraphTensor object.

Discussion

The descriptor allows configuring an optional attention mask, causal masking, and attention sinks without requiring a separate API method for each combination of features.