[all-commits] [llvm/llvm-project] 310c94: Re-engineer MLIR python build support.

Stella Laurenzo via All-commits all-commits at lists.llvm.org
Tue Jul 27 09:03:15 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 310c9496d80961188e8d8f8ad306cdf44bd7541f
      https://github.com/llvm/llvm-project/commit/310c9496d80961188e8d8f8ad306cdf44bd7541f
  Author: Stella Laurenzo <stellaraccident at gmail.com>
  Date:   2021-07-27 (Tue, 27 Jul 2021)

  Changed paths:
    M mlir/cmake/modules/AddMLIR.cmake
    M mlir/cmake/modules/AddMLIRPython.cmake
    M mlir/docs/Bindings/Python.md
    R mlir/lib/Bindings/CMakeLists.txt
    R mlir/lib/Bindings/Python/CMakeLists.txt
    R mlir/lib/Bindings/Python/Conversions/CMakeLists.txt
    R mlir/lib/Bindings/Python/Transforms/CMakeLists.txt
    M mlir/lib/CMakeLists.txt
    M mlir/python/CMakeLists.txt
    M mlir/python/mlir/_cext_loader.py
    A mlir/python/mlir/_mlir_libs/__init__.py
    R mlir/python/mlir/dialects/CMakeLists.txt
    A mlir/python/mlir/dialects/PythonTest.td
    M mlir/python/mlir/dialects/_builtin_ops_ext.py
    M mlir/python/mlir/dialects/_linalg_ops_ext.py
    M mlir/python/mlir/dialects/linalg/opdsl/lang/emitter.py
    M mlir/test/CMakeLists.txt
    M mlir/test/lit.cfg.py
    R mlir/test/python/CMakeLists.txt
    M mlir/test/python/ir/operation.py

  Log Message:
  -----------
  Re-engineer MLIR python build support.

* Implements all of the discussed features:
  - Links against common CAPI libraries that are self contained.
  - Stops using the 'python/' directory at the root for everything, opening the namespace up for multiple projects to embed the MLIR python API.
  - Separates declaration of sources (py and C++) needed to build the extension from building, allowing external projects to build custom assemblies from core parts of the API.
  - Makes the core python API relocatable (i.e. it could be embedded as something like 'npcomp.ir', 'npcomp.dialects', etc). Still a bit more to do to make it truly isolated but the main structural reset is done.
  - When building statically, installed python packages are completely self contained, suitable for direct setup and upload to PyPi, et al.
  - Lets external projects assemble their own CAPI common runtime library that all extensions use. No more possibilities for TypeID issues.
  - Begins modularizing the API so that external projects that just include a piece pay only for what they use.
* I also rolled in a re-organization of the native libraries that matches how I was packaging these out of tree and is a better layering (i.e. all libraries go into a nested _mlir_libs package). There is some further cleanup that I resisted since it would have required source changes that I'd rather do in a followup once everything stabilizes.
* Note that I made a somewhat odd choice in choosing to recompile all extensions for each project they are included into (as opposed to compiling once and just linking). While not leveraged yet, this will let us set definitions controlling the namespacing of the extensions so that they can be made to not conflict across projects (with preprocessor definitions).
* This will be a relatively substantial breaking change for downstreams. I will handle the npcomp migration and will coordinate with the circt folks before landing. We should stage this and make sure it isn't causing problems before landing.
* Fixed a couple of absolute imports that were causing issues.

Differential Revision: https://reviews.llvm.org/D106520




More information about the All-commits mailing list