def residual_block_quant(self, activation_quant_type, weight_quantize_type, quantizable_op_type, for_ci=True):
    main = fluid.Program()
    startup = fluid.Program()
    with fluid.program_guard(main, startup):
        loss = residual_block(2)
        opt = fluid.optimizer.Adam(learning_rate=0.001)
        opt.minimize(loss)
    place = fluid.CPUPlace()
    graph = IrGraph(core.Graph(main.desc), for_test=False)
    transform_pass = QuantizationTransformPass(scope=fluid.global_scope(), place=place, activation_quantize_type=activation_quant_type, weight_quantize_type=weight_quantize_type, quantizable_op_type=quantizable_op_type)
    transform_pass.apply(graph)
    if (not for_ci):
        marked_nodes = set()
        for op in graph.all_op_nodes():
            if (op.name().find('quantize') > (- 1)):
                marked_nodes.add(op)
        graph.draw('.', ('quantize_residual_' + activation_quant_type), marked_nodes)
    program = graph.to_program()
    self.check_program(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('quantize') > (- 1)):
                val_marked_nodes.add(op)
        val_graph.draw('.', ('val_residual_' + activation_quant_type), val_marked_nodes)
def residual_block_quant(self, activation_quant_type, weight_quantize_type, quantizable_op_type, for_ci=True):
    main = fluid.Program()
    startup = fluid.Program()
    with fluid.program_guard(main, startup):
        loss = residual_block(2)
        opt = fluid.optimizer.Adam(learning_rate=0.001)
        opt.minimize(loss)
    place = fluid.CPUPlace()
    graph = IrGraph(core.Graph(main.desc), for_test=False)
    transform_pass = QuantizationTransformPass(scope=fluid.global_scope(), place=place, activation_quantize_type=activation_quant_type, weight_quantize_type=weight_quantize_type, quantizable_op_type=quantizable_op_type)
    transform_pass.apply(graph)
    if (not for_ci):
        marked_nodes = set()
        for op in graph.all_op_nodes():
            if (op.name().find('quantize') > (- 1)):
                marked_nodes.add(op)
        graph.draw('.', ('quantize_residual_' + activation_quant_type), marked_nodes)
    program = graph.to_program()
    self.check_program(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('quantize') > (- 1)):
                val_marked_nodes.add(op)
        val_graph.draw('.', ('val_residual_' + activation_quant_type), val_marked_nodes)