def testLoopContext(self): self.setUp() with self.module.function_context("foo", [], []) as fun: lhs = E.constant_index(0) rhs = E.constant_index(42) with E.LoopContext(lhs, rhs, 1) as i: lhs + rhs + i with E.LoopContext(rhs, rhs + rhs, 2) as j: x = i + j printWithCurrentFunctionName(str(fun))
def testLoopContext(self): with self.module.function_context("foo", [], []) as fun: lhs = E.constant_index(0) rhs = E.constant_index(42) with E.LoopContext(lhs, rhs, 1) as i: lhs + rhs + i with E.LoopContext(rhs, rhs + rhs, 2) as j: x = i + j code = str(fun) # TODO(zinenko,ntv): use FileCheck for these tests self.assertIn( ' "affine.for"() {lower_bound: () -> (0), step: 1 : index, upper_bound: () -> (42)} : () -> () {\n', code) self.assertIn(" ^bb1(%i0: index):", code) self.assertIn( ' "affine.for"(%c42, %2) {lower_bound: (d0) -> (d0), step: 2 : index, upper_bound: (d0) -> (d0)} : (index, index) -> () {\n', code) self.assertIn(" ^bb2(%i1: index):", code) self.assertIn( ' %3 = "affine.apply"(%i0, %i1) {map: (d0, d1) -> (d0 + d1)} : (index, index) -> index', code)