Skip to content

Commit a784db4

Browse files
xuzhao9datumbox
andauthored
Atttempt to reduce unnecessary cuda sync (#5515)
Co-authored-by: Vasilis Vryniotis <[email protected]>
1 parent e836b3d commit a784db4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

torchvision/models/detection/anchor_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ def forward(self, image_list: ImageList, feature_maps: List[Tensor]) -> List[Ten
121121
dtype, device = feature_maps[0].dtype, feature_maps[0].device
122122
strides = [
123123
[
124-
torch.tensor(image_size[0] // g[0], dtype=torch.int64, device=device),
125-
torch.tensor(image_size[1] // g[1], dtype=torch.int64, device=device),
124+
torch.empty((), dtype=torch.int64, device=device).fill_(image_size[0] // g[0]),
125+
torch.empty((), dtype=torch.int64, device=device).fill_(image_size[1] // g[1]),
126126
]
127127
for g in grid_sizes
128128
]

0 commit comments

Comments
 (0)