(
up_block_type: str,
num_layers: int,
in_channels: int,
out_channels: int,
prev_output_channel: int,
temb_channels: int,
add_upsample: bool,
resnet_eps: float,
resnet_act_fn: str,
num_attention_heads: int,
resolution_idx: Optional[int] = None,
resnet_groups: Optional[int] = None,
cross_attention_dim: Optional[int] = None,
dual_cross_attention: bool = False,
use_linear_projection: bool = True,
only_cross_attention: bool = False,
upcast_attention: bool = False,
resnet_time_scale_shift: str = "default",
temporal_num_attention_heads: int = 8,
temporal_cross_attention_dim: Optional[int] = None,
temporal_max_seq_length: int = 32,
transformer_layers_per_block: Union[int, Tuple[int]] = 1,
temporal_transformer_layers_per_block: Union[int, Tuple[int]] = 1,
dropout: float = 0.0,
)
| 172 | |
| 173 | |
| 174 | def get_up_block( |
| 175 | up_block_type: str, |
| 176 | num_layers: int, |
| 177 | in_channels: int, |
| 178 | out_channels: int, |
| 179 | prev_output_channel: int, |
| 180 | temb_channels: int, |
| 181 | add_upsample: bool, |
| 182 | resnet_eps: float, |
| 183 | resnet_act_fn: str, |
| 184 | num_attention_heads: int, |
| 185 | resolution_idx: Optional[int] = None, |
| 186 | resnet_groups: Optional[int] = None, |
| 187 | cross_attention_dim: Optional[int] = None, |
| 188 | dual_cross_attention: bool = False, |
| 189 | use_linear_projection: bool = True, |
| 190 | only_cross_attention: bool = False, |
| 191 | upcast_attention: bool = False, |
| 192 | resnet_time_scale_shift: str = "default", |
| 193 | temporal_num_attention_heads: int = 8, |
| 194 | temporal_cross_attention_dim: Optional[int] = None, |
| 195 | temporal_max_seq_length: int = 32, |
| 196 | transformer_layers_per_block: Union[int, Tuple[int]] = 1, |
| 197 | temporal_transformer_layers_per_block: Union[int, Tuple[int]] = 1, |
| 198 | dropout: float = 0.0, |
| 199 | ) -> Union[ |
| 200 | "UpBlock3D", |
| 201 | "CrossAttnUpBlock3D", |
| 202 | "UpBlockSpatioTemporal", |
| 203 | "CrossAttnUpBlockSpatioTemporal", |
| 204 | ]: |
| 205 | if up_block_type == "UpBlock3D": |
| 206 | return UpBlock3D( |
| 207 | num_layers=num_layers, |
| 208 | in_channels=in_channels, |
| 209 | out_channels=out_channels, |
| 210 | prev_output_channel=prev_output_channel, |
| 211 | temb_channels=temb_channels, |
| 212 | add_upsample=add_upsample, |
| 213 | resnet_eps=resnet_eps, |
| 214 | resnet_act_fn=resnet_act_fn, |
| 215 | resnet_groups=resnet_groups, |
| 216 | resnet_time_scale_shift=resnet_time_scale_shift, |
| 217 | resolution_idx=resolution_idx, |
| 218 | dropout=dropout, |
| 219 | ) |
| 220 | elif up_block_type == "CrossAttnUpBlock3D": |
| 221 | if cross_attention_dim is None: |
| 222 | raise ValueError("cross_attention_dim must be specified for CrossAttnUpBlock3D") |
| 223 | return CrossAttnUpBlock3D( |
| 224 | num_layers=num_layers, |
| 225 | in_channels=in_channels, |
| 226 | out_channels=out_channels, |
| 227 | prev_output_channel=prev_output_channel, |
| 228 | temb_channels=temb_channels, |
| 229 | add_upsample=add_upsample, |
| 230 | resnet_eps=resnet_eps, |
| 231 | resnet_act_fn=resnet_act_fn, |
nothing calls this directly
no test coverage detected