(
self,
query_dim: int,
cross_attention_dim: int | None = None,
heads: int = 8,
kv_heads: int | None = None,
dim_head: int = 64,
dropout: float = 0.0,
bias: bool = False,
upcast_attention: bool = False,
upcast_softmax: bool = False,
cross_attention_norm: str | None = None,
cross_attention_norm_num_groups: int = 32,
qk_norm: str | None = None,
added_kv_proj_dim: int | None = None,
added_proj_bias: bool | None = True,
norm_num_groups: int | None = None,
spatial_norm_dim: int | None = None,
out_bias: bool = True,
scale_qk: bool = True,
only_cross_attention: bool = False,
eps: float = 1e-5,
rescale_output_factor: float = 1.0,
residual_connection: bool = False,
_from_deprecated_attn_block: bool = False,
processor: "AttnProcessor" | None = None,
out_dim: int = None,
out_context_dim: int = None,
context_pre_only=None,
pre_only=False,
elementwise_affine: bool = True,
is_causal: bool = False,
)
| 105 | """ |
| 106 | |
| 107 | def __init__( |
| 108 | self, |
| 109 | query_dim: int, |
| 110 | cross_attention_dim: int | None = None, |
| 111 | heads: int = 8, |
| 112 | kv_heads: int | None = None, |
| 113 | dim_head: int = 64, |
| 114 | dropout: float = 0.0, |
| 115 | bias: bool = False, |
| 116 | upcast_attention: bool = False, |
| 117 | upcast_softmax: bool = False, |
| 118 | cross_attention_norm: str | None = None, |
| 119 | cross_attention_norm_num_groups: int = 32, |
| 120 | qk_norm: str | None = None, |
| 121 | added_kv_proj_dim: int | None = None, |
| 122 | added_proj_bias: bool | None = True, |
| 123 | norm_num_groups: int | None = None, |
| 124 | spatial_norm_dim: int | None = None, |
| 125 | out_bias: bool = True, |
| 126 | scale_qk: bool = True, |
| 127 | only_cross_attention: bool = False, |
| 128 | eps: float = 1e-5, |
| 129 | rescale_output_factor: float = 1.0, |
| 130 | residual_connection: bool = False, |
| 131 | _from_deprecated_attn_block: bool = False, |
| 132 | processor: "AttnProcessor" | None = None, |
| 133 | out_dim: int = None, |
| 134 | out_context_dim: int = None, |
| 135 | context_pre_only=None, |
| 136 | pre_only=False, |
| 137 | elementwise_affine: bool = True, |
| 138 | is_causal: bool = False, |
| 139 | ): |
| 140 | super().__init__() |
| 141 | |
| 142 | # To prevent circular import. |
| 143 | from .normalization import FP32LayerNorm, LpNorm, RMSNorm |
| 144 | |
| 145 | self.inner_dim = out_dim if out_dim is not None else dim_head * heads |
| 146 | self.inner_kv_dim = self.inner_dim if kv_heads is None else dim_head * kv_heads |
| 147 | self.query_dim = query_dim |
| 148 | self.use_bias = bias |
| 149 | self.is_cross_attention = cross_attention_dim is not None |
| 150 | self.cross_attention_dim = cross_attention_dim if cross_attention_dim is not None else query_dim |
| 151 | self.upcast_attention = upcast_attention |
| 152 | self.upcast_softmax = upcast_softmax |
| 153 | self.rescale_output_factor = rescale_output_factor |
| 154 | self.residual_connection = residual_connection |
| 155 | self.dropout = dropout |
| 156 | self.fused_projections = False |
| 157 | self.out_dim = out_dim if out_dim is not None else query_dim |
| 158 | self.out_context_dim = out_context_dim if out_context_dim is not None else query_dim |
| 159 | self.context_pre_only = context_pre_only |
| 160 | self.pre_only = pre_only |
| 161 | self.is_causal = is_causal |
| 162 | |
| 163 | # we make use of this private variable to know whether this class is loaded |
| 164 | # with an deprecated state dict so that we can convert it on the fly |
no test coverage detected