diff --git a/ppdet/modeling/backbones/blazenet.py b/ppdet/modeling/backbones/blazenet.py index 8b4f63db3ab8ae4e1e22a23fde70babb0f9166d9..d3987521af36151430c94f24c1848e0936e15884 100644 --- a/ppdet/modeling/backbones/blazenet.py +++ b/ppdet/modeling/backbones/blazenet.py @@ -19,6 +19,7 @@ from __future__ import print_function from paddle import fluid from paddle.fluid.param_attr import ParamAttr +from ppdet.experimental import mixed_precision_global_state from ppdet.core.workspace import register __all__ = ['BlazeNet'] @@ -151,6 +152,7 @@ class BlazeNet(object): use_pool = not stride == 1 use_double_block = double_channels is not None act = 'relu' if use_double_block else None + mixed_precision_enabled = mixed_precision_global_state() is not None if use_5x5kernel: conv_dw = self._conv_norm( @@ -160,7 +162,7 @@ class BlazeNet(object): stride=stride, padding=2, num_groups=in_channels, - use_cudnn=False, + use_cudnn=mixed_precision_enabled, name=name + "1_dw") else: conv_dw_1 = self._conv_norm( @@ -170,7 +172,7 @@ class BlazeNet(object): stride=1, padding=1, num_groups=in_channels, - use_cudnn=False, + use_cudnn=mixed_precision_enabled, name=name + "1_dw_1") conv_dw = self._conv_norm( input=conv_dw_1, @@ -179,7 +181,7 @@ class BlazeNet(object): stride=stride, padding=1, num_groups=in_channels, - use_cudnn=False, + use_cudnn=mixed_precision_enabled, name=name + "1_dw_2") conv_pw = self._conv_norm( @@ -199,7 +201,7 @@ class BlazeNet(object): num_filters=out_channels, stride=1, padding=2, - use_cudnn=False, + use_cudnn=mixed_precision_enabled, name=name + "2_dw") else: conv_dw_1 = self._conv_norm( @@ -209,7 +211,7 @@ class BlazeNet(object): stride=1, padding=1, num_groups=out_channels, - use_cudnn=False, + use_cudnn=mixed_precision_enabled, name=name + "2_dw_1") conv_dw = self._conv_norm( input=conv_dw_1, @@ -218,7 +220,7 @@ class BlazeNet(object): stride=1, padding=1, num_groups=out_channels, - use_cudnn=False, + use_cudnn=mixed_precision_enabled, name=name + "2_dw_2") conv_pw = self._conv_norm( diff --git a/ppdet/modeling/backbones/mobilenet.py b/ppdet/modeling/backbones/mobilenet.py index 56afdf96454a994591a3d97e71b8d9619e0e68c8..e275fe1f15de3cbcff597fc4fac801e2b01e1c90 100644 --- a/ppdet/modeling/backbones/mobilenet.py +++ b/ppdet/modeling/backbones/mobilenet.py @@ -20,6 +20,7 @@ from paddle import fluid from paddle.fluid.param_attr import ParamAttr from paddle.fluid.regularizer import L2Decay +from ppdet.experimental import mixed_precision_global_state from ppdet.core.workspace import register __all__ = ['MobileNet'] @@ -104,6 +105,7 @@ class MobileNet(object): stride, scale, name=None): + mixed_precision_enabled = mixed_precision_global_state() is not None depthwise_conv = self._conv_norm( input=input, filter_size=3, @@ -111,7 +113,7 @@ class MobileNet(object): stride=stride, padding=1, num_groups=int(num_groups * scale), - use_cudnn=False, + use_cudnn=mixed_precision_enabled, name=name + "_dw") pointwise_conv = self._conv_norm(