This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Linalg] Introduce folding patterns to remove certain MemRefCastOp
AbandonedPublic

Authored by nicolasvasilache on Jan 28 2020, 10:46 AM.

Details

Summary

Canonicalization and folding patterns in StandardOps may interfere with the needs
of Linalg. This revision introduces specific foldings for dynamic memrefs that can
be proven to be static.

Very concretely:

Determines whether it is possible to fold it away in the parent Linalg op:

mlir
  %1 = memref_cast %0 : memref<8x16xf32> to memref<?x?xf32>
  %2 = linalg.slice %1 ... : memref<?x?xf32> ...
  // or
  %1 = memref_cast %0 : memref<8x16xf32, affine_map<(i, j)->(16 * i + j)>>
         to memref<?x?xf32>
  linalg.generic(%1 ...) : memref<?x?xf32> ...

into

mlir
  %2 = linalg.slice %0 ... : memref<8x16xf32> ...
  // or
  linalg.generic(%0 ... : memref<8x16xf32, affine_map<(i, j)->(16 * i + j)>>

Diff Detail

Event Timeline

Unit tests: fail. 62196 tests passed, 1 failed and 815 were skipped.

failed: MLIR.mlir-cpu-runner/unranked_memref.mlir

clang-tidy: pass.

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

nicolasvasilache abandoned this revision.Jan 28 2020, 12:16 PM

I messed up with arc, abandonning this one, sigh