(self, dim, num_heads, mlp_ratio=4., qkv_bias=False, drop=0., attn_drop=0.,
drop_path=0., act_layer=nn.GELU, norm_layer=nn.LayerNorm, norm_mem=True, rope=None)
| 171 | class DecoderBlock(nn.Module): |
| 172 | |
| 173 | def __init__(self, dim, num_heads, mlp_ratio=4., qkv_bias=False, drop=0., attn_drop=0., |
| 174 | drop_path=0., act_layer=nn.GELU, norm_layer=nn.LayerNorm, norm_mem=True, rope=None): |
| 175 | super().__init__() |
| 176 | self.norm1 = norm_layer(dim) |
| 177 | self.attn = Attention(dim, rope=rope, num_heads=num_heads, qkv_bias=qkv_bias, attn_drop=attn_drop, proj_drop=drop) |
| 178 | self.cross_attn = CrossAttention(dim, rope=rope, num_heads=num_heads, qkv_bias=qkv_bias, attn_drop=attn_drop, proj_drop=drop) |
| 179 | self.drop_path = DropPath(drop_path) if drop_path > 0. else nn.Identity() |
| 180 | self.norm2 = norm_layer(dim) |
| 181 | self.norm3 = norm_layer(dim) |
| 182 | mlp_hidden_dim = int(dim * mlp_ratio) |
| 183 | self.mlp = Mlp(in_features=dim, hidden_features=mlp_hidden_dim, act_layer=act_layer, drop=drop) |
| 184 | self.norm_y = norm_layer(dim) if norm_mem else nn.Identity() |
| 185 | |
| 186 | def forward(self, x, y, xpos, ypos): |
| 187 | x = x + self.drop_path(self.attn(self.norm1(x), xpos)) |
nothing calls this directly
no test coverage detected