![]() I’d just aim for performance, so avoiding complex checks and data structures. I’m being intentionally vague on the “rules”, this is all up for discussion and I don’t have strong opinions here. If there’s a clean up stage after, not necessarily immediately after, etc etc. Weak ordering would be: a transform pass should be cleaned up afterwards. Passes could register with some properties to be checked, etc. Strong ordering would be: a memref pass should run after “at least one” bufferization pass. This is similar to what LLVM does, but much simpler, so we may get away with a simpler model, too. If passes “knew” they had to pass before/after certain other passes, then we could emit an error at the pipeline construction time. But if it didn’t find it because it was before/after another pass (classic example: bufferization), then it’s an error. Weak/Strong Orderīy construction, if a pass doesn’t find its intended target match, it exists successfully. Pass bundles would solve one problem: it’d make composition more natural by not making it a matter for the user which passes do add in which order, but the API. Or more, we could common analysis/cleanup passes between two consecutive bundles, if neither of them invalidate each other, for example. ![]() But once added to the pass manager, it doesn’t necessarily have to continue as a block. We could even have a class PassBundle that represents a natural sequence of passes that always come together, if necessary. ![]() For example, it’s common to pass canonicalization and CSE after heavier transform passes, so a addCleanupPasses() method would add them both.īut also, and perhaps more importantly, there are passes that should always run together, either to avoid canonicalizations in between, or because of dialect or shape guarantees (without having to pass information through metadata), or to avoid bufferization in between, etc. Methods that add a group of passes that usually go together. The first feature I’d like to add, which is similar to LLVM’s builder, is pass bundles. So, to be clear, this is NOT a proposal for a “New Pass Manager for MLIR”, it’s just for adding a builder pattern to it, and some relaxations to the pipeline to match. At least not at a first approach, so it’s possible one day we’ll get there. Much like LLVM’s alternative, this is something that helps one build a pipeline using pass managers, but unlike LLVM’s, the MLIR version doesn’t need all the complexity of dependencies, intersections, etc. ![]() In the end, every framework or compiler would need to account for every alternative or experiment in order to make use of their dialects and passes. Moreover, due to the nature of MLIR, combining dialects, injecting alternative passes, lowering and side-conversions are not only allowed, but encouraged. Pipeline builder classes end up being more complex and brittle to changes. Compilers can use them in a similar way as LLVM, but the construction of the pipeline becomes more fragmented when radically different decisions are taken at the high level, for example, to target CPUs or GPUs or accelerators, different dialects being present or not, etc. MLIR pipelines are quite different beasts. Compilers are given simple option bundles (like O3 or Oz) and the complexity is then inside the pipeline itself, which takes into account target preferences and some user choices, etc. LLVM’s pipelines are usually very monolithic. MLIR, on the other hand, is more static ( runBefore can’t skip anything) but it has an explicit verification before runAfter steps. LLVM’s new pass manager has a more elaborate, dynamic pipeline, where the runBefore method can skip a pass, and where a set of future dependencies are intersected after each pass. They both allow you to add analysis and transformation passes, they both have a pass instrumentation with runBefore and runAfter methods, they both invalidate analysis and chain the passes together, either via some addPasses function or command line arguments to an opt-like tool. ![]() The need for an outer layer to the pass managerīoth LLVM and MLIR pass managers are reasonably similar in intent. If anyone has a better idea, I’m all ears. Disclaimer: Most of these ideas are still fresh in my mind, I’m not claiming this is the way. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |