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)
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)
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)
def add(A, B, x): hcl.return_(A[x] + B[x])
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])
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])
def add(A, B, x): hcl.assert_(x < 3, "assert in add") hcl.print(0, "in add\n") hcl.return_(A[x] + B[x])
def ret_add(a, b, x, y): hcl.return_(a[x, y] + b[x, y])
def ret_mul(a, b, x, y): hcl.return_(a[x, y] * b[x, y])
def foo(A, x): B = hcl.compute(A.shape, lambda y: A[y] + 1) hcl.return_(B[x])
def foo(A, x): hcl.return_(A[x] + 1)
def foo(x, y, z): with hcl.if_(A[x, y, z] > 5): hcl.return_(x) with hcl.else_(): hcl.return_(0)
def update_B(A, x): hcl.return_(A[x] + 1)
def absolute(image, *args): with hcl.if_(image[args] > 0): hcl.return_(image[args]) with hcl.else_(): hcl.return_(-1 * image[args])
def reducer_body(x, y): with hcl.if_(x > 5): hcl.return_(y + 1) with hcl.else_(): hcl.return_(y + 2)
def popcount64(number): count = hcl.scalar(0, "count") with hcl.for_(0, 64) as i: count.v += number[i] hcl.return_(count.v)
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)
def update_B(A, x): with hcl.if_(A[x] > 5): hcl.return_(-1) hcl.return_(A[x] + 1)
def find_max(A, B, x): with hcl.if_(A[x] > B[x]): hcl.return_(A[x]) with hcl.else_(): hcl.return_(B[x])