Skip to content

Commit

Permalink
Manage context when opening a session against a micro target
Browse files Browse the repository at this point in the history
Now that open() method in Session is gone with commit 42167f9
(Revert "[microTVM] Add open and close methods to Session class") use
contextlib to activate the context manager when opening a session
against a micro target.
  • Loading branch information
gromero committed Oct 24, 2021
1 parent bf94efe commit 874382e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion python/tvm/driver/tvmc/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""
Provides support to run compiled networks both locally and remotely.
"""
from contextlib import ExitStack
import json
import logging
import pathlib
Expand Down Expand Up @@ -487,7 +488,10 @@ def run_module(
# Remote RPC (running on a micro target)
logger.debug("Running on remote RPC (micro target).")
try:
session = tvm.micro.Session(project_.transport()).open()
with ExitStack() as stack:
session = tvm.micro.Session(project_.transport())
# Enter context manager 'session' so it's active from now on.
stack.enter_context(session)
except:
raise TVMCException("Could not open a session with the micro target.")
else:
Expand Down

0 comments on commit 874382e

Please sign in to comment.