コード例 #1
0
def test_redundant_kernels():
    dtype = "float32"
    A = te.placeholder(shape=(1, ), name="A", dtype=dtype)
    B = te.placeholder(shape=(1, ), name="B", dtype=dtype)
    C = te.placeholder(shape=(1, ), name="C", dtype=dtype)
    D = topi.less(A, C)
    E = topi.less(B, C)
    F = topi.logical_or(D, E)
    G = topi.identity(F)

    for target in ["opencl", "cuda"]:
        if not tvm.testing.device_enabled(target):
            continue
        print("Running on target: %s" % target)
        valid = [None]

        with tvm.target.Target(target):
            s = tvm.topi.testing.get_reduce_schedule(target)(G)

        with tvm.transform.PassContext(config={
                "tir.add_lower_pass": [(2,
                                        get_verify_pass(valid, max_kernels=1))]
        }):
            tvm.build(s, [A, B, C, G], target)
        assert valid[0]
コード例 #2
0
 def less(x, y):
     return topi.less(x, y).astype("int8")