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

Function test_mod

tests/python/arith/test_arith_intset.py:91–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

89
90
91def test_mod():
92 ck = IntSetChecker()
93 x, y = tvm.tirx.Var("x", "int32"), tvm.tirx.Var("y", "int32")
94 tmod = tvm.tirx.truncmod
95 ck.analyzer.update(y, tvm.arith.ConstIntBound(1, 100), override=True)
96 ck.verify(tmod(x, y), {x: tvm.arith.IntervalSet(0, 10)}, (0, y - 1))
97 ck.verify(tmod(x, 10), {x: tvm.arith.IntervalSet(1, 10)}, (0, 9))
98
99 flm = tvm.tirx.floormod
100 ck.verify(flm(x, 10), {x: tvm.arith.IntervalSet(-10, 10)}, (0, 9))
101 ck.verify(flm(x, 10), {x: tvm.arith.IntervalSet(3, 5)}, (3, 5))
102 ck.verify(flm(x, 10), {x: tvm.arith.IntervalSet(13, 15)}, (3, 5))
103 ck.verify(flm(x, 10), {x: tvm.arith.IntervalSet(3, 15)}, (0, 9))
104 ck.verify(flm(x, 10), {x: tvm.arith.IntervalSet(3, 11)}, (0, 9))
105 ck.verify(flm(x, 10), {x: tvm.arith.IntervalSet(1, 21)}, (0, 9))
106
107 fld = tvm.tirx.floordiv
108 z = tvm.tirx.Var("z", "int32")
109 ck.analyzer.bind(x, tvm.ir.Range.from_min_extent(0, 3))
110 ck.verify(
111 flm(y, 8),
112 {y: tvm.arith.IntervalSet(z * 8 + x * 4, z * 8 + x * 4 + 3)},
113 (
114 z * 8 + x * 4 - 8 * fld(z * 8 + x * 4, 8),
115 z * 8 + x * 4 + 3 - 8 * fld(z * 8 + x * 4, 8),
116 ),
117 )
118 ck1 = IntSetChecker()
119 ck1.analyzer.bind(x, tvm.ir.Range.from_min_extent(0, 2))
120 ck1.verify(
121 flm(y, 8), {y: tvm.arith.IntervalSet(z * 8 + x * 4, z * 8 + x * 4 + 3)}, (x * 4, x * 4 + 3)
122 )
123
124
125def test_max_min():

Callers

nothing calls this directly

Calls 5

verifyMethod · 0.95
IntSetCheckerClass · 0.85
from_min_extentMethod · 0.80
updateMethod · 0.45
bindMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…