[all-commits] [llvm/llvm-project] 14c920: [mlir] support interfaces in Python bindings

ftynse via All-commits all-commits at lists.llvm.org
Mon Oct 25 03:50:58 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 14c9207063bb00823a5126131e50c93f6e288bd3
      https://github.com/llvm/llvm-project/commit/14c9207063bb00823a5126131e50c93f6e288bd3
  Author: Alex Zinenko <zinenko at google.com>
  Date:   2021-10-25 (Mon, 25 Oct 2021)

  Changed paths:
    M mlir/CMakeLists.txt
    M mlir/docs/Bindings/Python.md
    M mlir/docs/CAPI.md
    A mlir/include/mlir-c/Interfaces.h
    A mlir/include/mlir/CAPI/Interfaces.h
    A mlir/lib/Bindings/Python/IRInterfaces.cpp
    M mlir/lib/Bindings/Python/IRModule.h
    M mlir/lib/Bindings/Python/MainModule.cpp
    M mlir/lib/CAPI/CMakeLists.txt
    A mlir/lib/CAPI/Interfaces/CMakeLists.txt
    A mlir/lib/CAPI/Interfaces/Interfaces.cpp
    M mlir/python/CMakeLists.txt
    R mlir/python/mlir/dialects/PythonTest.td
    M mlir/python/mlir/dialects/python_test.py
    M mlir/test/CMakeLists.txt
    A mlir/test/python/CMakeLists.txt
    M mlir/test/python/dialects/python_test.py
    A mlir/test/python/lib/CMakeLists.txt
    A mlir/test/python/lib/PythonTestCAPI.cpp
    A mlir/test/python/lib/PythonTestCAPI.h
    A mlir/test/python/lib/PythonTestDialect.cpp
    A mlir/test/python/lib/PythonTestDialect.h
    A mlir/test/python/lib/PythonTestModule.cpp
    M mlir/test/python/python_test_ops.td
    M utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

  Log Message:
  -----------
  [mlir] support interfaces in Python bindings

Introduce the initial support for operation interfaces in C API and Python
bindings. Interfaces are a key component of MLIR's extensibility and should be
available in bindings to make use of full potential of MLIR.

This initial implementation exposes InferTypeOpInterface all the way to the
Python bindings since it can be later used to simplify the operation
construction methods by inferring their return types instead of requiring the
user to do so. The general infrastructure for binding interfaces is defined and
InferTypeOpInterface can be used as an example for binding other interfaces.

Reviewed By: gysit

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


  Commit: 2995d29bb42729043e707161bd7a7e4e428afbcf
      https://github.com/llvm/llvm-project/commit/2995d29bb42729043e707161bd7a7e4e428afbcf
  Author: Alex Zinenko <zinenko at google.com>
  Date:   2021-10-25 (Mon, 25 Oct 2021)

  Changed paths:
    M mlir/include/mlir/TableGen/Operator.h
    M mlir/lib/Bindings/Python/IRModule.h
    M mlir/python/mlir/dialects/linalg/opdsl/lang/emitter.py
    M mlir/test/mlir-tblgen/op-python-bindings.td
    M mlir/test/python/dialects/math.py
    M mlir/test/python/dialects/python_test.py
    M mlir/test/python/dialects/shape.py
    M mlir/test/python/ir/dialects.py
    M mlir/test/python/python_test_ops.td
    M mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp

  Log Message:
  -----------
  [mlir][python] Infer result types in generated constructors whenever possible

In several cases, operation result types can be unambiguously inferred from
operands and attributes at operation construction time. Stop requiring the user
to provide these types as arguments in the ODS-generated constructors in Python
bindings. In particular, handle the SameOperandAndResultTypes and
FirstAttrDerivedResultType traits as well as InferTypeOpInterface using the
recently added interface support. This is a significant usability improvement
for IR construction, similar to what C++ ODS provides.

Depends On D111656

Reviewed By: gysit

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


Compare: https://github.com/llvm/llvm-project/compare/1f49b71fe5fa...2995d29bb427


More information about the All-commits mailing list