Skip to content

Commit f767a3a

Browse files
authored
fix syn_bn for npu (#8247)
1 parent 83136bb commit f767a3a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

ppdet/engine/trainer.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,8 @@ def train(self, validate=False):
429429
model = self.model
430430
if self.cfg.get('to_static', False):
431431
model = apply_to_static(self.cfg, model)
432-
sync_bn = (
433-
getattr(self.cfg, 'norm_type', None) == 'sync_bn' and
434-
(self.cfg.use_gpu or self.cfg.use_npu or self.cfg.use_mlu) and
435-
self._nranks > 1)
432+
sync_bn = (getattr(self.cfg, 'norm_type', None) == 'sync_bn' and
433+
(self.cfg.use_gpu or self.cfg.use_mlu) and self._nranks > 1)
436434
if sync_bn:
437435
model = paddle.nn.SyncBatchNorm.convert_sync_batchnorm(model)
438436

ppdet/modeling/heads/sparsercnn_head.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,15 @@ def _init_box_pooler(input_shape):
317317
pooler_scales = [1.0 / 4.0, 1.0 / 8.0, 1.0 / 16.0, 1.0 / 32.0]
318318
end_level = 3
319319

320+
aligned = True
321+
if paddle.device.is_compiled_with_custom_device('npu'):
322+
aligned = False
320323
box_pooler = RoIAlign(
321324
resolution=pooler_resolution,
322325
spatial_scale=pooler_scales,
323326
sampling_ratio=sampling_ratio,
324327
end_level=end_level,
325-
aligned=True)
328+
aligned=aligned)
326329
return box_pooler
327330

328331
def forward(self, features, input_whwh):

0 commit comments

Comments
 (0)