def _gather_output_scale():
    target_ops = []
    for block in program.blocks:
        for op in block.ops:
            if (op.type == 'moving_average_abs_max_scale'):
                target_ops.append(op)
    for op in target_ops:
        in_var_name = op.input('X')[0]
        out_var_name = op.output('Out')[0]
        block = op.block
        previous_op = utils.find_previous_op(block, in_var_name)
        next_ops = utils.find_next_ops(block, out_var_name)
        out_scale_name = op.output('OutScale')[0]
        out_scale = utils.load_variable_data(scope, out_scale_name)
        out_scale = utils.fp_numpy_to_naive(out_scale)
        if (previous_op.type != 'feed'):
            (argname, index) = utils._get_output_name_index(previous_op, in_var_name)
            previous_op._set_attr(((argname + str(index)) + '_threshold'), out_scale)
            previous_op._set_attr('out_threshold', out_scale)
        for next_op in next_ops:
            next_op._rename_input(out_var_name, in_var_name)
def _gather_output_scale():
    target_ops = []
    for block in program.blocks:
        for op in block.ops:
            if (op.type == 'moving_average_abs_max_scale'):
                target_ops.append(op)
    for op in target_ops:
        in_var_name = op.input('X')[0]
        out_var_name = op.output('Out')[0]
        block = op.block
        previous_op = utils.find_previous_op(block, in_var_name)
        next_ops = utils.find_next_ops(block, out_var_name)
        out_scale_name = op.output('OutScale')[0]
        out_scale = utils.load_variable_data(scope, out_scale_name)
        out_scale = utils.fp_numpy_to_naive(out_scale)
        if (previous_op.type != 'feed'):
            (argname, index) = utils._get_output_name_index(previous_op, in_var_name)
            previous_op._set_attr(((argname + str(index)) + '_threshold'), out_scale)
            previous_op._set_attr('out_threshold', out_scale)
        for next_op in next_ops:
            next_op._rename_input(out_var_name, in_var_name)