Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
masahi committed Sep 2, 2020
1 parent cedfabe commit 7e88b6d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/relay/op/tensor/transform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1664,6 +1664,7 @@ bool WhereRel(const Array<Type>& types, int num_inputs, const Attrs& attrs,
}
}
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));
Expand Down Expand Up @@ -1699,6 +1700,9 @@ size is the same as x’s first dimension size. Each row of the output array
is from x’s row if the corresponding element from condition is true, and
from y’s row if false.
When x and y are scalars, condition must be an 1D array. The output shape
is the same as condition's shape.
Note that all non-zero values are interpreted as True in condition.
Examples::
Expand All @@ -1712,6 +1716,9 @@ Examples::
cond = [1, 0]
where(cond, x, y) = [[1, 2], [7, 8]]
cond = [0, 1]
where(cond, 1, -1) = [-1, 1]
)code" TVM_ADD_FILELINE)
.add_argument("condition", "Tensor", "Condition array")
.add_argument("x", "Tensor", "First array to be selected")
Expand Down

0 comments on commit 7e88b6d

Please sign in to comment.