parameters: (input,
             num_filters,
             filter_size,
             stride=1,
             padding=0,
             dilation=1,
             groups=None,
             param_attr=None,
             bias_attr=None,
             use_cudnn=True,
             act=None,
             name=None,
             data_format="NCHW")
return_statement: return helper.append_activation(pre_act)
docstring: r"""
      :api_attr: Static Graph
  
      The convolution2D layer calculates the output based on the input, filter
      and strides, paddings, dilations, groups parameters. Input and
      Output are in NCHW or NHWC format, where N is batch size, C is the number of
      channels, H is the height of the feature, and W is the width of the feature.
      Filter is in MCHW format, where M is the number of output image channels,
      C is the number of input image channels, H is the height of the filter,
      and W is the width of the filter. If the groups is greater than 1,
      C will equal the number of input image channels divided by the groups.
      Please refer to UFLDL's `convolution
      <http://ufldl.stanford.edu/tutorial/supervised/FeatureExtractionUsingConvolution/>`_
      for more details.
      If bias attribution and activation type are provided, bias is added to the
      output of the convolution, and the corresponding activation function is
      applied to the final result.
  
      For each input :math:`X`, the equation is:
  
      .. math::
  
          Out = \sigma (W \\ast X + b)
  
      Where:
  
      * :math:`X`: Input value, a tensor with NCHW or NHWC format.
      * :math:`W`: Filter value, a tensor with MCHW format.
      * :math:`\\ast`: Convolution operation.
      * :math:`b`: Bias value, a 2-D tensor with shape [M, 1].
      * :math:`\\sigma`: Activation function.
      * :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be different.
  
      Example:
  
          - Input:
  
            Input shape: :math:`(N, C_{in}, H_{in}, W_{in})`
  
            Filter shape: :math:`(C_{out}, C_{in}, H_f, W_f)`
  
          - Output:
  
            Output shape: :math:`(N, C_{out}, H_{out}, W_{out})`
  
          Where
  
          .. math::
  
              H_{out}&= \\frac{(H_{in} + 2 * paddings[0] - (dilations[0] * (H_f - 1) + 1))}{strides[0]} + 1 \\\\
              W_{out}&= \\frac{(W_{in} + 2 * paddings[1] - (dilations[1] * (W_f - 1) + 1))}{strides[1]} + 1
  
      Args:
          input (Tensor): The input is 4-D Tensor with shape [N, C, H, W], the data type
              of input is float16 or float32 or float64.
          num_filters(int): The number of filter. It is as same as the output
              image channel.
          filter_size (int|tuple): The filter size. If filter_size
              is a tuple, it must contain two integers, (filter_size_height,
              filter_size_width). Otherwise, filter_size_height = filter_size_width =\
              filter_size.
          stride (int|tuple): The stride size. It means the stride in convolution.
              If stride is a tuple, it must contain two integers, (stride_height, stride_width).
              Otherwise, stride_height = stride_width = stride. Default: stride = 1.
          padding (string|int|list|tuple): The padding size. It means the number of zero-paddings
              on both sides for each dimension.If `padding` is a string, either 'VALID' or
              'SAME' which is the padding algorithm. If padding size is a tuple or list,
              it could be in three forms: `[pad_height, pad_width]` or
              `[pad_height_top, pad_height_bottom, pad_width_left, pad_width_right]`, and when
              `data_format` is `"NCHW"`, `padding` can be in the form `[[0,0], [0,0],
              [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right]]`.
              when `data_format` is `"NHWC"`, `pool_padding` can be in the form
              `[[0,0], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right], [0,0]]`.
              Default: padding = 0.
          dilation (int|tuple): The dilation size. It means the spacing between the kernel
              points. If dilation is a tuple, it must contain two integers, (dilation_height,
              dilation_width). Otherwise, dilation_height = dilation_width = dilation.
              Default: dilation = 1.
          groups (int): The groups number of the Conv2d Layer. According to grouped
              convolution in Alex Krizhevsky's Deep CNN paper: when group=2,
              the first half of the filters is only connected to the first half
              of the input channels, while the second half of the filters is only
              connected to the second half of the input channels. Default: groups=1.
          param_attr (ParamAttr|None): The parameter attribute for learnable parameters/weights
              of conv2d. If it is set to None or one attribute of ParamAttr, conv2d
              will create ParamAttr as param_attr. If the Initializer of the param_attr
              is not set, the parameter is initialized with :math:`Normal(0.0, std)`,
              and the :math:`std` is :math:`(\\frac{2.0 }{filter\_elem\_num})^{0.5}`. Default: None.
          bias_attr (ParamAttr|bool|None): The parameter attribute for the bias of conv2d.
              If it is set to False, no bias will be added to the output units.
              If it is set to None or one attribute of ParamAttr, conv2d
              will create ParamAttr as bias_attr. If the Initializer of the bias_attr
              is not set, the bias is initialized zero. Default: None.
          use_cudnn (bool): Use cudnn kernel or not, it is valid only when the cudnn
              library is installed. Default: True
          act (str): Activation type, if it is set to None, activation is not appended.
              Default: None
          name(str|None): For detailed information, please refer
             to :ref:`api_guide_Name`. Usually name is no need to set and
             None by default.
          data_format (str, optional): Specify the data format of the input, and the data format of the output
              will be consistent with that of the input. An optional string from: `"NCHW"`, `"NHWC"`.
              The default is `"NCHW"`. When it is `"NCHW"`, the data is stored in the order of:
              `[batch_size, input_channels, input_height, input_width]`.
  
      Returns:
          A Tensor representing the conv2d, whose data type is the
          same with input. If act is None, the tensor storing the convolution
          result, and if act is not None, the tensor storing convolution
          and non-linearity activation result.
  
      Raises:
          ValueError: If the type of `use_cudnn` is not bool.
          ValueError: If `data_format` is not "NCHW" or "NHWC".
          ValueError: If the channel dimmention of the input is less than or equal to zero.
          ValueError: If `padding` is a string, but not "SAME" or "VALID".
          ValueError: If `padding` is a tuple, but the element corresponding to the input's batch size is not 0
              or the element corresponding to the input's channel is not 0.
          ShapeError: If the input is not 4-D Tensor.
          ShapeError: If the input's dimension size and filter's dimension size not equal.
          ShapeError: If the dimension size of input minus the size of `stride` is not 2.
          ShapeError: If the number of input channels is not equal to filter's channels * groups.
          ShapeError: If the number of output channels is not be divided by groups.
  
      Examples:
          .. code-block:: python
  
            import paddle
            paddle.enable_static()
            
            data = paddle.static.data(name='data', shape=[None, 3, 32, 32], dtype='float32')
            conv2d = paddle.static.nn.conv2d(input=data, num_filters=2, filter_size=3, act="relu")
            print(conv2d.shape) # [-1, 2, 30, 30]
docstring_summary: r"""
      :api_attr: Static Graph
docstring_tokens: r : api_attr : Static Graph
function: def conv2d(input,
             num_filters,
             filter_size,
             stride=1,
             padding=0,
             dilation=1,
             groups=None,
             param_attr=None,
             bias_attr=None,
             use_cudnn=True,
             act=None,
             name=None,
             data_format="NCHW"):
      r"""
      :api_attr: Static Graph
  
      The convolution2D layer calculates the output based on the input, filter
      and strides, paddings, dilations, groups parameters. Input and
      Output are in NCHW or NHWC format, where N is batch size, C is the number of
      channels, H is the height of the feature, and W is the width of the feature.
      Filter is in MCHW format, where M is the number of output image channels,
      C is the number of input image channels, H is the height of the filter,
      and W is the width of the filter. If the groups is greater than 1,
      C will equal the number of input image channels divided by the groups.
      Please refer to UFLDL's `convolution
      <http://ufldl.stanford.edu/tutorial/supervised/FeatureExtractionUsingConvolution/>`_
      for more details.
      If bias attribution and activation type are provided, bias is added to the
      output of the convolution, and the corresponding activation function is
      applied to the final result.
  
      For each input :math:`X`, the equation is:
  
      .. math::
  
          Out = \sigma (W \\ast X + b)
  
      Where:
  
      * :math:`X`: Input value, a tensor with NCHW or NHWC format.
      * :math:`W`: Filter value, a tensor with MCHW format.
      * :math:`\\ast`: Convolution operation.
      * :math:`b`: Bias value, a 2-D tensor with shape [M, 1].
      * :math:`\\sigma`: Activation function.
      * :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be different.
  
      Example:
  
          - Input:
  
            Input shape: :math:`(N, C_{in}, H_{in}, W_{in})`
  
            Filter shape: :math:`(C_{out}, C_{in}, H_f, W_f)`
  
          - Output:
  
            Output shape: :math:`(N, C_{out}, H_{out}, W_{out})`
  
          Where
  
          .. math::
  
              H_{out}&= \\frac{(H_{in} + 2 * paddings[0] - (dilations[0] * (H_f - 1) + 1))}{strides[0]} + 1 \\\\
              W_{out}&= \\frac{(W_{in} + 2 * paddings[1] - (dilations[1] * (W_f - 1) + 1))}{strides[1]} + 1
  
      Args:
          input (Tensor): The input is 4-D Tensor with shape [N, C, H, W], the data type
              of input is float16 or float32 or float64.
          num_filters(int): The number of filter. It is as same as the output
              image channel.
          filter_size (int|tuple): The filter size. If filter_size
              is a tuple, it must contain two integers, (filter_size_height,
              filter_size_width). Otherwise, filter_size_height = filter_size_width =\
              filter_size.
          stride (int|tuple): The stride size. It means the stride in convolution.
              If stride is a tuple, it must contain two integers, (stride_height, stride_width).
              Otherwise, stride_height = stride_width = stride. Default: stride = 1.
          padding (string|int|list|tuple): The padding size. It means the number of zero-paddings
              on both sides for each dimension.If `padding` is a string, either 'VALID' or
              'SAME' which is the padding algorithm. If padding size is a tuple or list,
              it could be in three forms: `[pad_height, pad_width]` or
              `[pad_height_top, pad_height_bottom, pad_width_left, pad_width_right]`, and when
              `data_format` is `"NCHW"`, `padding` can be in the form `[[0,0], [0,0],
              [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right]]`.
              when `data_format` is `"NHWC"`, `pool_padding` can be in the form
              `[[0,0], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right], [0,0]]`.
              Default: padding = 0.
          dilation (int|tuple): The dilation size. It means the spacing between the kernel
              points. If dilation is a tuple, it must contain two integers, (dilation_height,
              dilation_width). Otherwise, dilation_height = dilation_width = dilation.
              Default: dilation = 1.
          groups (int): The groups number of the Conv2d Layer. According to grouped
              convolution in Alex Krizhevsky's Deep CNN paper: when group=2,
              the first half of the filters is only connected to the first half
              of the input channels, while the second half of the filters is only
              connected to the second half of the input channels. Default: groups=1.
          param_attr (ParamAttr|None): The parameter attribute for learnable parameters/weights
              of conv2d. If it is set to None or one attribute of ParamAttr, conv2d
              will create ParamAttr as param_attr. If the Initializer of the param_attr
              is not set, the parameter is initialized with :math:`Normal(0.0, std)`,
              and the :math:`std` is :math:`(\\frac{2.0 }{filter\_elem\_num})^{0.5}`. Default: None.
          bias_attr (ParamAttr|bool|None): The parameter attribute for the bias of conv2d.
              If it is set to False, no bias will be added to the output units.
              If it is set to None or one attribute of ParamAttr, conv2d
              will create ParamAttr as bias_attr. If the Initializer of the bias_attr
              is not set, the bias is initialized zero. Default: None.
          use_cudnn (bool): Use cudnn kernel or not, it is valid only when the cudnn
              library is installed. Default: True
          act (str): Activation type, if it is set to None, activation is not appended.
              Default: None
          name(str|None): For detailed information, please refer
             to :ref:`api_guide_Name`. Usually name is no need to set and
             None by default.
          data_format (str, optional): Specify the data format of the input, and the data format of the output
              will be consistent with that of the input. An optional string from: `"NCHW"`, `"NHWC"`.
              The default is `"NCHW"`. When it is `"NCHW"`, the data is stored in the order of:
              `[batch_size, input_channels, input_height, input_width]`.
  
      Returns:
          A Tensor representing the conv2d, whose data type is the
          same with input. If act is None, the tensor storing the convolution
          result, and if act is not None, the tensor storing convolution
          and non-linearity activation result.
  
      Raises:
          ValueError: If the type of `use_cudnn` is not bool.
          ValueError: If `data_format` is not "NCHW" or "NHWC".
          ValueError: If the channel dimmention of the input is less than or equal to zero.
          ValueError: If `padding` is a string, but not "SAME" or "VALID".
          ValueError: If `padding` is a tuple, but the element corresponding to the input's batch size is not 0
              or the element corresponding to the input's channel is not 0.
          ShapeError: If the input is not 4-D Tensor.
          ShapeError: If the input's dimension size and filter's dimension size not equal.
          ShapeError: If the dimension size of input minus the size of `stride` is not 2.
          ShapeError: If the number of input channels is not equal to filter's channels * groups.
          ShapeError: If the number of output channels is not be divided by groups.
  
      Examples:
          .. code-block:: python
  
            import paddle
            paddle.enable_static()
            
            data = paddle.static.data(name='data', shape=[None, 3, 32, 32], dtype='float32')
            conv2d = paddle.static.nn.conv2d(input=data, num_filters=2, filter_size=3, act="relu")
            print(conv2d.shape) # [-1, 2, 30, 30]
      """
  
      check_variable_and_dtype(input, 'input', ['float16', 'float32', 'float64'],
                               'conv2d')
      if len(input.shape) != 4:
          raise ValueError("Input size should be 4, "
                           "but received {}".format(len(input.shape)))
      num_channels = input.shape[1]
      if not isinstance(use_cudnn, bool):
          raise ValueError("Attr(use_cudnn) should be True or False. Received "
                           "Attr(use_cudnn): %s. " % str(use_cudnn))
  
      if data_format not in ["NCHW", "NHWC"]:
          raise ValueError(
              "Attr(data_format) should be 'NCHW' or 'NHWC'. Received "
              "Attr(data_format): %s." % str(data_format))
  
      channel_last = (data_format == "NHWC")
      num_channels = input.shape[3] if channel_last else input.shape[1]
      if num_channels < 0:
          raise ValueError(
              "The channel dimmention of the input(%s) should be defined. "
              "Received: %s." % (str(input.shape), str(num_channels)))
      assert param_attr is not False, "param_attr should not be False here."
  
      if groups is None:
          num_filter_channels = num_channels
      elif groups <= 0:
          raise ValueError("the groups of input must be greater than 0, "
                           "but received the groups of input is {}".format(
                               groups))
      else:
          if num_channels % groups != 0:
              raise ValueError(
                  "the channel of input must be divisible by groups,"
                  "received: the channel of input is {}, the shape of input is {}"
                  ", the groups is {}".format(num_channels, input.shape, groups))
          num_filter_channels = num_channels // groups
  
      l_type = 'conv2d'
      if (num_channels == groups and num_filters % num_channels == 0 and
              not use_cudnn):
          l_type = 'depthwise_conv2d'
  
      if (num_channels == groups and num_filters % num_channels == 0 and
              core.is_compiled_with_rocm()):
          l_type = 'depthwise_conv2d'
  
      # NPU only supports depthwise_conv2d when  "input_channel = output_channel = groups"
      if core.is_compiled_with_npu():
          if (num_channels == groups and num_channels == num_filters):
              l_type = 'depthwise_conv2d'
          else:
              l_type = 'conv2d'
  
      helper = LayerHelper(l_type, **locals())
      dtype = helper.input_dtype()
  
      filter_size = utils.convert_to_list(filter_size, 2, 'filter_size')
      stride = utils.convert_to_list(stride, 2, 'stride')
      dilation = utils.convert_to_list(dilation, 2, 'dilation')
  
      # padding
      def _update_padding(padding, data_format):
          def is_list_or_tuple(ele):
              if isinstance(ele, list) or isinstance(ele, tuple):
                  return True
              return False
  
          if is_list_or_tuple(padding) and len(padding) == 4:
              if is_list_or_tuple(padding[0]) and (data_format == "NCHW"):
                  if not (padding[0] == [0, 0] and padding[1] == [0, 0]):
                      raise ValueError(
                          "Non-zero padding(%s) in the batch or channel dimensions "
                          "is not supported." % str(padding))
                  padding = padding[2:4]
                  padding = [ele for a_list in padding for ele in a_list]
              elif is_list_or_tuple(padding[0]) and (data_format == "NHWC"):
                  if not (padding[0] == [0, 0] and padding[3] == [0, 0]):
                      raise ValueError(
                          "Non-zero padding(%s) in the batch or channel dimensions "
                          "is not supported." % str(padding))
                  padding = padding[1:3]
                  padding = [ele for a_list in padding for ele in a_list]
              padding = utils.convert_to_list(padding, 4, 'padding')
              if utils._is_symmetric_padding(padding, 2):
                  padding = [padding[0], padding[2]]
  
          else:
              padding = utils.convert_to_list(padding, 2, 'padding')
  
          return padding
  
      padding_algorithm = "EXPLICIT"
      if isinstance(padding, str):
          padding = padding.upper()
          if padding not in ["SAME", "VALID"]:
              raise ValueError(
                  "Unknown padding: '%s'. It can only be 'SAME' or 'VALID'." %
                  str(padding))
          if padding == "VALID":
              padding_algorithm = "VALID"
              padding = [0, 0]
          elif padding == "SAME":
              padding_algorithm = "SAME"
              padding = [0, 0]
  
      padding = _update_padding(padding, data_format)
  
      filter_shape = [num_filters, int(num_filter_channels)] + filter_size
  
      def _get_default_param_initializer():
          filter_elem_num = filter_size[0] * filter_size[1] * num_channels
          if filter_elem_num <= 0:
              raise ValueError(
                  "Invalid filter number, excepted number is larger than 0, but"
                  " received {}, please check the input shape and "
                  "filter size.".format(filter_elem_num))
          std = (2.0 / filter_elem_num)**0.5
          return Normal(0.0, std, 0)
  
      filter_param = helper.create_parameter(
          attr=helper.param_attr,
          shape=filter_shape,
          dtype=dtype,
          default_initializer=_get_default_param_initializer())
  
      pre_bias = helper.create_variable_for_type_inference(dtype)
  
      if (core.is_compiled_with_cuda() and paddle.fluid.get_flags(
              "FLAGS_conv2d_disable_cudnn")["FLAGS_conv2d_disable_cudnn"]):
          use_cudnn = False
  
      helper.append_op(
          type=l_type,
          inputs={
              'Input': input,
              'Filter': filter_param,
          },
          outputs={"Output": pre_bias},
          attrs={
              'strides': stride,
              'paddings': padding,
              'dilations': dilation,
              'groups': groups,
              'use_cudnn': use_cudnn,
              'use_mkldnn': False,
              'fuse_relu_before_depthwise_conv': False,
              "padding_algorithm": padding_algorithm,
              "data_format": data_format,
          })
  
      if data_format == 'NCHW':
          pre_act = helper.append_bias_op(pre_bias, dim_start=1, dim_end=2)
      else:
          pre_act = helper.append_bias_op(pre_bias, dim_start=3, dim_end=4)
  
      return helper.append_activation(pre_act)
function_tokens: def conv2d ( input , num_filters , filter_size , stride = 1 , padding = 0 , dilation = 1 , groups = None , param_attr = None , bias_attr = None , use_cudnn = True , act = None , name = None , data_format = "NCHW" ) : check_variable_and_dtype ( input , 'input' , [ 'float16' , 'float32' , 'float64' ] , 'conv2d' ) if len ( input . shape ) != 4 : raise ValueError ( "Input size should be 4, " "but received {}" . format ( len ( input . shape ) ) ) num_channels = input . shape [ 1 ] if not isinstance ( use_cudnn , bool ) : raise ValueError ( "Attr(use_cudnn) should be True or False. Received " "Attr(use_cudnn): %s. " % str ( use_cudnn ) ) if data_format not in [ "NCHW" , "NHWC" ] : raise ValueError ( "Attr(data_format) should be 'NCHW' or 'NHWC'. Received " "Attr(data_format): %s." % str ( data_format ) ) channel_last = ( data_format == "NHWC" ) num_channels = input . shape [ 3 ] if channel_last else input . shape [ 1 ] if num_channels < 0 : raise ValueError ( "The channel dimmention of the input(%s) should be defined. " "Received: %s." % ( str ( input . shape ) , str ( num_channels ) ) ) assert param_attr is not False , "param_attr should not be False here." if groups is None : num_filter_channels = num_channels elif groups <= 0 : raise ValueError ( "the groups of input must be greater than 0, " "but received the groups of input is {}" . format ( groups ) ) else : if num_channels % groups != 0 : raise ValueError ( "the channel of input must be divisible by groups," "received: the channel of input is {}, the shape of input is {}" ", the groups is {}" . format ( num_channels , input . shape , groups ) ) num_filter_channels = num_channels // groups l_type = 'conv2d' if ( num_channels == groups and num_filters % num_channels == 0 and not use_cudnn ) : l_type = 'depthwise_conv2d' if ( num_channels == groups and num_filters % num_channels == 0 and core . is_compiled_with_rocm ( ) ) : l_type = 'depthwise_conv2d' # NPU only supports depthwise_conv2d when  "input_channel = output_channel = groups" if core . is_compiled_with_npu ( ) : if ( num_channels == groups and num_channels == num_filters ) : l_type = 'depthwise_conv2d' else : l_type = 'conv2d' helper = LayerHelper ( l_type , * * locals ( ) ) dtype = helper . input_dtype ( ) filter_size = utils . convert_to_list ( filter_size , 2 , 'filter_size' ) stride = utils . convert_to_list ( stride , 2 , 'stride' ) dilation = utils . convert_to_list ( dilation , 2 , 'dilation' ) # padding def _update_padding ( padding , data_format ) : def is_list_or_tuple ( ele ) : if isinstance ( ele , list ) or isinstance ( ele , tuple ) : return True return False if is_list_or_tuple ( padding ) and len ( padding ) == 4 : if is_list_or_tuple ( padding [ 0 ] ) and ( data_format == "NCHW" ) : if not ( padding [ 0 ] == [ 0 , 0 ] and padding [ 1 ] == [ 0 , 0 ] ) : raise ValueError ( "Non-zero padding(%s) in the batch or channel dimensions " "is not supported." % str ( padding ) ) padding = padding [ 2 : 4 ] padding = [ ele for a_list in padding for ele in a_list ] elif is_list_or_tuple ( padding [ 0 ] ) and ( data_format == "NHWC" ) : if not ( padding [ 0 ] == [ 0 , 0 ] and padding [ 3 ] == [ 0 , 0 ] ) : raise ValueError ( "Non-zero padding(%s) in the batch or channel dimensions " "is not supported." % str ( padding ) ) padding = padding [ 1 : 3 ] padding = [ ele for a_list in padding for ele in a_list ] padding = utils . convert_to_list ( padding , 4 , 'padding' ) if utils . _is_symmetric_padding ( padding , 2 ) : padding = [ padding [ 0 ] , padding [ 2 ] ] else : padding = utils . convert_to_list ( padding , 2 , 'padding' ) return padding padding_algorithm = "EXPLICIT" if isinstance ( padding , str ) : padding = padding . upper ( ) if padding not in [ "SAME" , "VALID" ] : raise ValueError ( "Unknown padding: '%s'. It can only be 'SAME' or 'VALID'." % str ( padding ) ) if padding == "VALID" : padding_algorithm = "VALID" padding = [ 0 , 0 ] elif padding == "SAME" : padding_algorithm = "SAME" padding = [ 0 , 0 ] padding = _update_padding ( padding , data_format ) filter_shape = [ num_filters , int ( num_filter_channels ) ] + filter_size def _get_default_param_initializer ( ) : filter_elem_num = filter_size [ 0 ] * filter_size [ 1 ] * num_channels if filter_elem_num <= 0 : raise ValueError ( "Invalid filter number, excepted number is larger than 0, but" " received {}, please check the input shape and " "filter size." . format ( filter_elem_num ) ) std = ( 2.0 / filter_elem_num ) ** 0.5 return Normal ( 0.0 , std , 0 ) filter_param = helper . create_parameter ( attr = helper . param_attr , shape = filter_shape , dtype = dtype , default_initializer = _get_default_param_initializer ( ) ) pre_bias = helper . create_variable_for_type_inference ( dtype ) if ( core . is_compiled_with_cuda ( ) and paddle . fluid . get_flags ( "FLAGS_conv2d_disable_cudnn" ) [ "FLAGS_conv2d_disable_cudnn" ] ) : use_cudnn = False helper . append_op ( type = l_type , inputs = { 'Input' : input , 'Filter' : filter_param , } , outputs = { "Output" : pre_bias } , attrs = { 'strides' : stride , 'paddings' : padding , 'dilations' : dilation , 'groups' : groups , 'use_cudnn' : use_cudnn , 'use_mkldnn' : False , 'fuse_relu_before_depthwise_conv' : False , "padding_algorithm" : padding_algorithm , "data_format" : data_format , } ) if data_format == 'NCHW' : pre_act = helper . append_bias_op ( pre_bias , dim_start = 1 , dim_end = 2 ) else : pre_act = helper . append_bias_op ( pre_bias , dim_start = 3 , dim_end = 4 ) return helper . append_activation ( pre_act )