[Mlir-commits] [mlir] bccf27d - [mlir][python] Actually set UseLocalScope printing flag

Stella Laurenzo llvmlistbot at llvm.org
Wed Jun 15 22:03:06 PDT 2022


Author: Mark Browning
Date: 2022-06-15T22:01:34-07:00
New Revision: bccf27d934b312c1a9434b8ba5430ea21f504ffb

URL: https://github.com/llvm/llvm-project/commit/bccf27d934b312c1a9434b8ba5430ea21f504ffb
DIFF: https://github.com/llvm/llvm-project/commit/bccf27d934b312c1a9434b8ba5430ea21f504ffb.diff

LOG: [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

Added: 
    

Modified: 
    mlir/lib/Bindings/Python/IRCore.cpp
    mlir/test/python/ir/operation.py

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp
index 37ca3b953067a..98566ddea2f3f 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -1002,6 +1002,8 @@ void PyOperationBase::print(py::object fileObject, bool binary,
     mlirOpPrintingFlagsEnableDebugInfo(flags, /*prettyForm=*/prettyDebugInfo);
   if (printGenericOpForm)
     mlirOpPrintingFlagsPrintGenericOpForm(flags);
+  if (useLocalScope)
+    mlirOpPrintingFlagsUseLocalScope(flags);
 
   PyFileAccumulator accum(fileObject, binary);
   mlirOperationPrintWithFlags(operation, flags, accum.getCallback(),

diff  --git a/mlir/test/python/ir/operation.py b/mlir/test/python/ir/operation.py
index 489723a6d13d4..b7b47f8bf07c8 100644
--- a/mlir/test/python/ir/operation.py
+++ b/mlir/test/python/ir/operation.py
@@ -535,7 +535,7 @@ def testOperationPrint():
   module = Module.parse(
       r"""
     func.func @f1(%arg0: i32) -> i32 {
-      %0 = arith.constant dense<[1, 2, 3, 4]> : tensor<4xi32>
+      %0 = arith.constant dense<[1, 2, 3, 4]> : tensor<4xi32> loc("nom")
       return %arg0 : i32
     }
   """, ctx)
@@ -562,6 +562,10 @@ def testOperationPrint():
   print(bytes_value.__class__)
   print(bytes_value)
 
+  # Test get_asm local_scope.
+  # CHECK: constant dense<[1, 2, 3, 4]> : tensor<4xi32> loc("nom")
+  module.operation.print(enable_debug_info=True, use_local_scope=True)
+
   # Test get_asm with options.
   # CHECK: value = opaque<"elided_large_const", "0xDEADBEEF"> : tensor<4xi32>
   # CHECK: "func.return"(%arg0) : (i32) -> () -:4:7


        


More information about the Mlir-commits mailing list