[Mlir-commits] [mlir] [mlir] Python: Parse ModuleOp from file path (PR #125736)
Maksim Levental
llvmlistbot at llvm.org
Tue Feb 4 16:30:12 PST 2025
================
@@ -27,6 +29,24 @@ def testParseSuccess():
print(str(module))
+# Verify successful parse from file.
+# CHECK-LABEL: TEST: testParseFromFileSuccess
+# CHECK: module @successfulParse
+ at run
+def testParseFromFileSuccess():
+ ctx = Context()
+ with NamedTemporaryFile(mode="w") as tmp_file:
+ tmp_file.write(r"""module @successfulParse {}""")
+ tmp_file.flush()
+ module = Module.parse(Path(tmp_file.name), ctx)
+ assert module.context is ctx
+ print("CLEAR CONTEXT")
+ ctx = None # Ensure that module captures the context.
+ gc.collect()
+ module.dump() # Just outputs to stderr. Verifies that it functions.
----------------
makslevental wrote:
You can just do print(module) to print to stdout
https://github.com/llvm/llvm-project/pull/125736
More information about the Mlir-commits
mailing list