We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 82cbdf3 commit ff8b42fCopy full SHA for ff8b42f
mlir/extras/context.py
@@ -112,6 +112,24 @@ def __str__(self):
112
return str(self.module)
113
114
115
+@contextmanager
116
+def mlir_mod(
117
+ src: Optional[str] = None,
118
+ location: ir.Location = None,
119
+) -> ir.Module:
120
+ with ExitStack() as stack:
121
+ if location is None:
122
+ location = ir.Location.unknown()
123
+ stack.enter_context(location)
124
+ if src is not None:
125
+ module = ir.Module.parse(src)
126
+ else:
127
+ module = ir.Module.create()
128
+ ip = ir.InsertionPoint(module.body)
129
+ stack.enter_context(ip)
130
+ yield module
131
+
132
133
@contextlib.contextmanager
134
def enable_multithreading(context=None):
135
from ..ir import Context
0 commit comments