Skip to content

Commit

Permalink
sync sum_centerness_targets only when num_gpus > 1
Browse files Browse the repository at this point in the history
  • Loading branch information
tianzhi0549 committed Aug 26, 2019
1 parent 816bfa6 commit 0145839
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fcos_core/modeling/rpn/fcos/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,13 @@ def __call__(self, locations, box_cls, box_regression, centerness, targets):

if pos_inds.numel() > 0:
centerness_targets = self.compute_centerness_targets(reg_targets_flatten)

sum_centerness_targets = centerness_targets.sum()
sum_centerness_targets = reduce_sum(sum_centerness_targets).item()
if num_gpus > 1:
sum_centerness_targets = reduce_sum(sum_centerness_targets).item()
else:
sum_centerness_targets = sum_centerness_targets.item()

reg_loss = self.box_reg_loss_func(
box_regression_flatten,
reg_targets_flatten,
Expand Down

0 comments on commit 0145839

Please sign in to comment.