parameters: (data, num_filter, stride, dim_match, name, bottle_neck=True, num_group=32, bn_mom=0.9, workspace=256, memonger=False)
docstring: Return ResNet Unit symbol for building ResNet
      Parameters
      ----------
      data : str
          Input data
      num_filter : int
          Number of output channels
      bnf : int
          Bottle neck channels factor with regard to num_filter
      stride : tupe
          Stride used in convolution
      dim_match : Boolen
          True means channel number between input and output is the same, otherwise means differ
      name : str
          Base name of the operators
      workspace : int
          Workspace used in convolution operator
docstring_summary: Return ResNet Unit symbol for building ResNet
      Parameters
      ----------
      data : str
          Input data
      num_filter : int
          Number of output channels
      bnf : int
          Bottle neck channels factor with regard to num_filter
      stride : tupe
          Stride used in convolution
      dim_match : Boolen
          True means channel number between input and output is the same, otherwise means differ
      name : str
          Base name of the operators
      workspace : int
          Workspace used in convolution operator
docstring_tokens: Return ResNet Unit symbol for building ResNet Parameters ---------- data : str Input data num_filter : int Number of output channels bnf : int Bottle neck channels factor with regard to num_filter stride : tupe Stride used in convolution dim_match : Boolen True means channel number between input and output is the same otherwise means differ name : str Base name of the operators workspace : int Workspace used in convolution operator
function: def Qresidual_unit(data, num_filter, stride, dim_match, name, bottle_neck=True, num_group=32, bn_mom=0.9, workspace=256, memonger=False):
      """Return ResNet Unit symbol for building ResNet
      Parameters
      ----------
      data : str
          Input data
      num_filter : int
          Number of output channels
      bnf : int
          Bottle neck channels factor with regard to num_filter
      stride : tupe
          Stride used in convolution
      dim_match : Boolen
          True means channel number between input and output is the same, otherwise means differ
      name : str
          Base name of the operators
      workspace : int
          Workspace used in convolution operator
      """
      cudnn_off = False
  
      if bottle_neck:
          # the same as https://github.com/facebook/fb.resnet.torch#notes, a bit difference with origin paper
          
          bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn1')
          act1 = mx.sym.QActivation(data=bn1, act_bit=BITA, backward_only=True)
          conv1 = mx.sym.QConvolution(data=act1, num_filter=int(num_filter*0.5), kernel=(1,1), stride=(1,1), pad=(0,0),
                                        no_bias=True, workspace=workspace, name=name + '_conv1', act_bit=BITA, weight_bit=BITW, cudnn_off=cudnn_off)     
  
          bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2')
          act2 = mx.sym.QActivation(data=bn2, act_bit=BITA, backward_only=True)
          conv2 = mx.sym.QConvolution(data=act2, num_filter=int(num_filter*0.5), num_group=num_group, kernel=(3,3), stride=stride, pad=(1,1),
                                        no_bias=True, workspace=workspace, name=name + '_conv2', act_bit=BITA, weight_bit=BITW, cudnn_off=cudnn_off)
          
          bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3')
          act3 = mx.sym.QActivation(data=bn3, act_bit=BITA, backward_only=True)     
          conv3 = mx.sym.QConvolution(data=act3, num_filter=num_filter, kernel=(1,1), stride=(1,1), pad=(0,0), no_bias=True,
                                     workspace=workspace, name=name + '_conv3', act_bit=BITA, weight_bit=BITW, cudnn_off=cudnn_off)
  
          bn4 = mx.sym.BatchNorm(data=conv3, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn4')
  
          if dim_match:
              shortcut = data
          else:
              shortcut_conv = mx.sym.QConvolution(data=act1, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True,
                                              workspace=workspace, name=name+'_sc', act_bit=BITA, weight_bit=BITW, cudnn_off=cudnn_off)
              shortcut = mx.sym.BatchNorm(data=shortcut_conv, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_sc_bn')
  
          if memonger:
              shortcut._set_attr(mirror_stage='True')
          eltwise =  bn4 + shortcut
          return mx.sym.Activation(data=eltwise, act_type='relu', name=name + '_relu')
      else:      
          bn1 = mx.sym.BatchNorm(data=data, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn1')
          act1 = mx.sym.QActivation(data=bn1, act_bit=BITA, backward_only=True)
          conv1 = mx.sym.QConvolution(data=act1, num_filter=num_filter, kernel=(3,3), stride=stride, pad=(1,1),
                                no_bias=True, workspace=workspace, name=name + '_conv1', act_bit=BITA, weight_bit=BITW, cudnn_off=cudnn_off)
  
          bn2 = mx.sym.BatchNorm(data=conv1, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn2')
          act2 = mx.sym.QActivation(data=bn2, act_bit=BITA, backward_only=True)        
          conv2 = mx.sym.QConvolution(data=act2, num_filter=num_filter, kernel=(3,3), stride=(1,1), pad=(1,1),
                                        no_bias=True, workspace=workspace, name=name + '_conv2', act_bit=BITA, weight_bit=BITW, cudnn_off=cudnn_off)
          
          bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, momentum=bn_mom, eps=2e-5, name=name + '_bn3')
  
          if dim_match:
              shortcut = data
          else:
              shortcut_conv = mx.sym.QConvolution(data=act1, num_filter=num_filter, kernel=(1,1), stride=stride, no_bias=True,
                                              workspace=workspace, name=name+'_sc', act_bit=BITA, weight_bit=BITW, cudnn_off=cudnn_off)
              shortcut = mx.sym.BatchNorm(data=shortcut_conv, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_sc_bn')
  
          if memonger:
              shortcut._set_attr(mirror_stage='True')
          eltwise = bn3 + shortcut
          return mx.sym.Activation(data=eltwise, act_type='relu', name=name + '_relu')
function_tokens: def Qresidual_unit ( data , num_filter , stride , dim_match , name , bottle_neck = True , num_group = 32 , bn_mom = 0.9 , workspace = 256 , memonger = False ) : cudnn_off = False if bottle_neck : # the same as https://github.com/facebook/fb.resnet.torch#notes, a bit difference with origin paper bn1 = mx . sym . BatchNorm ( data = data , fix_gamma = False , eps = 2e-5 , momentum = bn_mom , name = name + '_bn1' ) act1 = mx . sym . QActivation ( data = bn1 , act_bit = BITA , backward_only = True ) conv1 = mx . sym . QConvolution ( data = act1 , num_filter = int ( num_filter * 0.5 ) , kernel = ( 1 , 1 ) , stride = ( 1 , 1 ) , pad = ( 0 , 0 ) , no_bias = True , workspace = workspace , name = name + '_conv1' , act_bit = BITA , weight_bit = BITW , cudnn_off = cudnn_off ) bn2 = mx . sym . BatchNorm ( data = conv1 , fix_gamma = False , eps = 2e-5 , momentum = bn_mom , name = name + '_bn2' ) act2 = mx . sym . QActivation ( data = bn2 , act_bit = BITA , backward_only = True ) conv2 = mx . sym . QConvolution ( data = act2 , num_filter = int ( num_filter * 0.5 ) , num_group = num_group , kernel = ( 3 , 3 ) , stride = stride , pad = ( 1 , 1 ) , no_bias = True , workspace = workspace , name = name + '_conv2' , act_bit = BITA , weight_bit = BITW , cudnn_off = cudnn_off ) bn3 = mx . sym . BatchNorm ( data = conv2 , fix_gamma = False , eps = 2e-5 , momentum = bn_mom , name = name + '_bn3' ) act3 = mx . sym . QActivation ( data = bn3 , act_bit = BITA , backward_only = True ) conv3 = mx . sym . QConvolution ( data = act3 , num_filter = num_filter , kernel = ( 1 , 1 ) , stride = ( 1 , 1 ) , pad = ( 0 , 0 ) , no_bias = True , workspace = workspace , name = name + '_conv3' , act_bit = BITA , weight_bit = BITW , cudnn_off = cudnn_off ) bn4 = mx . sym . BatchNorm ( data = conv3 , fix_gamma = False , eps = 2e-5 , momentum = bn_mom , name = name + '_bn4' ) if dim_match : shortcut = data else : shortcut_conv = mx . sym . QConvolution ( data = act1 , num_filter = num_filter , kernel = ( 1 , 1 ) , stride = stride , no_bias = True , workspace = workspace , name = name + '_sc' , act_bit = BITA , weight_bit = BITW , cudnn_off = cudnn_off ) shortcut = mx . sym . BatchNorm ( data = shortcut_conv , fix_gamma = False , eps = 2e-5 , momentum = bn_mom , name = name + '_sc_bn' ) if memonger : shortcut . _set_attr ( mirror_stage = 'True' ) eltwise = bn4 + shortcut return mx . sym . Activation ( data = eltwise , act_type = 'relu' , name = name + '_relu' ) else : bn1 = mx . sym . BatchNorm ( data = data , fix_gamma = False , momentum = bn_mom , eps = 2e-5 , name = name + '_bn1' ) act1 = mx . sym . QActivation ( data = bn1 , act_bit = BITA , backward_only = True ) conv1 = mx . sym . QConvolution ( data = act1 , num_filter = num_filter , kernel = ( 3 , 3 ) , stride = stride , pad = ( 1 , 1 ) , no_bias = True , workspace = workspace , name = name + '_conv1' , act_bit = BITA , weight_bit = BITW , cudnn_off = cudnn_off ) bn2 = mx . sym . BatchNorm ( data = conv1 , fix_gamma = False , eps = 2e-5 , momentum = bn_mom , name = name + '_bn2' ) act2 = mx . sym . QActivation ( data = bn2 , act_bit = BITA , backward_only = True ) conv2 = mx . sym . QConvolution ( data = act2 , num_filter = num_filter , kernel = ( 3 , 3 ) , stride = ( 1 , 1 ) , pad = ( 1 , 1 ) , no_bias = True , workspace = workspace , name = name + '_conv2' , act_bit = BITA , weight_bit = BITW , cudnn_off = cudnn_off ) bn3 = mx . sym . BatchNorm ( data = conv2 , fix_gamma = False , momentum = bn_mom , eps = 2e-5 , name = name + '_bn3' ) if dim_match : shortcut = data else : shortcut_conv = mx . sym . QConvolution ( data = act1 , num_filter = num_filter , kernel = ( 1 , 1 ) , stride = stride , no_bias = True , workspace = workspace , name = name + '_sc' , act_bit = BITA , weight_bit = BITW , cudnn_off = cudnn_off ) shortcut = mx . sym . BatchNorm ( data = shortcut_conv , fix_gamma = False , eps = 2e-5 , momentum = bn_mom , name = name + '_sc_bn' ) if memonger : shortcut . _set_attr ( mirror_stage = 'True' ) eltwise = bn3 + shortcut return mx . sym . Activation ( data = eltwise , act_type = 'relu' , name = name + '_relu' )