From f0431607e91331585291fd9cf7d6dd5d78b00761 Mon Sep 17 00:00:00 2001 From: songyouwei Date: Wed, 22 Jan 2020 11:34:49 +0800 Subject: [PATCH] cherry-pick #22373 (#22388) test=release/1.7, test=develop --- python/paddle/fluid/dygraph/nn.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/python/paddle/fluid/dygraph/nn.py b/python/paddle/fluid/dygraph/nn.py index 5c99900465..b45edb545e 100644 --- a/python/paddle/fluid/dygraph/nn.py +++ b/python/paddle/fluid/dygraph/nn.py @@ -182,14 +182,11 @@ class Conv2D(layers.Layer): self._bias_attr = bias_attr self._dtype = dtype - # TODO: recover the usage of depthwise_conv2d when it's - # kernel fixed https://github.com/PaddlePaddle/Paddle/issues/17098 - # if (self._num_channels == self._groups and - # num_filters % self._num_channels == 0 and not self._use_cudnn): - # self._l_type = 'depthwise_conv2d' - # else: - # self._l_type = 'conv2d' - self._l_type = 'conv2d' + if (self._num_channels == self._groups and + num_filters % self._num_channels == 0 and not self._use_cudnn): + self._l_type = 'depthwise_conv2d' + else: + self._l_type = 'conv2d' self._num_channels = num_channels if self._groups is None: @@ -233,7 +230,7 @@ class Conv2D(layers.Layer): 'use_mkldnn': False, } - if in_dygraph_mode(): + if in_dygraph_mode() and self._l_type == 'conv2d': outs = core.ops.conv2d(inputs, attrs) pre_bias = outs['Output'][0] -- GitLab