[all-commits] [llvm/llvm-project] f431d3: Make Python MLIR Operation not iterable

Mehdi Amini via All-commits all-commits at lists.llvm.org
Tue Oct 26 00:21:30 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f431d3878a07a67e544dacb98ad553b6a0b6b25a
      https://github.com/llvm/llvm-project/commit/f431d3878a07a67e544dacb98ad553b6a0b6b25a
  Author: Mehdi Amini <joker.eph at gmail.com>
  Date:   2021-10-26 (Tue, 26 Oct 2021)

  Changed paths:
    M mlir/lib/Bindings/Python/IRCore.cpp
    M mlir/python/mlir/dialects/_builtin_ops_ext.py
    M mlir/python/mlir/dialects/_ods_common.py
    M mlir/test/python/dialects/builtin.py
    M mlir/test/python/dialects/math.py
    M mlir/test/python/ir/operation.py

  Log Message:
  -----------
  Make Python MLIR Operation not iterable

The current behavior is conveniently allowing to iterate on the regions of an operation
implicitly by exposing an operation as Iterable. However this is also error prone and
code that may intend to iterate on the results or the operands could end up "working"
apparently instead of throwing a runtime error.
The lack of static type checking in Python contributes to the ambiguity here, it seems
safer to not do this and require and explicit qualification to iterate (`op.results`, `op.regions`, ...).

Reviewed By: ftynse

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




More information about the All-commits mailing list