masahi commented on a change in pull request #6759:
URL: https://github.com/apache/incubator-tvm/pull/6759#discussion_r511689194
##########
File path: src/relay/op/tensor/transform.cc
##########
@@ -1685,30 +1686,17 @@ bool WhereRel(const Array<Type>& types, int num_inputs,
const Attrs& attrs,
return false;
}
- const auto& cond_shape = condition->shape;
- const auto& x_shape = x->shape;
- const auto& y_shape = y->shape;
- ICHECK(x_shape.size() == y_shape.size()) << "x and y must have the same
size";
+ ICHECK_EQ(x->dtype, y->dtype) << "x and y must have the same dtype: " <<
x->dtype << " vs "
+ << y->dtype;
- if (cond_shape.size() != x_shape.size()) {
- ICHECK_EQ(cond_shape.size(), 1) << "Shape of condition " <<
condition->shape
- << " must be either equal to x or has
dimension of 1.";
- }
- for (size_t i = 0; i < x_shape.size(); i++) {
- ICHECK(reporter->AssertEQ(x_shape[i], y_shape[i]))
- << "x and y must have the same shape: " << x_shape << " vs " <<
y_shape;
+ auto tensor_ty_condition = GetRef<TensorType>(condition);
+ auto tensor_ty_x = GetRef<TensorType>(x);
+ auto tensor_ty_y = GetRef<TensorType>(y);
- if (i < cond_shape.size()) {
- ICHECK(reporter->AssertEQ(cond_shape[i], x_shape[i]))
- << "condition and x must have the same shape: " << cond_shape << "
vs " << x_shape;
- }
- }
- if (x_shape.size() == 0) {
- // if x and y are scalar, the condition shape becomes the output shape
- reporter->Assign(types[3], TensorType(cond_shape, x->dtype));
- } else {
- reporter->Assign(types[3], TensorType(x_shape, x->dtype));
- }
+ auto b_ty = ConcreteBroadcast(tensor_ty_x, tensor_ty_y, x->dtype);
+ auto ret_ty = ConcreteBroadcast(tensor_ty_condition, b_ty, b_ty->dtype);
Review comment:
I see, do we have a test that exercises where shape func?
If not, I don't know how to test this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]