parameters: (model, quantize_info)
return_statement: return adjusted_quantize_info
docstring: Adjust the shift bias of layer.
  
    shift_bias = wp + ip - bp
  
    DPU compiler constraints of shift_bias:
      1. min(0, -(24 - (8 + shift_cut))) <= shfit_bias <= 16, while shift_cut = wp + ip - op
docstring_summary: Adjust the shift bias of layer.
docstring_tokens: Adjust the shift bias of layer .
function: def _adjust_shift_bias(model, quantize_info):
    """Adjust the shift bias of layer.
  
    shift_bias = wp + ip - bp
  
    DPU compiler constraints of shift_bias:
      1. min(0, -(24 - (8 + shift_cut))) <= shfit_bias <= 16, while shift_cut = wp + ip - op
    """
    adjusted_quantize_info = copy.deepcopy(quantize_info)
  
    for i in range(1, len(model.layers)):
      layer = model.layers[i]
      if not isinstance(layer, vitis_quantize_wrapper.QuantizeWrapper):
        continue
  
      # Only adjust shift_cut and shift_bias for Conv-like layers
      if not (isinstance(layer.layer, keras.layers.Conv2D) or
              isinstance(layer.layer, keras.layers.DepthwiseConv2D) or
              isinstance(layer.layer, keras.layers.Conv2DTranspose) or
              isinstance(layer.layer, keras.layers.Dense)):
        continue
  
      ip, wp, op, bp = _get_iwob_pos(layer, adjusted_quantize_info)
  
      if isinstance(wp, np.ndarray):
        logger.debug(
            'Not support adjust shift bias for per_channel quantization.')
        return adjusted_quantize_info
  
      if not _is_valid(ip, wp, op, bp):
        logger.debug('Skip shift bias adjustment for layer {}, '
                     'its quantize pos is [i={}, w={}, b={}, o={}]'.format(
                         layer.name, ip, wp, bp, op))
        return adjusted_quantize_info
  
      sc = wp + ip - op
      min_sb = min(0, -(24 - (8 + sc)))
      max_sb = 16
      sb = wp + ip - bp
  
      new_sb = None
      if sb < min_sb:
        new_sb = min_sb
      elif sb > max_sb:
        new_sb = max_sb
  
      if new_sb is not None:
        new_bp = wp + ip - new_sb
        _set_pos(layer, adjusted_quantize_info, 'b', new_bp)
        logger.debug('Shift bias of layer {} is {}. It exceeds range [{}, {}]. '
                     'Modify bpos from {} to {}.'.format(layer.name, int(sb),
                                                         int(min_sb), int(max_sb),
                                                         int(bp), int(new_bp)))
    return adjusted_quantize_info
function_tokens: def _adjust_shift_bias ( model , quantize_info ) : adjusted_quantize_info = copy . deepcopy ( quantize_info ) for i in range ( 1 , len ( model . layers ) ) : layer = model . layers [ i ] if not isinstance ( layer , vitis_quantize_wrapper . QuantizeWrapper ) : continue # Only adjust shift_cut and shift_bias for Conv-like layers if not ( isinstance ( layer . layer , keras . layers . Conv2D ) or isinstance ( layer . layer , keras . layers . DepthwiseConv2D ) or isinstance ( layer . layer , keras . layers . Conv2DTranspose ) or isinstance ( layer . layer , keras . layers . Dense ) ) : continue ip , wp , op , bp = _get_iwob_pos ( layer , adjusted_quantize_info ) if isinstance ( wp , np . ndarray ) : logger . debug ( 'Not support adjust shift bias for per_channel quantization.' ) return adjusted_quantize_info if not _is_valid ( ip , wp , op , bp ) : logger . debug ( 'Skip shift bias adjustment for layer {}, ' 'its quantize pos is [i={}, w={}, b={}, o={}]' . format ( layer . name , ip , wp , bp , op ) ) return adjusted_quantize_info sc = wp + ip - op min_sb = min ( 0 , - ( 24 - ( 8 + sc ) ) ) max_sb = 16 sb = wp + ip - bp new_sb = None if sb < min_sb : new_sb = min_sb elif sb > max_sb : new_sb = max_sb if new_sb is not None : new_bp = wp + ip - new_sb _set_pos ( layer , adjusted_quantize_info , 'b' , new_bp ) logger . debug ( 'Shift bias of layer {} is {}. It exceeds range [{}, {}]. ' 'Modify bpos from {} to {}.' . format ( layer . name , int ( sb ) , int ( min_sb ) , int ( max_sb ) , int ( bp ) , int ( new_bp ) ) ) return adjusted_quantize_info