MCPcopy Create free account
hub / github.com/Ropedia/SpatialBench / forward

Method forward

benchmark/models/zipmap/zipmap/layers/block.py:70–91  ·  view source on GitHub ↗
(self, x: Tensor, pos=None)

Source from the content-addressed store, hash-verified

68 self.sample_drop_ratio = drop_path
69
70 def forward(self, x: Tensor, pos=None) -> Tensor:
71 def attn_residual_func(x: Tensor, pos=None) -> Tensor:
72 return self.ls1(self.attn(self.norm1(x), pos=pos))
73
74 def ffn_residual_func(x: Tensor) -> Tensor:
75 return self.ls2(self.mlp(self.norm2(x)))
76
77 if self.training and self.sample_drop_ratio > 0.1:
78 # the overhead is compensated only for a drop path rate larger than 0.1
79 x = drop_add_residual_stochastic_depth(
80 x, pos=pos, residual_func=attn_residual_func, sample_drop_ratio=self.sample_drop_ratio
81 )
82 x = drop_add_residual_stochastic_depth(
83 x, residual_func=ffn_residual_func, sample_drop_ratio=self.sample_drop_ratio
84 )
85 elif self.training and self.sample_drop_ratio > 0.0:
86 x = x + self.drop_path1(attn_residual_func(x, pos=pos))
87 x = x + self.drop_path1(ffn_residual_func(x)) # FIXME: drop_path2
88 else:
89 x = x + attn_residual_func(x, pos=pos)
90 x = x + ffn_residual_func(x)
91 return x
92
93
94def drop_add_residual_stochastic_depth(

Callers 1

forwardMethod · 0.45

Calls 1

Tested by

no test coverage detected