tensorplay.nn.functional.scaled_dot_product_attention
- tensorplay.nn.functional.scaled_dot_product_attention(query: TensorBase, key: TensorBase, value: TensorBase, attn_mask=None, dropout_p: float = 0.0, is_causal: bool = False, scale=None, enable_gqa: bool = False, backend: str | None = None) TensorBase[source]
scaled_dot_product_attention(query, key, value, attn_mask=None, dropout_p=0.0, is_causal=False, scale=None, enable_gqa=False, backend=None) -> Tensor
Computes scaled dot product attention on query, key and value. Routes to reference:
- Parameters:
backend (str, optional) –
'flash'|'mem_efficient','math', orNoneto pick automatically.'flash'selects the fused flash-attention kernel,'math'forces the composed reference path. WhenNone, the routing candidate order is governed bytensorplay.nn.attention.sdpa_kernel().

