未验证 提交 caf46020 编写于 作者: D duanyanhui 提交者: GitHub

fix syn_bn for npu (#8246)

上级 2fedefa3
......@@ -429,10 +429,8 @@ class Trainer(object):
model = self.model
if self.cfg.get('to_static', False):
model = apply_to_static(self.cfg, model)
sync_bn = (
getattr(self.cfg, 'norm_type', None) == 'sync_bn' and
(self.cfg.use_gpu or self.cfg.use_npu or self.cfg.use_mlu) and
self._nranks > 1)
sync_bn = (getattr(self.cfg, 'norm_type', None) == 'sync_bn' and
(self.cfg.use_gpu or self.cfg.use_mlu) and self._nranks > 1)
if sync_bn:
model = paddle.nn.SyncBatchNorm.convert_sync_batchnorm(model)
......
......@@ -317,12 +317,15 @@ class SparseRCNNHead(nn.Layer):
pooler_scales = [1.0 / 4.0, 1.0 / 8.0, 1.0 / 16.0, 1.0 / 32.0]
end_level = 3
aligned = True
if paddle.device.is_compiled_with_custom_device('npu'):
aligned = False
box_pooler = RoIAlign(
resolution=pooler_resolution,
spatial_scale=pooler_scales,
sampling_ratio=sampling_ratio,
end_level=end_level,
aligned=True)
aligned=aligned)
return box_pooler
def forward(self, features, input_whwh):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册