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

Function _check

tests/python/arith/test_arith_solve_linear_inequality.py:37–58  ·  view source on GitHub ↗
(variables, formulas, coef=(-5, 5), bounds=(-20, 20))

Source from the content-addressed store, hash-verified

35 random.seed(seed)
36
37 def _check(variables, formulas, coef=(-5, 5), bounds=(-20, 20)):
38 vs = [tvm.tirx.Var("x" + str(i), "int32") for i in range(variables)]
39
40 fs = []
41 for i in range(formulas):
42 s1 = sum([v * random.randint(coef[0], coef[1]) for v in vs])
43 s1 += random.randint(coef[0], coef[1])
44 s2 = sum([v * random.randint(coef[0], coef[1]) for v in vs])
45 s2 += random.randint(coef[0], coef[1])
46 op = random.choice(
47 [tirx.expr.EQ, tirx.expr.LE, tirx.expr.LT, tirx.expr.GE, tirx.expr.GT]
48 )
49 fs.append(op(s1, s2))
50
51 vranges = {v: tvm.ir.expr.Range(bounds[0], bounds[1] + 1) for v in vs}
52 before = tvm.tirx.all(tirx.const(1, "bool"), *fs)
53 after = arith._ffi_api.SolveInequalitiesAsCondition(vs, vranges, fs)
54 after = tvm.tirx.all(tirx.const(1, "bool"), *after)
55 testing.check_bool_expr_is_true(before == after, vranges)
56
57 solution = arith.solve_linear_inequalities(fs, vs, vranges, deskew_range=True)
58 testing.check_int_constraints_trans_consistency(solution)
59
60 for i in range(3):
61 _check(1, 1)

Callers 1

Calls 3

strFunction · 0.85
sumFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…