コード例 #1
0
def test_custom_quantizable_subgraph_patterns(_case_config):
    model = test_models.SENet18()

    input_shape = (1, 3, 32, 32)

    config = get_basic_quantization_config(_case_config.quant_type, input_sample_size=input_shape)

    config["compression"].update({"quantize_outputs": False,
                                  "quantizable_subgraph_patterns": [["sigmoid", "__mul__"],
                                                                    ["__iadd__", "batch_norm"]]})

    compressed_model, _ = create_compressed_model_and_algo_for_test(model, config)
    check_model_graph(compressed_model, 'senet_custom_patterns.dot', _case_config.graph_dir)
コード例 #2
0
def test_custom_quantizable_subgraph_patterns(_quantize_config):
    net = test_models.SENet18()
    ctx = reset_context('orig')
    ctx = reset_context('quantized_graphs')
    input_shape = (1, 3, 32, 32)
    qnet = QuantizedNetwork(net, _quantize_config.quantizer, [ModelInputInfo(input_shape), ],
                            quantize_outputs=False,
                            quantizable_subgraph_patterns=(("sigmoid", "__mul__"),
                                                           ("__iadd__", "batch_norm")))
    _ = qnet(torch.zeros(*input_shape))
    _ = qnet(torch.zeros(*input_shape))

    check_graph(ctx.graph, 'senet_custom_patterns.dot', _quantize_config.graph_dir)