diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp --- a/mlir/lib/Bindings/Python/IRCore.cpp +++ b/mlir/lib/Bindings/Python/IRCore.cpp @@ -839,6 +839,8 @@ mlirOpPrintingFlagsEnableDebugInfo(flags, /*prettyForm=*/prettyDebugInfo); if (printGenericOpForm) mlirOpPrintingFlagsPrintGenericOpForm(flags); + if (useLocalScope) + mlirOpPrintingFlagsUseLocalScope(flags); PyFileAccumulator accum(fileObject, binary); py::gil_scoped_release(); diff --git a/mlir/test/python/ir/operation.py b/mlir/test/python/ir/operation.py --- a/mlir/test/python/ir/operation.py +++ b/mlir/test/python/ir/operation.py @@ -487,7 +487,7 @@ ctx = Context() module = Module.parse(r""" func @f1(%arg0: i32) -> i32 { - %0 = constant dense<[1, 2, 3, 4]> : tensor<4xi32> + %0 = constant dense<[1, 2, 3, 4]> : tensor<4xi32> loc("nom") return %arg0 : i32 } """, ctx) @@ -514,6 +514,11 @@ print(bytes_value.__class__) print(bytes_value) + # Test get_asm local_scope. + # CHECK: constant opaque<"_", "0xDEADBEEF"> : tensor<4xi32> loc("nom") + module.operation.print(large_elements_limit=2, enable_debug_info=True, + use_local_scope=True) + # Test get_asm with options. # CHECK: value = opaque<"_", "0xDEADBEEF"> : tensor<4xi32> # CHECK: "std.return"(%arg0) : (i32) -> () -:4:7