Skip to content

Commit

Permalink
[Relay] Fix an assertion exposed by loop vectorizer (apache#4916)
Browse files Browse the repository at this point in the history
- Allows uniform conditions for select expressions (the same as halide)
  exposed by the loop vectorizer.

Signed-off-by: Wei Pan <weip@nvidia.com>
  • Loading branch information
wpan11nv authored and alexwong committed Feb 28, 2020
1 parent fd28647 commit aa6d17f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/tir/ir/expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ PrimExpr SelectNode::make(PrimExpr condition, PrimExpr true_value, PrimExpr fals
CHECK(true_value.defined()) << "ValueError: true_value is undefined";
CHECK(false_value.defined()) << "ValueError: true_value is undefined";
CHECK(condition.dtype().is_bool());
CHECK_EQ(condition.dtype().lanes(), true_value.dtype().lanes());
CHECK(condition.dtype().lanes() == true_value.dtype().lanes() ||
condition.dtype().lanes() == 1);
CHECK(false_value.dtype() == true_value.dtype()) << "TypeError: mismatched types";

ObjectPtr<SelectNode> node = make_object<SelectNode>();
Expand Down
1 change: 1 addition & 0 deletions tests/python/relay/test_op_level4.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ def verify(dshape, begin, end, strides, vshape, test_ref=True):
op_res = intrp.evaluate(func)(x_data, v_data)
tvm.testing.assert_allclose(op_res.asnumpy(), ref_res)

verify((3, 4, 16), [0, 0, 0], [4, -5, 4], [1, -1, 2], (3, 1, 2))
verify((3, 4, 3), [0, 0, 0], [4, -5, 4], [1, -1, 2], (3, 1, 2))
verify((3, 4, 3), [1, 1, 0], [4, 4, 3], [2, 1, 1], (1, 3, 3))
verify((3, 4, 3), [1, -1, 0], [4, -5, 3], [2, -1, 1], (1, 4, 3))
Expand Down

0 comments on commit aa6d17f

Please sign in to comment.