Skip to content

Commit bccf27d

Browse files
Mark BrowningStella Laurenzo
authored andcommitted
[mlir][python] Actually set UseLocalScope printing flag
The useLocalScope printing flag has been passed around between pybind methods, but doesn't actually enable the corresponding printing flag. Reviewed By: stellaraccident Differential Revision: https://reviews.llvm.org/D127907
1 parent 401a425 commit bccf27d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

mlir/lib/Bindings/Python/IRCore.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,8 @@ void PyOperationBase::print(py::object fileObject, bool binary,
10021002
mlirOpPrintingFlagsEnableDebugInfo(flags, /*prettyForm=*/prettyDebugInfo);
10031003
if (printGenericOpForm)
10041004
mlirOpPrintingFlagsPrintGenericOpForm(flags);
1005+
if (useLocalScope)
1006+
mlirOpPrintingFlagsUseLocalScope(flags);
10051007

10061008
PyFileAccumulator accum(fileObject, binary);
10071009
mlirOperationPrintWithFlags(operation, flags, accum.getCallback(),

mlir/test/python/ir/operation.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ def testOperationPrint():
535535
module = Module.parse(
536536
r"""
537537
func.func @f1(%arg0: i32) -> i32 {
538-
%0 = arith.constant dense<[1, 2, 3, 4]> : tensor<4xi32>
538+
%0 = arith.constant dense<[1, 2, 3, 4]> : tensor<4xi32> loc("nom")
539539
return %arg0 : i32
540540
}
541541
""", ctx)
@@ -562,6 +562,10 @@ def testOperationPrint():
562562
print(bytes_value.__class__)
563563
print(bytes_value)
564564

565+
# Test get_asm local_scope.
566+
# CHECK: constant dense<[1, 2, 3, 4]> : tensor<4xi32> loc("nom")
567+
module.operation.print(enable_debug_info=True, use_local_scope=True)
568+
565569
# Test get_asm with options.
566570
# CHECK: value = opaque<"elided_large_const", "0xDEADBEEF"> : tensor<4xi32>
567571
# CHECK: "func.return"(%arg0) : (i32) -> () -:4:7

0 commit comments

Comments
 (0)