def residual_block_quant(self, quantizable_op_type, skip_pattern=None, for_ci=True):
    main = fluid.Program()
    startup = fluid.Program()
    with fluid.program_guard(main, startup):
        loss = quant_dequant_residual_block(2, skip_pattern)
        opt = fluid.optimizer.Adam(learning_rate=0.001)
        opt.minimize(loss)
    place = fluid.CPUPlace()
    graph = IrGraph(core.Graph(main.desc), for_test=False)
    add_quant_dequant_pass = AddQuantDequantPass(scope=fluid.global_scope(), place=place, skip_pattern=skip_pattern, quantizable_op_type=quantizable_op_type)
    add_quant_dequant_pass.apply(graph)
    if (not for_ci):
        marked_nodes = set()
        for op in graph.all_op_nodes():
            if (op.name().find('quant') > (- 1)):
                marked_nodes.add(op)
        graph.draw('.', 'add_quant_dequant_graph', marked_nodes)
    self.check_graph(graph, skip_pattern)
    program = graph.to_program()
    val_graph = IrGraph(core.Graph(program.desc), for_test=False)
    if (not for_ci):
        val_marked_nodes = set()
        for op in val_graph.all_op_nodes():
            if (op.name().find('quant') > (- 1)):
                val_marked_nodes.add(op)
        val_graph.draw('.', 'val_add_quant_dequant_graph', val_marked_nodes)
def residual_block_quant(self, quantizable_op_type, skip_pattern=None, for_ci=True):
    main = fluid.Program()
    startup = fluid.Program()
    with fluid.program_guard(main, startup):
        loss = quant_dequant_residual_block(2, skip_pattern)
        opt = fluid.optimizer.Adam(learning_rate=0.001)
        opt.minimize(loss)
    place = fluid.CPUPlace()
    graph = IrGraph(core.Graph(main.desc), for_test=False)
    add_quant_dequant_pass = AddQuantDequantPass(scope=fluid.global_scope(), place=place, skip_pattern=skip_pattern, quantizable_op_type=quantizable_op_type)
    add_quant_dequant_pass.apply(graph)
    if (not for_ci):
        marked_nodes = set()
        for op in graph.all_op_nodes():
            if (op.name().find('quant') > (- 1)):
                marked_nodes.add(op)
        graph.draw('.', 'add_quant_dequant_graph', marked_nodes)
    self.check_graph(graph, skip_pattern)
    program = graph.to_program()
    val_graph = IrGraph(core.Graph(program.desc), for_test=False)
    if (not for_ci):
        val_marked_nodes = set()
        for op in val_graph.all_op_nodes():
            if (op.name().find('quant') > (- 1)):
                val_marked_nodes.add(op)
        val_graph.draw('.', 'val_add_quant_dequant_graph', val_marked_nodes)