diff --git a/fluid/object_detection/eval.py b/fluid/object_detection/eval.py index 4a2f2ab09d..403d7b2683 100644 --- a/fluid/object_detection/eval.py +++ b/fluid/object_detection/eval.py @@ -29,7 +29,6 @@ add_arg('mean_value_B', float, 127.5, "Mean value for B channel which will be subtracted.") #123.68 add_arg('mean_value_G', float, 127.5, "Mean value for G channel which will be subtracted.") #116.78 add_arg('mean_value_R', float, 127.5, "Mean value for R channel which will be subtracted.") #103.94 -parser.add_argument('--use_mkldnn', action='store_true', help='If set, use MKL-DNN library.') parser.add_argument('--profile', action='store_true', help='If set, do profiling.') # yapf: enable @@ -52,8 +51,7 @@ def eval(args, data_args, test_list): use_cudnn = True if args.use_gpu else False locs, confs, box, box_var = mobile_net(num_classes, image, image_shape, - use_cudnn=use_cudnn, - use_mkldnn=args.use_mkldnn) + use_cudnn=use_cudnn) nmsed_out = fluid.layers.detection_output( locs, confs, box, box_var, nms_threshold=args.nms_threshold) loss = fluid.layers.ssd_loss(locs, confs, gt_box, gt_label, box, box_var) diff --git a/fluid/object_detection/mobilenet_ssd.py b/fluid/object_detection/mobilenet_ssd.py index 0b09ec48c0..bdf0b8e733 100644 --- a/fluid/object_detection/mobilenet_ssd.py +++ b/fluid/object_detection/mobilenet_ssd.py @@ -12,8 +12,7 @@ def conv_bn(input, channels=None, num_groups=1, act='relu', - use_cudnn=True, - use_mkldnn=False): + use_cudnn=True): parameter_attr = ParamAttr(learning_rate=0.1, initializer=MSRA()) conv = fluid.layers.conv2d( input=input, @@ -24,16 +23,15 @@ def conv_bn(input, groups=num_groups, act=None, use_cudnn=use_cudnn, - use_mkldnn=use_mkldnn, param_attr=parameter_attr, bias_attr=False) parameter_attr = ParamAttr(learning_rate=0.1, initializer=MSRA()) bias_attr = ParamAttr(learning_rate=0.2) - return fluid.layers.batch_norm(input=conv, act=act, use_mkldnn=use_mkldnn) + return fluid.layers.batch_norm(input=conv, act=act) def depthwise_separable(input, num_filters1, num_filters2, num_groups, stride, - scale, use_cudnn=True, use_mkldnn=False): + scale, use_cudnn=True): depthwise_conv = conv_bn( input=input, filter_size=3, @@ -41,9 +39,7 @@ def depthwise_separable(input, num_filters1, num_filters2, num_groups, stride, stride=stride, padding=1, num_groups=int(num_groups * scale), - use_cudnn=use_cudnn, - # to be instrumented when depthwise conv2d op will handle use_mkldnn - use_mkldnn=False) + use_cudnn=use_cudnn) pointwise_conv = conv_bn( input=depthwise_conv, @@ -51,13 +47,12 @@ def depthwise_separable(input, num_filters1, num_filters2, num_groups, stride, num_filters=int(num_filters2 * scale), stride=1, padding=0, - use_cudnn=use_cudnn, - use_mkldnn=use_mkldnn) + use_cudnn=use_cudnn) return pointwise_conv def extra_block(input, num_filters1, num_filters2, num_groups, stride, scale, - use_cudnn=True, use_mkldnn=False): + use_cudnn=True): # 1x1 conv pointwise_conv = conv_bn( input=input, @@ -66,8 +61,7 @@ def extra_block(input, num_filters1, num_filters2, num_groups, stride, scale, stride=1, num_groups=int(num_groups * scale), padding=0, - use_cudnn=use_cudnn, - use_mkldnn=use_mkldnn) + use_cudnn=use_cudnn) # 3x3 conv normal_conv = conv_bn( @@ -77,54 +71,49 @@ def extra_block(input, num_filters1, num_filters2, num_groups, stride, scale, stride=2, num_groups=int(num_groups * scale), padding=1, - use_cudnn=use_cudnn, - use_mkldnn=use_mkldnn) + use_cudnn=use_cudnn) return normal_conv -def mobile_net(num_classes, img, img_shape, scale=1.0, use_cudnn=True, - use_mkldnn=False): +def mobile_net(num_classes, img, img_shape, scale=1.0, use_cudnn=True): # 300x300 - tmp = conv_bn(img, 3, int(32 * scale), 2, 1, 3, use_cudnn=use_cudnn, - use_mkldnn=use_mkldnn) + tmp = conv_bn(img, 3, int(32 * scale), 2, 1, 3, use_cudnn=use_cudnn) # 150x150 - tmp = depthwise_separable(tmp, 32, 64, 32, 1, scale, use_cudnn=use_cudnn, - use_mkldnn=use_mkldnn) - tmp = depthwise_separable(tmp, 64, 128, 64, 2, scale, use_cudnn=use_cudnn, - use_mkldnn=use_mkldnn) + tmp = depthwise_separable(tmp, 32, 64, 32, 1, scale, use_cudnn=use_cudnn) + tmp = depthwise_separable(tmp, 64, 128, 64, 2, scale, use_cudnn=use_cudnn) # 75x75 tmp = depthwise_separable(tmp, 128, 128, 128, 1, scale, - use_cudnn=use_cudnn, use_mkldnn=use_mkldnn) + use_cudnn=use_cudnn) tmp = depthwise_separable(tmp, 128, 256, 128, 2, scale, - use_cudnn=use_cudnn, use_mkldnn=use_mkldnn) + use_cudnn=use_cudnn) # 38x38 tmp = depthwise_separable(tmp, 256, 256, 256, 1, scale, - use_cudnn=use_cudnn, use_mkldnn=use_mkldnn) + use_cudnn=use_cudnn) tmp = depthwise_separable(tmp, 256, 512, 256, 2, scale, - use_cudnn=use_cudnn, use_mkldnn=use_mkldnn) + use_cudnn=use_cudnn) # 19x19 for i in range(5): tmp = depthwise_separable(tmp, 512, 512, 512, 1, scale, - use_cudnn=use_cudnn, use_mkldnn=use_mkldnn) + use_cudnn=use_cudnn) module11 = tmp tmp = depthwise_separable(tmp, 512, 1024, 512, 2, scale, - use_cudnn=use_cudnn, use_mkldnn=use_mkldnn) + use_cudnn=use_cudnn) # 10x10 module13 = depthwise_separable(tmp, 1024, 1024, 1024, 1, scale, - use_cudnn=use_cudnn, use_mkldnn=use_mkldnn) + use_cudnn=use_cudnn) module14 = extra_block(module13, 256, 512, 1, 2, scale, - use_cudnn=use_cudnn, use_mkldnn=use_mkldnn) + use_cudnn=use_cudnn) # 5x5 module15 = extra_block(module14, 128, 256, 1, 2, scale, - use_cudnn=use_cudnn, use_mkldnn=use_mkldnn) + use_cudnn=use_cudnn) # 3x3 module16 = extra_block(module15, 128, 256, 1, 2, scale, - use_cudnn=use_cudnn, use_mkldnn=use_mkldnn) + use_cudnn=use_cudnn) # 2x2 module17 = extra_block(module16, 64, 128, 1, 2, scale, - use_cudnn=use_cudnn, use_mkldnn=use_mkldnn) + use_cudnn=use_cudnn) mbox_locs, mbox_confs, box, box_var = fluid.layers.multi_box_head( inputs=[module11, module13, module14, module15, module16, module17], diff --git a/fluid/object_detection/train.py b/fluid/object_detection/train.py index 478fa33e39..97fa0fe58c 100644 --- a/fluid/object_detection/train.py +++ b/fluid/object_detection/train.py @@ -33,7 +33,6 @@ add_arg('mean_value_G', float, 127.5, "Mean value for G channel which will be subtracted.") #116.78 add_arg('mean_value_R', float, 127.5, "Mean value for R channel which will be subtracted.") #103.94 add_arg('is_toy', int, 0, "Toy for quick debug, 0 means using all data, while n means using only n sample.") -parser.add_argument('--use_mkldnn', action='store_true', help='If set, use MKL-DNN library.') parser.add_argument('--test', action='store_true', help='If set, test the model.') #yapf: enable @@ -67,7 +66,6 @@ def train(args, use_cudnn = True if args.use_gpu else False locs, confs, box, box_var = mobile_net(num_classes, image, image_shape, - use_mkldnn=args.use_mkldnn, use_cudnn=use_cudnn) nmsed_out = fluid.layers.detection_output( locs, confs, box, box_var, nms_threshold=args.nms_threshold)