4c13ae9d17d1709ed7a777ce1bb72212e8d2559d,tests/python/frontend/pytorch/test_object_detection.py,,test_detection_models,#,88

Before Change


    with tvm.transform.PassContext(opt_level=3, disabled_pass=["FoldScaleAxis"]):
        vm_exec = relay.vm.compile(mod, target=target, params=params)

    ctx = tvm.cpu()
    vm = VirtualMachine(vm_exec, ctx)
    data = process_image(img)
    pt_res = scripted_model(data)
    data = data.detach().numpy()
    vm.set_input("main", **{input_name: data})
    tvm_res = vm.run()

    // Note: due to accumulated numerical error, we can"t directly compare results
    // with pytorch output. Some boxes might have a quite tiny difference in score
    // and the order can become different. We just measure how many valid boxes
    // there are for input image.
    pt_scores = pt_res[1].detach().numpy().tolist()
    tvm_scores = tvm_res[1].asnumpy().tolist()
    num_pt_valid_scores = num_tvm_valid_scores = 0

    for score in pt_scores:
        if score >= score_threshold:
            num_pt_valid_scores += 1
        else:
            break

    for score in tvm_scores:
        if score >= score_threshold:
            num_tvm_valid_scores += 1
        else:
            break

    assert num_pt_valid_scores == num_tvm_valid_scores, (
        "Output mismatch: Under score threshold {}, Pytorch has {} valid "
        "boxes while TVM has {}.".format(score_threshold, num_pt_valid_scores, num_tvm_valid_scores)
    )

After Change



        score_threshold = 0.9
        print("Num boxes:", pt_res[0].cpu().numpy().shape[0])
        print("Num valid boxes:", np.sum(pt_res[1].cpu().numpy() >= score_threshold))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: apache/incubator-tvm
Commit Name: 4c13ae9d17d1709ed7a777ce1bb72212e8d2559d
Time: 2020-12-25
Author: masahi129@gmail.com
File Name: tests/python/frontend/pytorch/test_object_detection.py
Class Name:
Method Name: test_detection_models


Project Name: osmr/imgclsmob
Commit Name: ff46766065ea7846f8b36701451afc2bf6d667d3
Time: 2019-06-08
Author: osemery@gmail.com
File Name: pytorch/pytorchcv/models/efficientnet.py
Class Name:
Method Name: _test


Project Name: CSAILVision/semantic-segmentation-pytorch
Commit Name: 6324799d51a451995a91b76306eae40ccd11f55e
Time: 2018-03-27
Author: jasonhsiao97@gmail.com
File Name: utils.py
Class Name:
Method Name: accuracy