def test_index_var_basic(self): b = FakeBox() i = IndexVar(b, 1, 1, 0) j = IndexVar(b, 1, 1, 0) assert i.is_identity() assert i.same_variable(j) assert i.constant_diff(j) == 0
def test_index_var_diff(self): b = FakeBox() i = IndexVar(b, 4, 2, 0) j = IndexVar(b, 1, 1, 1) assert not i.is_identity() assert not j.is_identity() assert not i.same_mulfactor(j) assert i.constant_diff(j) == -1
def __init__(self, index, op, cmp_op, index_vars): self.index = index self.op = op self.cmp_op = cmp_op lhs = cmp_op.getarg(0) self.lhs = index_vars.get(lhs, None) if self.lhs is None: self.lhs = IndexVar(lhs) # rhs = cmp_op.getarg(1) self.rhs = index_vars.get(rhs, None) if self.rhs is None: self.rhs = IndexVar(rhs)
def memoryref(array, var, mod=(1,1,0), descr=None, raw=False): if descr is None: descr = FLOAT mul, div, off = mod op = FakeMemoryRefResOp(array, descr) return MemoryRef(op, IndexVar(var, mul, div, off), raw)
def iv(value, coeff=(1, 1, 0)): var = IndexVar(value) var.coefficient_mul = coeff[0] var.coefficient_div = coeff[1] var.constant = coeff[2] return var