[all-commits] [llvm/llvm-project] 54c998: [mlir][Python] Fix generation of accessors for Opt...

Michal Terepeta via All-commits all-commits at lists.llvm.org
Thu Nov 18 00:43:12 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 54c99842079997b0fe208acdab01e540c0d81b51
      https://github.com/llvm/llvm-project/commit/54c99842079997b0fe208acdab01e540c0d81b51
  Author: Michal Terepeta <michal.terepeta at gmail.com>
  Date:   2021-11-18 (Thu, 18 Nov 2021)

  Changed paths:
    M mlir/python/mlir/dialects/_linalg_ops_ext.py
    M mlir/test/mlir-tblgen/op-python-bindings.td
    M mlir/test/python/dialects/linalg/ops.py
    M mlir/test/python/dialects/python_test.py
    M mlir/test/python/python_test_ops.td
    M mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp

  Log Message:
  -----------
  [mlir][Python] Fix generation of accessors for Optional

Previously, in case there was only one `Optional` operand/result within
the list, we would always return `None` from the accessor, e.g., for a
single optional result we would generate:

```
return self.operation.results[0] if len(self.operation.results) > 1 else None
```

But what we really want is to return `None` only if the length of
`results` is smaller than the total number of element groups (i.e.,
the optional operand/result is in fact missing).

This commit also renames a few local variables in the generator to make
the distinction between `isVariadic()` and `isVariableLength()` a bit
more clear.

Reviewed By: ftynse

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




More information about the All-commits mailing list