(
    dots, q_info, kv_info, causal=True, exclude_self=True, masked=False)
return dots
Performs masking for self-attention.
Performs masking for self-attention.
Performs masking for self - attention .
def mask_self_attention(
    dots, q_info, kv_info, causal=True, exclude_self=True, masked=False):
  """Performs masking for self-attention."""
  q_info = q_info.astype(np.float32)
  kv_info = kv_info.astype(np.float32)
  if causal:
    mask = fastmath.lt(q_info, kv_info)
    dots = dots - 1e9 * mask
  if exclude_self:
    mask = np.equal(q_info, kv_info)
    dots = dots - 1e5 * mask
  if masked:
    zeros_like_kv_info = np.zeros_like(kv_info)
    mask = fastmath.lt(kv_info, zeros_like_kv_info).astype(np.float32)
    dots = dots - 1e9 * mask
  return dots
def mask_self_attention ( dots , q_info , kv_info , causal = True , exclude_self = True , masked = False ) : q_info = q_info . astype ( np . float32 ) kv_info = kv_info . astype ( np . float32 ) if causal : mask = fastmath . lt ( q_info , kv_info ) dots = dots - 1e9 * mask if exclude_self : mask = np . equal ( q_info , kv_info ) dots = dots - 1e5 * mask if masked : zeros_like_kv_info = np . zeros_like ( kv_info ) mask = fastmath . lt ( kv_info , zeros_like_kv_info ) . astype ( np . float32 ) dots = dots - 1e9 * mask return dots