()
| 137 | |
| 138 | |
| 139 | def test_infer_range(): |
| 140 | x, y = tvm.tirx.Var("x", "int32"), tvm.tirx.Var("y", "int32") |
| 141 | ranges = { |
| 142 | x: tvm.ir.Range.from_min_extent(-5, 10), |
| 143 | y: tvm.ir.Range.from_min_extent(0, 10), |
| 144 | } |
| 145 | |
| 146 | solution = arith.solve_linear_equations( |
| 147 | [ |
| 148 | tvm.tirx.EQ(x + y, 0), |
| 149 | ], |
| 150 | [x, y], |
| 151 | ranges, |
| 152 | ) |
| 153 | [n0] = solution.dst.variables |
| 154 | assert tvm_ffi.structural_equal(solution.src_to_dst[x], n0) |
| 155 | assert tvm_ffi.structural_equal(solution.src_to_dst[y], -n0) |
| 156 | # inferred from y's range |
| 157 | assert tvm_ffi.structural_equal(solution.dst.ranges[n0].min, T.int32(-9)) |
| 158 | assert tvm_ffi.structural_equal(solution.dst.ranges[n0].extent, T.int32(10)) |
| 159 | # additional inequality is added into the system for x |
| 160 | [ineq] = solution.dst.relations |
| 161 | assert isinstance(ineq, tvm.tirx.LE) |
| 162 | assert tvm_ffi.structural_equal(ineq.a, T.int32(-5)) |
| 163 | assert tvm_ffi.structural_equal(ineq.b, n0) |
| 164 | |
| 165 | |
| 166 | def test_ill_formed(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…