yangulei commented on a change in pull request #9996:
URL: https://github.com/apache/tvm/pull/9996#discussion_r810778133
##########
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:
This is similar to zero padding. For example, when a tensor with shape=[
64, 3, 7, 7, ] is going to be transformed from "OIHW" to "OHWI16o2i", it's new
shape=[ 4, 7, 7, **2**, 16, **2**, ], which is bigger then the original tensor
in total.
--
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]