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

Before Change


    download(img_url, img)

    input_shape = (1, 3, in_size, in_size)
    target = "llvm"
    input_name = "input0"
    shape_list = [(input_name, input_shape)]
    score_threshold = 0.9

    scripted_model = generate_jit_model(1)
    mod, params = relay.frontend.from_pytorch(scripted_model, shape_list)

    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:

After Change


        tvm_res = vm.run()

        // Bounding boxes
        tvm.testing.assert_allclose(
            pt_res[0].cpu().numpy(), tvm_res[0].asnumpy(), rtol=1e-5, atol=1e-5
        )
        // Scores
        tvm.testing.assert_allclose(
            pt_res[1].cpu().numpy(), tvm_res[1].asnumpy(), rtol=1e-5, atol=1e-5
        )
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 4

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: Featuretools/featuretools
Commit Name: 3b84b663234956420fcf0c41a2c85d5880f0ecdb
Time: 2019-06-17
Author: chrisstadler@gmail.com
File Name: featuretools/tests/entityset_tests/test_timedelta.py
Class Name:
Method Name: test_delta_with_observations


Project Name: Pinafore/qb
Commit Name: 9d22742baeeb608bac5594c3ece96f62f0734dce
Time: 2017-05-13
Author: sjtufs@gmail.com
File Name: qanta/buzzer/trainer.py
Class Name: Trainer
Method Name: test


Project Name: nipy/dipy
Commit Name: ced0dcb3db1d6e1d32310f46b442cbbffaba3d3a
Time: 2018-10-08
Author: bramshq@gmail.com
File Name: dipy/workflows/tests/test_align.py
Class Name:
Method Name: test_slr_flow