MCPcopy Create free account
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / block_forward

Function block_forward

dmidas/backbones/beit.py:94–107  ·  view source on GitHub ↗

Modification of timm.models.beit.py: Block.forward to support arbitrary window sizes.

(self, x, resolution, shared_rel_pos_bias: Optional[torch.Tensor] = None)

Source from the content-addressed store, hash-verified

92
93
94def block_forward(self, x, resolution, shared_rel_pos_bias: Optional[torch.Tensor] = None):
95 """
96 Modification of timm.models.beit.py: Block.forward to support arbitrary window sizes.
97 """
98 if hasattr(self, 'drop_path1') and not hasattr(self, 'drop_path'):
99 self.drop_path = self.drop_path1
100 if self.gamma_1 is None:
101 x = x + self.drop_path(self.attn(self.norm1(x), resolution, shared_rel_pos_bias=shared_rel_pos_bias))
102 x = x + self.drop_path(self.mlp(self.norm2(x)))
103 else:
104 x = x + self.drop_path(self.gamma_1 * self.attn(self.norm1(x), resolution,
105 shared_rel_pos_bias=shared_rel_pos_bias))
106 x = x + self.drop_path(self.gamma_2 * self.mlp(self.norm2(x)))
107 return x
108
109
110def beit_forward_features(self, x):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected