[all-commits] [llvm/llvm-project] 029e19: [mlir] Make attributes mutable in Python bindings

ftynse via All-commits all-commits at lists.llvm.org
Tue Nov 24 00:16:45 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 029e199dbfd394c7a3c372a632a4ddac6b591648
      https://github.com/llvm/llvm-project/commit/029e199dbfd394c7a3c372a632a4ddac6b591648
  Author: Alex Zinenko <zinenko at google.com>
  Date:   2020-11-24 (Tue, 24 Nov 2020)

  Changed paths:
    M mlir/lib/Bindings/Python/IRModules.cpp
    A mlir/test/Bindings/CMakeLists.txt
    A mlir/test/Bindings/Python/CMakeLists.txt
    A mlir/test/Bindings/Python/dialects/python_test.py
    M mlir/test/Bindings/Python/lit.local.cfg
    A mlir/test/Bindings/Python/python_test_ops.td
    M mlir/test/CMakeLists.txt
    M mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp

  Log Message:
  -----------
  [mlir] Make attributes mutable in Python bindings

Attributes represent additional data about an operation and are intended to be
modifiable during the lifetime of the operation. In the dialect-specific Python
bindings, attributes are exposed as properties on the operation class. Allow
for assigning values to these properties. Also support creating new and
deleting existing attributes through the generic "attributes" property of an
operation. Any validity checking must be performed by the op verifier after the
mutation, similarly to C++. Operations are not invalidated in the process: no
dangling pointers can be created as all attributes are owned by the context and
will remain live even if they are not used in any operation.

Introduce a Python Test dialect by analogy with the Test dialect and to avoid
polluting the latter with Python-specific constructs. Use this dialect to
implement a test for the attribute access and mutation API.

Reviewed By: stellaraccident, mehdi_amini

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




More information about the All-commits mailing list