(in_channels, attn_type="vanilla", natten_kernel_size=-1, use_null_attention=False)
| 229 | |
| 230 | |
| 231 | def make_attn(in_channels, attn_type="vanilla", natten_kernel_size=-1, use_null_attention=False): |
| 232 | if attn_type == "vanilla": |
| 233 | assert not (use_null_attention and natten_kernel_size > -1), "use_null_attention and natten_kernel_size > -1 are mutually exclusive" |
| 234 | if natten_kernel_size > -1 and not NATTEN_IS_AVAILBLE: |
| 235 | raise ValueError("natten_kernel_size > -1 but natten is not available") |
| 236 | if use_null_attention: |
| 237 | print(f"Using null attention to save memory and compute...") |
| 238 | return MemoryEfficientAttnBlock(in_channels, natten_kernel_size=natten_kernel_size, use_null_attention=use_null_attention) |
| 239 | |
| 240 | elif attn_type == "none": |
| 241 | return nn.Identity(in_channels) |
| 242 | |
| 243 | else: |
| 244 | raise NotImplementedError(f"attn_type {attn_type} not implemented") |
| 245 | |
| 246 | |
| 247 | """ Encoder and Decoder """ |
no test coverage detected