[all-commits] [llvm/llvm-project] b947e1: [mlir][python] stop initialization on ImportError

Ashay Rane via All-commits all-commits at lists.llvm.org
Wed Sep 28 20:02:43 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b947e15a577f72284d69d077cfdb2d3f211abe65
      https://github.com/llvm/llvm-project/commit/b947e15a577f72284d69d077cfdb2d3f211abe65
  Author: Ashay Rane <ashay at users.noreply.github.com>
  Date:   2022-09-29 (Thu, 29 Sep 2022)

  Changed paths:
    M mlir/python/mlir/_mlir_libs/__init__.py

  Log Message:
  -----------
  [mlir][python] stop initialization on ImportError

An `_mlirRegisterEverything.*.so` file from an old build that referenced
`MLIRPythonExtension.RegisterEverything`, but which no longer references
that extension in a new build, causes runtime errors in the new build
like:

    ImportError: _mlirRegisterEverything.cpython-38-x86_64-linux-gnu.so: undefined symbol: mlirRegisterAllPasses

The error occurs because the MLIR Python binding tries to dynamically
import the `_mlirRegisterEverything` module but the dynamic importer
fails since the new build no longer references
`MLIRPythonExtension.RegisterEverything`.

One possible solution is for the user to manually remove the
`_mlirRegisterEverything.*.so` file.  This patch instead resolves the
problem in code by printing a waning if the module cannot be
imported.

Reviewed By: stellaraccident

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




More information about the All-commits mailing list