[all-commits] [llvm/llvm-project] 7abb0f: Add Operation to python bindings.

Stella Laurenzo via All-commits all-commits at lists.llvm.org
Wed Sep 23 07:59:12 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 7abb0ff7e0419a9554d77e9108cb7da670b7471c
      https://github.com/llvm/llvm-project/commit/7abb0ff7e0419a9554d77e9108cb7da670b7471c
  Author: Stella Laurenzo <stellaraccident at gmail.com>
  Date:   2020-09-23 (Wed, 23 Sep 2020)

  Changed paths:
    M mlir/docs/Bindings/Python.md
    M mlir/lib/Bindings/Python/IRModules.cpp
    M mlir/lib/Bindings/Python/IRModules.h
    M mlir/test/Bindings/Python/ir_attributes.py
    M mlir/test/Bindings/Python/ir_location.py
    M mlir/test/Bindings/Python/ir_module.py
    M mlir/test/Bindings/Python/ir_operation.py
    M mlir/test/Bindings/Python/ir_types.py

  Log Message:
  -----------
  Add Operation to python bindings.

* Fixes a rather egregious bug with respect to the inability to return arbitrary objects from py::init (was causing aliasing of multiple py::object -> native instance).
* Makes Modules and Operations referencable types so that they can be reliably depended on.
* Uniques python operation instances within a context. Opens the door for further accounting.
* Next I will retrofit region and block to be dependent on the operation, and I will attempt to model the API to avoid detached regions/blocks, which will simplify things a lot (in that world, only operations can be detached).
* Added quite a bit of test coverage to check for leaks and reference issues.
* Supercedes: https://reviews.llvm.org/D87213

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


  Commit: 4cf754c4bca94e957b634a854f57f4c7ec9151fb
      https://github.com/llvm/llvm-project/commit/4cf754c4bca94e957b634a854f57f4c7ec9151fb
  Author: Stella Laurenzo <stellaraccident at gmail.com>
  Date:   2020-09-23 (Wed, 23 Sep 2020)

  Changed paths:
    M mlir/include/mlir-c/IR.h
    M mlir/lib/Bindings/Python/IRModules.cpp
    M mlir/lib/Bindings/Python/IRModules.h
    M mlir/lib/CAPI/IR/CMakeLists.txt
    M mlir/lib/CAPI/IR/IR.cpp
    M mlir/test/Bindings/Python/ir_operation.py

  Log Message:
  -----------
  Implement python iteration over the operation/region/block hierarchy.

* Removes the half-completed prior attempt at region/block mutation in favor of new approach to ownership.
* Will re-add mutation more correctly in a follow-on.
* Eliminates the detached state on blocks and regions, simplifying the ownership hierarchy.
* Adds both iterator and index based access at each level.

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


  Commit: c1ded6a759913a32b44a851f0823bbb648d2a7e1
      https://github.com/llvm/llvm-project/commit/c1ded6a759913a32b44a851f0823bbb648d2a7e1
  Author: Stella Laurenzo <stellaraccident at gmail.com>
  Date:   2020-09-23 (Wed, 23 Sep 2020)

  Changed paths:
    M mlir/lib/Bindings/Python/IRModules.cpp
    M mlir/lib/Bindings/Python/IRModules.h
    M mlir/lib/Bindings/Python/PybindUtils.h
    M mlir/test/Bindings/Python/ir_operation.py

  Log Message:
  -----------
  Add mlir python APIs for creating operations, regions and blocks.

* The API is a bit more verbose than I feel like it needs to be. In a follow-up I'd like to abbreviate some things and look in to creating aliases for common accessors.
* There is a lingering lifetime hazard between the module and newly added operations. We have the facilities now to solve for this but I will do that in a follow-up.
* We may need to craft a more limited API for safely referencing successors when creating operations. We need more facilities to really prove that out and should defer for now.

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


Compare: https://github.com/llvm/llvm-project/compare/bd8b50cd7f5d...c1ded6a75991


More information about the All-commits mailing list