This is an archive of the discontinued LLVM Phabricator instance.

[mlir][memref] Add better support for identity layouts in memref.collapse_shape canonicalizer
ClosedPublic

Authored by herhut on Jan 20 2022, 4:22 AM.

Details

Summary

When computing the new type of a collapse_shape operation, we need to at least take into account whether the type has an identity layout, in which case we can easily support dynamic strides. Otherwise, the canonicalizer creates invalid IR.

Longer term, both the verifier and the canoncializer need to be extended to support the general case.

Diff Detail

Event Timeline

herhut created this revision.Jan 20 2022, 4:22 AM
herhut requested review of this revision.Jan 20 2022, 4:22 AM
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
1354–1364

You should short-circuit here, it does not make much sense to pass isIdentityLayout to the isReshapableDimBand.

herhut updated this revision to Diff 401604.Jan 20 2022, 5:03 AM

Pull size checking out of helper.

herhut marked an inline comment as done.Jan 20 2022, 5:05 AM

PTAL

mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
1354–1364

I can do that, too.

bkramer accepted this revision.Jan 20 2022, 6:21 AM

looks good, thanks

This revision is now accepted and ready to land.Jan 20 2022, 6:21 AM