MCPcopy Create free account
hub / github.com/PolyU-ChenLab/UniPixel / Fuser

Class Fuser

sam2/modeling/memory_encoder.py:117–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115
116
117class Fuser(nn.Module):
118
119 def __init__(self, layer, num_layers, dim=None, input_projection=False):
120 super().__init__()
121 self.proj = nn.Identity()
122 # NOTE: avoid using copy.deepcopy with zero3 or ZeroGPUs
123 self.layers = nn.ModuleList([CXBlock(**layer) for _ in range(num_layers)])
124 # self.layers = get_clones(layer, num_layers)
125
126 if input_projection:
127 assert dim is not None
128 self.proj = nn.Conv2d(dim, dim, kernel_size=1)
129
130 def forward(self, x):
131 # normally x: (N, C, H, W)
132 x = self.proj(x)
133 for layer in self.layers:
134 x = layer(x)
135 return x
136
137
138class MemoryEncoder(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected