This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Tensor] Add a FoldTensorSubsetOps pass and patterns
ClosedPublic

Authored by nicolasvasilache on Mar 22 2023, 5:04 AM.

Details

Summary

These patterns follow FoldMemRefAliasOps which is further refactored for reuse.
In the process, fix FoldMemRefAliasOps handling of strides for vector.transfer ops which was previously incorrect.

These opt-in patterns generalize the existing canonicalizations on vector.transfer ops.
In the future the blanket canonicalizations will be retired.
They are kept for now to minimize porting disruptions.

Diff Detail

Event Timeline

Herald added a reviewer: aartbik. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
nicolasvasilache requested review of this revision.Mar 22 2023, 5:04 AM
Herald added a project: Restricted Project. · View Herald Transcript

@springerm please note the comments around deprecating canonicalization patterns, these have impacts on bufferization and I expect we'll need to test and relayer things properly to avoid spurious copies.

nicolasvasilache edited the summary of this revision. (Show Details)

Rebase.

springerm accepted this revision.Mar 23 2023, 2:37 AM
springerm added inline comments.
mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td
861

omitted

862

extended

mlir/include/mlir/Dialect/Tensor/Transforms/Passes.h
21–25

These should be in Tensor/Transforms/Transforms.h

mlir/include/mlir/Dialect/Tensor/Transforms/Passes.td
17

Can you put an example here what is folded.

mlir/include/mlir/Dialect/Tensor/Utils/ViewLikeInterfaceUtils.h
26 ↗(On Diff #507327)

nit: operating on

27–28 ↗(On Diff #507327)

nit: maybe just combined indices

34 ↗(On Diff #507327)

[...]

39 ↗(On Diff #507327)

could be

45–47 ↗(On Diff #507327)

This could take an AffineMap &map and SmallVector<Value> &mapOperands as output arguments. Instead of building IR it would populate the those two args, then it could be part of an interview. I used the same trick in ValueBoundsOpInterface. (The caller has to create the affine op then.)

48 ↗(On Diff #507327)

The implementation always returns success, so the return type can be void.

mlir/lib/Dialect/MemRef/Transforms/FoldMemRefAliasOps.cpp
326

remove?

mlir/lib/Dialect/Tensor/Transforms/FoldTensorSubsetOps.cpp
78

remove

This revision is now accepted and ready to land.Mar 23 2023, 2:37 AM
nicolasvasilache marked 12 inline comments as done.

Address comments.

This revision was landed with ongoing or failed builds.Mar 23 2023, 4:03 AM
This revision was automatically updated to reflect the committed changes.