[Refactor] Remove dead code multiple places (#60120)
Signed-off-by: yewentao256 <zhyanwentao@126.com>
This commit is contained in:
@@ -255,25 +255,6 @@ class KeyeVisionEmbeddings(nn.Module):
|
||||
patch_pos_embed = patch_pos_embed.permute(0, 2, 3, 1).view(1, -1, dim)
|
||||
return patch_pos_embed
|
||||
|
||||
def fetch_position_embedding_lfu_cache(self, embeddings, h, w, max_cache: int = 20):
|
||||
grid = (h, w)
|
||||
if grid in self.cache_position_embedding:
|
||||
self.cache_position_count[grid] += 1
|
||||
return self.cache_position_embedding[grid]
|
||||
|
||||
if len(self.cache_position_embedding) >= max_cache:
|
||||
min_hit_grid = min(
|
||||
self.cache_position_count,
|
||||
key=self.cache_position_count.__getitem__,
|
||||
)
|
||||
self.cache_position_count.pop(min_hit_grid)
|
||||
self.cache_position_embedding.pop(min_hit_grid)
|
||||
|
||||
position_embedding = self.interpolate_pos_encoding(embeddings, h, w, True)
|
||||
self.cache_position_count[grid] = 1
|
||||
self.cache_position_embedding[grid] = position_embedding
|
||||
return position_embedding
|
||||
|
||||
def forward(
|
||||
self,
|
||||
pixel_values: torch.FloatTensor,
|
||||
|
||||
Reference in New Issue
Block a user