File: negate_test.py

package info (click to toggle)
halide 21.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 55,752 kB
  • sloc: cpp: 289,334; ansic: 22,751; python: 7,486; makefile: 4,299; sh: 2,508; java: 1,549; javascript: 282; pascal: 207; xml: 127; asm: 9
file content (40 lines) | stat: -rw-r--r-- 785 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import halide as hl


def test_free_logical_not_function():
    x = hl.Var("x")

    f = hl.Func("f")
    f[x] = x > 5

    not_f = hl.Func("not_f")
    not_f[x] = hl.logical_not(f[x])

    f_out = f.realize([10])
    not_f_out = not_f.realize([10])

    for i in range(10):
        assert f_out[i] == (i > 5)
        assert not_f_out[i] == (i <= 5)


def test_member_logical_not_function():
    x = hl.Var("x")

    f = hl.Func("f")
    f[x] = x > 5

    not_f = hl.Func("not_f")
    not_f[x] = f[x].logical_not()

    f_out = f.realize([10])
    not_f_out = not_f.realize([10])

    for i in range(10):
        assert f_out[i] == (i > 5)
        assert not_f_out[i] == (i <= 5)


if __name__ == "__main__":
    test_free_logical_not_function()
    test_member_logical_not_function()