def mul(A, B, x):
     temp = hcl.scalar(0)
     with hcl.for_(0, x) as i:
         hcl.assert_(x < 5, "assert in for")
         temp[0] += add(A, B, x)
         hcl.print(0, "in for\n")
     hcl.return_(temp[0])
 def update_B(A, x):
     with hcl.if_(A[x] < 5):
         hcl.print(0, "print1\n")
         hcl.assert_(A[x] < 4, "assert message 1")
         hcl.print(0, "print2\n")
         hcl.return_(-1)
     hcl.assert_(A[x] >= 5, "assert message 2")
     hcl.print(0, "not in if\n")
     hcl.return_(A[x] + 1)
 def update_B(A, x):
     with hcl.for_(0, 10) as i:
         hcl.assert_(i < 20)
         hcl.print(0, "in for loop\n")
         with hcl.if_(A[x] == i):
             hcl.assert_(A[x] > 10, "assert in if")
             hcl.print(0, "this should not be printed")
             hcl.return_(1)
     hcl.return_(A[x])
 def update_B(A, x):
     with hcl.if_(A[x] > 5):
         hcl.print(0, "print if 1\n")
         hcl.assert_(A[x] <= 5, "assert in if")
         hcl.print(0, "print if 2\n")
         hcl.return_(-1)
     with hcl.else_():
         hcl.print(0, "print else 1\n")
         hcl.assert_(A[x] <= 5, "assert in else")
         hcl.print(0, "print else 2\n")
         hcl.return_(A[x] + 1)
Пример #5
0
 def update_B(A, x):
     with hcl.if_(A[x] > 5):
         with hcl.if_(A[x] > 7):
             hcl.return_(-2)
         hcl.return_(-1)
     with hcl.else_():
         with hcl.if_(A[x] > 3):
             hcl.return_(-3)
     hcl.return_(A[x] + 1)
Пример #6
0
 def pe(a, b, x):
     with hcl.if_(x == 0):
         result = a * b
         hcl.return_(a)
     with hcl.elif_(x == 1):
         hcl.return_(b)
     with hcl.else_():
         hcl.return_(result)
 def update_B(A, x):
     with hcl.if_(A[x] > 5):
         with hcl.if_(A[x] > 7):
             hcl.print(0, "in if 1\n")
             hcl.assert_(A[x] == 1, "assert in if")
             hcl.print(0, "in if 2\n")
             hcl.return_(-2)
         hcl.return_(-1)
     with hcl.else_():
         with hcl.if_(A[x] > 3):
             hcl.print(0, "in else 1\n")
             hcl.assert_(A[x] == 4, "assert in else")
             hcl.print(2, "in else 2\n")
             hcl.return_(-3)
     hcl.return_(A[x] + 1)
Пример #8
0
 def add(A, B, x):
     hcl.return_(A[x] + B[x])
Пример #9
0
 def mul(A, B, x):
     temp = hcl.local(0)
     with hcl.for_(0, x) as i:
         temp[0] += add(A, B, x)
     hcl.return_(temp[0])
Пример #10
0
 def update_B(A, x):
     with hcl.for_(0, 10) as i:
         with hcl.if_(A[x] == i):
             hcl.return_(1)
     hcl.return_(A[x])
Пример #11
0
 def add(A, B, x):
     hcl.assert_(x < 3, "assert in add")
     hcl.print(0, "in add\n")
     hcl.return_(A[x] + B[x])
Пример #12
0
def ret_add(a, b, x, y):
    hcl.return_(a[x, y] + b[x, y])
Пример #13
0
def ret_mul(a, b, x, y):
    hcl.return_(a[x, y] * b[x, y])
Пример #14
0
 def foo(A, x):
     B = hcl.compute(A.shape, lambda y: A[y] + 1)
     hcl.return_(B[x])
Пример #15
0
 def foo(A, x):
     hcl.return_(A[x] + 1)
Пример #16
0
 def foo(x, y, z):
     with hcl.if_(A[x, y, z] > 5):
         hcl.return_(x)
     with hcl.else_():
         hcl.return_(0)
Пример #17
0
 def update_B(A, x):
     hcl.return_(A[x] + 1)
Пример #18
0
 def absolute(image, *args):
     with hcl.if_(image[args] > 0):
         hcl.return_(image[args])
     with hcl.else_():
         hcl.return_(-1 * image[args])
Пример #19
0
 def reducer_body(x, y):
     with hcl.if_(x > 5):
         hcl.return_(y + 1)
     with hcl.else_():
         hcl.return_(y + 2)
Пример #20
0
 def popcount64(number):
     count = hcl.scalar(0, "count")
     with hcl.for_(0, 64) as i:
         count.v += number[i]
     hcl.return_(count.v)
Пример #21
0
 def update_B(A, x):
     hcl.print(0, "print1\n")
     hcl.assert_(A[x] != 7)
     hcl.print(0, "print2\n")
     hcl.return_(A[x] + 1)
Пример #22
0
 def update_B(A, x):
     with hcl.if_(A[x] > 5):
         hcl.return_(-1)
     hcl.return_(A[x] + 1)
Пример #23
0
 def find_max(A, B, x):
     with hcl.if_(A[x] > B[x]):
         hcl.return_(A[x])
     with hcl.else_():
         hcl.return_(B[x])