(self)
| 413 | dtype: jnp.dtype = jnp.float32 |
| 414 | |
| 415 | def setup(self): |
| 416 | resnet_groups = self.resnet_groups if self.resnet_groups is not None else min(self.in_channels // 4, 32) |
| 417 | |
| 418 | # there is always at least one resnet |
| 419 | resnets = [ |
| 420 | FlaxResnetBlock2D( |
| 421 | in_channels=self.in_channels, |
| 422 | out_channels=self.in_channels, |
| 423 | dropout=self.dropout, |
| 424 | groups=resnet_groups, |
| 425 | dtype=self.dtype, |
| 426 | ) |
| 427 | ] |
| 428 | |
| 429 | attentions = [] |
| 430 | |
| 431 | for _ in range(self.num_layers): |
| 432 | attn_block = FlaxAttentionBlock( |
| 433 | channels=self.in_channels, |
| 434 | num_head_channels=self.num_attention_heads, |
| 435 | num_groups=resnet_groups, |
| 436 | dtype=self.dtype, |
| 437 | ) |
| 438 | attentions.append(attn_block) |
| 439 | |
| 440 | res_block = FlaxResnetBlock2D( |
| 441 | in_channels=self.in_channels, |
| 442 | out_channels=self.in_channels, |
| 443 | dropout=self.dropout, |
| 444 | groups=resnet_groups, |
| 445 | dtype=self.dtype, |
| 446 | ) |
| 447 | resnets.append(res_block) |
| 448 | |
| 449 | self.resnets = resnets |
| 450 | self.attentions = attentions |
| 451 | |
| 452 | def __call__(self, hidden_states, deterministic=True): |
| 453 | hidden_states = self.resnets[0](hidden_states, deterministic=deterministic) |
nothing calls this directly
no test coverage detected