Skip to content

Commit

Permalink
test only structural equality
Browse files Browse the repository at this point in the history
  • Loading branch information
masahi committed Aug 25, 2021
1 parent df48c5a commit 5f47788
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions tests/python/relay/test_to_mixed_precision.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,19 @@ def test_do_not_convert_softmax():
b = relay.nn.softmax(a)
mod = tvm.IRModule.from_expr(b)
mod = tvm.relay.transform.InferType()(mod)

mod_params = {
"a": np.random.uniform(-1, 1, size=shape).astype("float32"),
}
output_mod = verify_mixed_precision_output_close(mod, mod_params, atol=0.0, rtol=0)
assert tvm.ir.structural_equal(mod, output_mod)
out_mod = ToMixedPrecision("float16")(mod)
orig_mod = tvm.relay.transform.InferType()(mod)
assert tvm.ir.structural_equal(orig_mod, out_mod)


def test_do_not_convert_arange():
"""Arange is a red listed operation and therefore should never be fp16."""
dtype = "float32"
arange = relay.arange(relay.const(1, dtype), relay.const(128, dtype))
mod = tvm.IRModule.from_expr(arange)
mod = tvm.relay.transform.InferType()(mod)

output_mod = verify_mixed_precision_output_close(mod, {}, atol=0.0, rtol=0)
assert tvm.ir.structural_equal(mod, output_mod)
out_mod = ToMixedPrecision("float16")(mod)
orig_mod = tvm.relay.transform.InferType()(mod)
assert tvm.ir.structural_equal(orig_mod, out_mod)


def test_do_not_convert_summation():
Expand All @@ -252,14 +248,9 @@ def test_do_not_convert_summation():
]
for op in ops:
mod = tvm.IRModule.from_expr(op(a))
mod = tvm.relay.transform.InferType()(mod)

mod_params = {
"a": np.random.uniform(-1, 1, size=shape).astype("float32"),
}

output_mod = verify_mixed_precision_output_close(mod, mod_params, atol=0.0, rtol=0)
assert tvm.ir.structural_equal(mod, output_mod)
out_mod = ToMixedPrecision("float16")(mod)
orig_mod = tvm.relay.transform.InferType()(mod)
assert tvm.ir.structural_equal(orig_mod, out_mod)


def test_green_gray_propagates_simple():
Expand Down

0 comments on commit 5f47788

Please sign in to comment.