Exemple #1
0
def test_unique(target, dev):
    dtype = "int32"
    x = relay.var("x", shape=(relay.Any(),), dtype=dtype)
    mod = tvm.IRModule()
    [unique, _, _, num_unique] = relay.unique(x, is_sorted=True)
    mod["main"] = relay.Function([x], relay.op.strided_slice(unique, begin=[0], end=num_unique))
    x_np = np.random.randint(0, high=10, size=(10,)).astype(dtype)
    res_np = np.unique(x_np)
    check_mod(target, dev, mod, x_np, res_np)
Exemple #2
0
def test_unique():
    if not tvm.testing.device_enabled("vulkan"):
        return

    dtype = "int32"
    x = relay.var("x", shape=(relay.Any(), ), dtype=dtype)
    mod = tvm.IRModule()
    [unique, _, num_unique] = relay.unique(x, is_sorted=True)
    mod["main"] = relay.Function([x],
                                 relay.op.strided_slice(unique,
                                                        begin=[0],
                                                        end=num_unique))
    x_np = np.random.randint(0, high=10, size=(10, )).astype(dtype)
    res_np = np.unique(x_np)
    check_mod(mod, x_np, res_np)