<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShadersGraph",
  "identifier" : "/documentation/MetalPerformanceShadersGraph/MPSGraph/scaledDotProductAttention(query:key:value:scale:name:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal Performance Shaders Graph",
      "MetalPerformanceShadersGraph"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSGraph(im)scaledDotProductAttentionWithQueryTensor:keyTensor:valueTensor:scale:name:"
  },
  "title" : "scaledDotProductAttention(query:key:value:scale:name:)"
}
-->

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

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

```
func scaledDotProductAttention(query queryTensor: MPSGraphTensor, key keyTensor: MPSGraphTensor, value valueTensor: MPSGraphTensor, scale: Float, 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.

`scale`

A scale that is applied on the result of query and value matrix multiply.

`name`

The name for the operation.

## Return Value

A valid MPSGraphTensor object.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)