[all-commits] [llvm/llvm-project] ed9e52: [mlir][python] Usability improvements for Python b...

ftynse via All-commits all-commits at lists.llvm.org
Mon Oct 4 02:45:42 PDT 2021


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

  Changed paths:
    M mlir/lib/Bindings/Python/IRAttributes.cpp
    M mlir/lib/Bindings/Python/IRCore.cpp
    M mlir/test/python/ir/attributes.py
    M mlir/test/python/ir/operation.py

  Log Message:
  -----------
  [mlir][python] Usability improvements for Python bindings

Provide a couple of quality-of-life usability improvements for Python bindings,
in particular:

  * give access to the list of types for the list of op results or block
    arguments, similarly to ValueRange->TypeRange,

  * allow for constructing empty dictionary arrays,

  * support construction of array attributes by concatenating an existing
    attribute with a Python list of attributes.

All these are required for the upcoming customization of builtin and standard
ops.

Reviewed By: stellaraccident

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


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

  Changed paths:
    M mlir/python/CMakeLists.txt
    A mlir/python/mlir/dialects/_std_ops_ext.py
    A mlir/test/python/dialects/std.py

  Log Message:
  -----------
  [mlir][python] Provide more convenient wrappers for std.ConstantOp

Constructing a ConstantOp using the default-generated API is verbose and
requires to specify the constant type twice: for the result type of the
operation and for the type of the attribute. It also requires to explicitly
construct the attribute. Provide custom constructors that take the type once
and accept a raw value instead of the attribute. This requires dynamic dispatch
based on type in the constructor. Also provide the corresponding accessors to
raw values.

In addition, provide a "refinement" class ConstantIndexOp similar to what
exists in C++. Unlike other "op view" Python classes, operations cannot be
automatically downcasted to this class since it does not correspond to a
specific operation name. It only exists to simplify construction of the
operation.

Depends On D110946

Reviewed By: stellaraccident

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


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

  Changed paths:
    M mlir/python/mlir/dialects/_builtin_ops_ext.py
    M mlir/python/mlir/dialects/_std_ops_ext.py
    M mlir/test/python/dialects/builtin.py
    M mlir/test/python/dialects/std.py

  Log Message:
  -----------
  [mlir][python] Provide more convenient constructors for std.CallOp

The new constructor relies on type-based dynamic dispatch and allows one to
construct call operations given an object representing a FuncOp or its name as
a string, as opposed to requiring an explicitly constructed attribute.

Depends On D110947

Reviewed By: stellaraccident

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


Compare: https://github.com/llvm/llvm-project/compare/c7bd6435993f...255a690971cb


More information about the All-commits mailing list