parameters: (self, block, idx, in_var, quant_bits, is_test)
return_statement: return quant_dequant_var
docstring: Insert moving average abs max fake quant op.
docstring_summary: Insert moving average abs max fake quant op.
docstring_tokens: Insert moving average abs max fake quant op .
function: def _insert_ma_abs_max_fq_op(self, block, idx, in_var, quant_bits, is_test):
          """
          Insert moving average abs max fake quant op.
          """
          quant_dequant_var = block.create_var(
              type=in_var.type,
              name="{}.quant_dequant".format(in_var.name),
              shape=in_var.shape,
              dtype=in_var.dtype)
  
          scale_var = self._helper.create_parameter(
              attr=ParamAttr(
                  name="{}.quant_dequant.scale".format(in_var.name),
                  initializer=Constant(0.),
                  trainable=False),
              shape=[1],
              dtype=in_var.dtype)
          scale_var.stop_gradient = True
  
          if not is_test:
              state_var = self._helper.create_parameter(
                  attr=ParamAttr(
                      name="{}.quant_dequant.state".format(in_var.name),
                      initializer=Constant(0),
                      trainable=False),
                  shape=[1],
                  dtype=in_var.dtype)
              state_var.stop_gradient = True
  
              accum_var = self._helper.create_parameter(
                  attr=ParamAttr(
                      name="{}.quant_dequant.accum".format(in_var.name),
                      initializer=Constant(0),
                      trainable=False),
                  shape=[1],
                  dtype=in_var.dtype)
              accum_var.stop_gradient = True
  
          attrs = {
              'moving_rate': self._moving_rate,
              'bit_length': quant_bits,
              'is_test': is_test
          }
          inputs = {'X': in_var, 'InScale': scale_var}
          outputs = {'Out': quant_dequant_var, 'OutScale': scale_var}
          if not is_test:
              inputs['InState'] = state_var
              inputs['InAccum'] = accum_var
              outputs['OutState'] = state_var
              outputs['OutAccum'] = accum_var
  
          block._insert_op(
              idx,
              type='fake_quantize_dequantize_moving_average_abs_max',
              attrs=attrs,
              inputs=inputs,
              outputs=outputs)
          return quant_dequant_var
function_tokens: def _insert_ma_abs_max_fq_op ( self , block , idx , in_var , quant_bits , is_test ) : quant_dequant_var = block . create_var ( type = in_var . type , name = "{}.quant_dequant" . format ( in_var . name ) , shape = in_var . shape , dtype = in_var . dtype ) scale_var = self . _helper . create_parameter ( attr = ParamAttr ( name = "{}.quant_dequant.scale" . format ( in_var . name ) , initializer = Constant ( 0. ) , trainable = False ) , shape = [ 1 ] , dtype = in_var . dtype ) scale_var . stop_gradient = True if not is_test : state_var = self . _helper . create_parameter ( attr = ParamAttr ( name = "{}.quant_dequant.state" . format ( in_var . name ) , initializer = Constant ( 0 ) , trainable = False ) , shape = [ 1 ] , dtype = in_var . dtype ) state_var . stop_gradient = True accum_var = self . _helper . create_parameter ( attr = ParamAttr ( name = "{}.quant_dequant.accum" . format ( in_var . name ) , initializer = Constant ( 0 ) , trainable = False ) , shape = [ 1 ] , dtype = in_var . dtype ) accum_var . stop_gradient = True attrs = { 'moving_rate' : self . _moving_rate , 'bit_length' : quant_bits , 'is_test' : is_test } inputs = { 'X' : in_var , 'InScale' : scale_var } outputs = { 'Out' : quant_dequant_var , 'OutScale' : scale_var } if not is_test : inputs [ 'InState' ] = state_var inputs [ 'InAccum' ] = accum_var outputs [ 'OutState' ] = state_var outputs [ 'OutAccum' ] = accum_var block . _insert_op ( idx , type = 'fake_quantize_dequantize_moving_average_abs_max' , attrs = attrs , inputs = inputs , outputs = outputs ) return quant_dequant_var