You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR is about addressing the MLIR context management issue in the
tuner detailed in #764.
Although this is a work in progress, I am sending it to gather feedback
and ensure I am heading in the right direction.
---------
Signed-off-by: Bangtian Liu <[email protected]>
Currently, the MLIR context management in the tuner is functional but weird:
shark-ai/tuner/tuner/libtuner.py
Lines 1055 to 1098 in aaee29a
We use a
with
statement to put the existing mlir context onto the stack, and after that the context outlives thewith
scope. This is unusual because thewith
statement is generally destructive in python: https://docs.python.org/3/reference/compound_stmts.html#the-with-statement:~:text=with%20EXPRESSION%20as%20TARGET%3A%0A%20%20%20%20SUITE-,is%20semantically%20equivalent%20to%3A,-manager%20%3D%20(EXPRESSION)%0AenterThis is only safe because of how
__enter__
and__exit__
are defined for the MLIR context class:For more introductory info, see https://mlir.llvm.org/docs/Bindings/Python/#context-management.
To make it more idiomatic, we should:
with
statement in the tuner__enter__
and__exit__
functionsTunerContext
constructor create MLIR context and cleaning up tuner context test fixturesThe text was updated successfully, but these errors were encountered: