Page MenuHomePhabricator

[mlir][EDSC] Almost NFC - Refactor and untangle EDSC dependencies
ClosedPublic

Authored by nicolasvasilache on Sun, Feb 9, 8:50 PM.

Details

Summary

This CL refactors EDSCs to layer them better and break unnecessary
dependencies. After this refactoring, the top-level EDSC target only
depends on IR but not on Dialects anymore and each dialect has its
own EDSC directory.

This simplifies the layering and breaks cyclic dependencies.
In particular, the declarative builder + folder are made explicit and
are now confined to Linalg.

As the refactoring occurred, certain classes and abstractions that were not
paying for themselves have been removed.

Diff Detail

Event Timeline

Any reason this couldn't have been split into multi revisions? e.g. one per dialect?

mlir/include/mlir/Dialect/AffineOps/EDSC/Builders.h
59

///

mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h
23

Drop newline.

28

nit: Remove the newlines.

mlir/include/mlir/Dialect/Linalg/EDSC/Intrinsics.h
17–27

nit: Drop the newline.

mlir/include/mlir/Dialect/StandardOps/EDSC/Builders.h
20

///

mlir/include/mlir/EDSC/Builders.h
517

We should be able to remove these.

@rriddle I did not see a simple way to untangle things and once I got things working I did not look back.
For instance, dropping dependencies from EDSC onto LoopOps and AffineOps requires extracting the makeLoopBuilder into a free function.
The only place where it makes sense to put this is in the loop dialect.
There are a bunch of similar cases.
At which point I don't see a reasonable way to split this up.

nicolasvasilache marked 6 inline comments as done.

Address review comments.

ftynse requested changes to this revision.Mon, Feb 10, 7:48 AM

cmake seems broken

CMake Error at ~/llvm-project/llvm/cmake/modules/AddLLVM.cmake:493 (add_library):
  Cannot find source file:

    Helpers.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx
Call Stack (most recent call first):
  ~/llvm-project/llvm/cmake/modules/AddLLVM.cmake:704 (llvm_add_library)
  ~/llvm-project/mlir/lib/EDSC/CMakeLists.txt:8 (add_llvm_library)
This revision now requires changes to proceed.Mon, Feb 10, 7:48 AM

Layering-wise, this makes sense to me. EDSC is a utility library, similar to IR, and should not depend on an ever-growing set of dialects, rather the inverse.

I don't understand why the folder-related part is located under Linalg/, it does not look too specific to it ?

mlir/include/mlir/Dialect/Linalg/EDSC/Intrinsics.h
17

This looks generally useful, any reason why it's under Linalg/ ?

mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
40

Shouldn't this rather be in StandardOps/EDSC/Intrinsics?

nicolasvasilache marked 3 inline comments as done.

Address review comments, revive CMake changes.

cmake seems broken

The joys of cross-toolchain edit and updates, should be fixed now (at least it runs locally).

mlir/include/mlir/Dialect/Linalg/EDSC/Intrinsics.h
17

The folder depends on FoldUtils which depends on StandardOps.
Splitting it out of EDSC is necessary, since Linalg is the only user for now I put it here to untangle for now.
Moved it to StandardOps for now but until FoldUtils drops the dependence (if possible?) it can't go at the top level.

ftynse accepted this revision.Mon, Feb 10, 9:04 AM
ftynse added inline comments.
mlir/include/mlir/Dialect/Linalg/EDSC/Intrinsics.h
17

Let's have a ticket for this.

This revision is now accepted and ready to land.Mon, Feb 10, 9:04 AM
This revision was automatically updated to reflect the committed changes.