[mlir] Normalize dynamic memrefs with a map of tiled-layout.
authorHaruki Imai <imaihal@jp.ibm.com>
Mon, 24 May 2021 03:04:45 +0000 (08:34 +0530)
committerUday Bondhugula <uday@polymagelabs.com>
Mon, 24 May 2021 03:09:36 +0000 (08:39 +0530)
commit000a05fd1ab33329f7ef2dd85a3f027a7d0c3a4b
treeb358ca8a8b53322584825a64aaca1bff7cd5f936
parente93ac1e2de66e8feae3cec3b6c0707b14c79dfeb
[mlir] Normalize dynamic memrefs with a map of tiled-layout.

Steps for normalizing dynamic memrefs for tiled layout map
1. Check if original map is tiled layout. Only tiled layout is supported.
2. Create normalized memrefType. Dimensions that include dynamic dimensions
   in the map output will be dynamic dimensions.
3. Create new maps to calculate each dimension size of new memref.
   In tiled layout, the dimension size can be calculated by replacing
    "floordiv <tile size>" with "ceildiv <tile size>" and
    "mod <tile size>" with "<tile size>".
4. Create AffineApplyOp to apply the new maps. The output of AffineApplyOp is
   dynamicSizes for new AllocOp.
5. Add the new dynamic sizes in new AllocOp.

This patch also set MemRefsNormalizable trant in CastOp and DimOp since
they used with dynamic memrefs.

Reviewed By: bondhugula

Differential Revision: https://reviews.llvm.org/D97655
mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
mlir/include/mlir/Transforms/Passes.td
mlir/lib/Transforms/PassDetail.h
mlir/lib/Transforms/Utils/Utils.cpp
mlir/test/Transforms/normalize-memrefs-ops-dynamic.mlir [new file with mode: 0644]