Skip to content

Commit

Permalink
zeta mmca
Browse files Browse the repository at this point in the history
  • Loading branch information
Kye committed Sep 27, 2023
1 parent 37f8166 commit e4196a4
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion mmca/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def __init__(
dim,
heads=8,
dropout=0.1,

):
super().__init__()
self.heads = heads
Expand Down Expand Up @@ -118,3 +117,36 @@ def forward(self, v, t):
t = self.cross_attn(t, t, t)[0] + self.cross_attn(t, v, v)[0]

return t


from zeta.nn import FlashAttention

class ZetaMMCA(nn.Module):
def __init__(
self,
flash=True,
causal=True,
dropout=0.1,
):
super().__init__()

self.self_attn = FlashAttention(
flash=flash,
causal=causal,
dropout=dropout,
)

self.cross_attn = FlashAttention(
flash=flash,
causal=causal,
dropout=dropout,
)

def forward(self, v, t):
#self attention for visual tokens
v = self.self_attn(v, v, v)[0]

#cross attention for textual tokens
t = self.cross_attn(t, t, t)[0] + self.cross_attn(t, v, v)[0]

return t

0 comments on commit e4196a4

Please sign in to comment.