Example #1
0
    def check_device(device):
        ctx = tvm.context(device, 0)
        if not ctx.exist:
            print("Skip because %s is not enabled" % device)
            return
        print("Running on target: %s" % device)
        with tvm.target.create(device):
            data = tvm.placeholder(dshape, name="data", dtype=dtype)
            outs = get_valid_counts(data, score_threshold)
            s = topi.generic.schedule_multibox_prior(outs)

        tvm_input_data = tvm.nd.array(np_data, ctx)
        tvm_out1 = tvm.nd.array(np.zeros(np_out1.shape, dtype="int32"), ctx)
        tvm_out2 = tvm.nd.array(np.zeros(np_out2.shape, dtype=dtype), ctx)
        f = tvm.build(s, [data, outs[0], outs[1]], device)
        f(tvm_input_data, tvm_out1, tvm_out2)
        tvm.testing.assert_allclose(tvm_out1.asnumpy(), np_out1, rtol=1e-3)
        tvm.testing.assert_allclose(tvm_out2.asnumpy(), np_out2, rtol=1e-3)
Example #2
0
    def check_device(device):
        ctx = tvm.context(device, 0)
        if not ctx.exist:
            print("Skip because %s is not enabled" % device)
            return
        print("Running on target: %s" % device)
        with tvm.target.create(device):
            data = tvm.placeholder(dshape, name="data", dtype=dtype)
            outs = get_valid_counts(data, score_threshold, id_index, score_index)
            s = topi.generic.schedule_get_valid_counts(outs)

        tvm_input_data = tvm.nd.array(np_data, ctx)
        tvm_out1 = tvm.nd.array(np.zeros(np_out1.shape, dtype="int32"), ctx)
        tvm_out2 = tvm.nd.array(np.zeros(np_out2.shape, dtype=dtype), ctx)
        f = tvm.build(s, [data, outs[0], outs[1]], device)
        f(tvm_input_data, tvm_out1, tvm_out2)
        tvm.testing.assert_allclose(tvm_out1.asnumpy(), np_out1, rtol=1e-3)
        tvm.testing.assert_allclose(tvm_out2.asnumpy(), np_out2, rtol=1e-3)