This is an archive of the discontinued LLVM Phabricator instance.

Fix CollapsedLayoutMap for dim size 1 case
ClosedPublic

Authored by cathyzhyi on Apr 20 2022, 6:07 PM.

Details

Summary

This change fixes CollapsedLayoutMap for cases where the collapsed
dims are size 1. The cases where inner most dims are size 1 and
noncontiguous can be represented by the strided form and therefore can
be allowed. For such cases, the new stride should be of the next entry
in an association whose dimension is not size 1. If the next entry is
dynamic, it's not possible to decide which stride to use at compilation
time and the stride is set to dynamic.

Diff Detail

Event Timeline

cathyzhyi created this revision.Apr 20 2022, 6:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2022, 6:07 PM
cathyzhyi requested review of this revision.Apr 20 2022, 6:07 PM
springerm accepted this revision.Apr 22 2022, 4:09 AM

nice!

mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
1826–1832

Nit: I would rewrite it as follows:

The result stride of a reassociation group is the stride of the last entry of the reassociation. (TODO: Should be the minimum stride in the reassociation because strides are not necessarily sorted. E.g., when using memref.transpose.) Dimensions of size 1 should be skipped, because their strides are meaningless and could have any arbitrary value.
1841

Nit: add a comment:

Dynamically-sized dims may turn out to be dims of size 1 at runtime, so the corresponding stride may have to be skipped. (See above comment.) Therefore, the result stride cannot be statically determined and must be dynamic.
mlir/test/Dialect/Tensor/bufferize.mlir
374

these must be func.func now

This revision is now accepted and ready to land.Apr 22 2022, 4:09 AM
cathyzhyi updated this revision to Diff 424475.Apr 22 2022, 7:34 AM

Address comments

cathyzhyi updated this revision to Diff 424620.Apr 22 2022, 2:41 PM

Fix test cases

This revision was landed with ongoing or failed builds.Apr 22 2022, 2:49 PM
This revision was automatically updated to reflect the committed changes.