MCPcopy Create free account
hub / github.com/apache/tvm / test_infer_range

Function test_infer_range

tests/python/arith/test_arith_solve_linear_equations.py:139–163  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

137
138
139def 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
166def test_ill_formed():

Callers

nothing calls this directly

Calls 1

from_min_extentMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…