Source/Packages

Realization.Nvidia.SM86.StreamingAttentionSM86

packages/realizations/cooperative/nvidia-sm86/src/Realization/Nvidia/SM86/StreamingAttentionSM86.alpha

1,203 lines221 declarations70.9 KiBSHA-256 23d4e5e2aa2a

def · lines 896–905

skMaskTile

Full file
the diagonal sub-tile's mask: element (key r + 8h, query 8 nt + 2 (lane % 4) + b) is kept when the query is not before the key: saMask holds 2 (lane % 4) - 16 warp - lane / 4 + 128, plus 4096 for every sub-tile before the diagonal one
896def skMaskTile = (lambda unrestricted tail : (family SM86Program) .
897  (saFor 16 (lambda unrestricted i : Nat .
898    (let unrestricted nt = (naturalDivideUnchecked i 4) in (let unrestricted h = (naturalDivideUnchecked (naturalModuloUnchecked i 4) 2) in
899      (let unrestricted b = (naturalModuloUnchecked i 2) in
900      (let unrestricted threshold = (naturalSaturatingSubtract (naturalAdd 127 (naturalMultiply 8 h)) (naturalAdd (naturalMultiply 8 nt) b)) in
901      (lambda unrestricted rest : (family SM86Program) .
902        (saGreater saP0 saMask threshold
903          (saUnless saP0 (constructor SM86InstructionBody SM86MoveImmediate (saR (saElem (skS nt) h b)) (saU saMinusInfinity) saPlain)
904            rest))))))))
905    tail))

The compiler supplied declaration spans and resolved links from this source snapshot. This page does not assert that this file belongs to a checked closure.