Skip to content

Commit

Permalink
[checkpoint] working on unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mbs-octoml committed Sep 15, 2021
1 parent ebf87be commit cb22588
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tests/python/relay/test_pass_plan_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,20 @@ def rewrite_and_assert(in_mod, expected_mod):
def eval_and_assert(in_mod: tvm.IRModule, reference_func, args):
with tvm.transform.PassContext(opt_level=3):
compiled = relay.create_executor("vm", mod=in_mod, device=GPU, target="cuda").evaluate()

if not (reference_func is None) and not (args is None):
actual = compiled(*args).numpy()
expected = reference_func(*args)
tvm.testing.assert_allclose(actual, expected)


def exercise(in_mod: tvm.IRModule, expected_mod: tvm.IRModule, reference_func, args):
# Correctness
# rewrite_and_assert(in_mod, expected_mod)
rewrite_and_assert(in_mod, expected_mod)
# Idempotence
# rewrite_and_assert(expected_mod, expected_mod)
# The VM can compile
if not (reference_func is None) and not (args is None):
eval_and_assert(in_mod, reference_func, args)
rewrite_and_assert(expected_mod, expected_mod)
# The VM can compile and possibly even run the module
eval_and_assert(in_mod, reference_func, args)


def on_cpu(expr: relay.Expr):
Expand Down Expand Up @@ -1036,10 +1037,10 @@ def ref(a, b, c, d):

if __name__ == "__main__":
# test_plain()
test_left_add_on_cpu()
# test_left_add_on_cpu()
# test_left_add_on_cpu_via_copy()
# test_both_adds_on_cpu()
# test_sharing()
test_sharing()
# test_let_on_cpu()
# test_func_param_on_cpu()
# test_func_result_on_cpu()
Expand Down

0 comments on commit cb22588

Please sign in to comment.