[mlir] Add SubViewOp::getOrCreateRanges and fix folding pattern
authorNicolas Vasilache <ntv@google.com>
Wed, 13 May 2020 02:21:36 +0000 (22:21 -0400)
committerNicolas Vasilache <ntv@google.com>
Wed, 13 May 2020 14:11:30 +0000 (10:11 -0400)
commite0b99a5de4cbf00bfa46d06caf1ebf64a6456537
treeb8e9d530999c2988bb15ba005ca5f8d0d74f7d92
parent195de442daba5ae1754528eb2869ca50c3af2669
[mlir] Add SubViewOp::getOrCreateRanges and fix folding pattern

The existing implementation of SubViewOp::getRanges relies on all
offsets/sizes/strides to be dynamic values and does not work in
combination with canonicalization. This revision adds a
SubViewOp::getOrCreateRanges to create the missing constants in the
canonicalized case.

This allows reactivating the fused pass with staged pattern
applications.

However another issue surfaces that the SubViewOp verifier is now too
strict to allow folding. The existing folding pattern is turned into a
canonicalization pattern which rewrites memref_cast + subview into
subview + memref_cast.

The transform-patterns-matmul-to-vector can then be reactivated.

Differential Revision: https://reviews.llvm.org/D79759
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
mlir/test/Dialect/Linalg/transform-patterns-matmul-to-vector.mlir
mlir/test/Transforms/canonicalize.mlir