Fix Linalg lowering to loops
authorNicolas Vasilache <ntv@google.com>
Thu, 23 May 2019 14:00:18 +0000 (07:00 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Sun, 2 Jun 2019 02:57:54 +0000 (19:57 -0700)
commitc0f41e5bb3d615f35c7708992304bb989929cdb1
tree64a4328212dcc0db86d18c66084017391da03aaf
parent6a31f9a7e34874667291b7eb38d41bd1849f315f
Fix Linalg lowering to loops

    This CL makes lowering to loops always be a:
    ```
    %D = linalg.dim %view, constant : !linalg.view<...>
    affine.for %ix = %c0 to %D {
      ...
    }
    ```

    This form composes correctly with tiling and is also the proper way to emit loops from views that across function boundaries.
    The previous version that would extract the range_min/max/step was composing incorrectly with tiling (i.e. would shift by range_min both in the loop bounds and in the slice) and would not work across function boundaries.

    The relevant tests are updated and a new test `dot_view`---which lowers to loops from views passed as function parameters---is added.

    When additional context is available, the linalg.dim operations should be folded away but this is left for a future CL.

--

PiperOrigin-RevId: 249634712
mlir/include/mlir/Linalg/IR/LinalgOps.h
mlir/include/mlir/Linalg/Utils/Utils.h
mlir/lib/Linalg/Transforms/LowerToLoops.cpp
mlir/lib/Linalg/Utils/Utils.cpp
mlir/test/Linalg/loops.mlir