masahi commented on a change in pull request #9996:
URL: https://github.com/apache/tvm/pull/9996#discussion_r810773090
##########
File path: include/tvm/topi/transform.h
##########
@@ -1608,7 +1608,11 @@ inline Tensor layout_transform(const Tensor& src, const
std::string& src_layout,
[&](const Array<Var>& dst_indices) {
Array<PrimExpr> dst_indices_expr(dst_indices.begin(),
dst_indices.end());
Array<PrimExpr> src_indices =
layout_converter.BackwardIndex(dst_indices_expr);
- return src(src_indices);
+ PrimExpr in_range = PrimExpr(1) > PrimExpr(0); // init with
dtype=bool and value=true
+ for (size_t i = 0; i < src.ndim(); ++i) {
+ in_range = in_range && (src_indices[i] < src->shape[i]);
+ }
+ return if_then_else(in_range, src(src_indices), tvm::cast(src->dtype,
PrimExpr(0)));
Review comment:
Why do you need this change? Returning 0 for out of bounds doesn't seem
right to me... Is there a "valid" out of bounds for which returning 0 is the
right thing to do?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]