Lunderberg commented on code in PR #11547:
URL: https://github.com/apache/tvm/pull/11547#discussion_r890207617
##########
python/tvm/contrib/hexagon/session.py:
##########
@@ -93,7 +93,8 @@ def __enter__(self):
raise exception
def __exit__(self, exc_type, exc_value, exc_traceback):
- pass
+ # close session to the tracker
+ del self._rpc
Review Comment:
Assuming that this is the only reference to `self._rpc`, this would destroy
the object, because CPython uses a reference count in addition to generational
garbage collection. That said, that's more of an implementation detail, and is
pretty fragile to rely upon.
It looks like the key function we want to call is
[`RPCEndpoint::Shutdown`](https://github.com/apache/tvm/blob/main/src/runtime/rpc/rpc_endpoint.cc#L708),
usually called when the `RPCEndpoint` object is destructed. Unfortunately, I
don't see any method in either
[`RPCClientSession`](https://github.com/apache/tvm/blob/main/src/runtime/rpc/rpc_endpoint.cc#L995)
or
[`RPCSession`](https://github.com/apache/tvm/blob/main/src/runtime/rpc/rpc_session.h#L48).
I think we could add a `close` method to the python `RPCSession` object,
which would then be called from `__exit__`.
```python
def close(self):
self._sess.__del__()
self._sess = None
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]