Skip to content

Commit b2bdc45

Browse files
committed
[mlir][python] Fix possible use of variable use before set
The _mlirRegisterEverything symbol may not be built by some customers. The code here was intended to support this, but didn't properly initialize the init_module variable. This would break JAX with: NameError: free variable 'init_module' referenced before assignment in enclosing scope
1 parent a3ee0d4 commit b2bdc45

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

mlir/python/mlir/_mlir_libs/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def process_initializer_module(module_name):
8383

8484
# If _mlirRegisterEverything is built, then include it as an initializer
8585
# module.
86+
init_module = None
8687
if process_initializer_module("_mlirRegisterEverything"):
8788
init_module = importlib.import_module(f"._mlirRegisterEverything", __name__)
8889

0 commit comments

Comments
 (0)