Lunderberg commented on a change in pull request #9091:
URL: https://github.com/apache/tvm/pull/9091#discussion_r717957244
##########
File path: src/tir/transforms/storage_flatten.cc
##########
@@ -137,8 +152,15 @@ class BufferShapeLegalize : public StmtExprMutator {
<< "Inconsistent dimensions for buffer " << op->buffer->name;
Array<PrimExpr> new_indices;
- for (size_t i = 0; i < entry.realized_begins.size(); i++) {
- new_indices.push_back(op->indices[i] - entry.realized_begins[i]);
+
+ // Pad leading indices with zero, matching the "fuzzy_match"
+ // behavior from ArgBinder::BindBuffer.
+ size_t diff = entry.realized_begins.size() - op->indices.size();
+ for (size_t i = 0; i < diff; i++) {
+ new_indices.push_back(0);
Review comment:
For the specific case, there is a check as part of the call to
`ArgBinder::BindBuffer`. I'll add a comment to indicate that.
For the general question, that was the intent in `BufferShapeLegalize`, so
that afterwards the buffers all have a single well-defined shape. It looks
like I had missed one case where `BufferBindUnwrapper` changed the number of
dimensions when binding to an external buffer, but I've added another commit to
this PR to pull that behavior into `BufferShapeLegalize` instead.
--
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]