(img_h, img_w, patch_size, max_num_patches_per_side)
| 48 | |
| 49 | |
| 50 | def get_flattened_position_ids_extrapolate(img_h, img_w, patch_size, max_num_patches_per_side): |
| 51 | num_patches_h, num_patches_w = img_h // patch_size, img_w // patch_size |
| 52 | coords_h = torch.arange(0, num_patches_h) |
| 53 | coords_w = torch.arange(0, num_patches_w) |
| 54 | pos_ids = (coords_h[:, None] * max_num_patches_per_side + coords_w).flatten() |
| 55 | return pos_ids |
| 56 | |
| 57 | # if (height, width) not in self.position_cache: |
| 58 | # y_coords = torch.arange(height, device=device) |
nothing calls this directly
no outgoing calls
no test coverage detected