---
title: "scaledDotProductAttention(query:key:value:descriptor:name:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/scaleddotproductattention(query:key:value:descriptor:name:)"
---

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

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

## Declaration

```swift
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

Return Value A valid MPSGraphTensor object.

## Discussion

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.
