MCPcopy Create free account
hub / github.com/pytorch/executorch / __call__

Method __call__

backends/mlx/patterns.py:512–541  ·  view source on GitHub ↗
(self, P: MLXProgramBuilder, n: Node)

Source from the content-addressed store, hash-verified

510 return SDPAHandler(head, body, q_node=q, k_node=k_base, v_node=v_base)
511
512 def __call__(self, P: MLXProgramBuilder, n: Node) -> Slot:
513 assert n == self.head
514 q, k, v, attn_mask, dropout_p, is_causal, scale, enable_gqa = (
515 SDPAHandler._parse_sdpa_args_and_kwargs(n)
516 )
517 head_dim = q.meta["val"].shape[-1]
518 if scale is None:
519 scale = head_dim**-0.5
520
521 q = self.q_node
522 k = self.k_node
523 v = self.v_node
524
525 assert dropout_p == 0.0, "SDPA with dropout is not supported"
526
527 q, k, v, attn_mask = P.slot_map([q, k, v, attn_mask])
528 out = P.make_or_get_slot(n)
529
530 P.emit(
531 SdpaNode(
532 q=P.slot_to_tid(q),
533 k=P.slot_to_tid(k),
534 v=P.slot_to_tid(v),
535 out=P.slot_to_tid(out),
536 scale=scale,
537 mask=P.slot_to_tid(attn_mask) if attn_mask else None,
538 causal=is_causal,
539 )
540 )
541 return out
542
543
544@REGISTRY.register_pattern(name="NVFP4_QUANTIZED_EMBEDDING")

Callers

nothing calls this directly

Calls 5

slot_mapMethod · 0.80
emitMethod · 0.80
slot_to_tidMethod · 0.80
make_or_get_slotMethod · 0.45

Tested by

no test coverage detected