janetsc commented on code in PR #13028:
URL: https://github.com/apache/tvm/pull/13028#discussion_r993977233
##########
src/runtime/hexagon/hexagon_buffer_manager.h:
##########
@@ -85,6 +86,18 @@ class HexagonBufferManager {
return hexagon_buffer_map_.empty();
}
+ //! \brief Returns a vector of currently allocated pointers, owned by the
manager.
+ // Note - this should only be used by the device API to keep track of what
+ // was in the manager when HexagonDeviceAPI::ReleaseResources is called.
+ std::vector<void*> current_allocations() {
Review Comment:
Thanks for the review.
I agree, this isn't ideal. However, I wanted to make sure that I don't give
a "free pass" to all frees that come after ReleaseResources. The scenario I
was trying to avoid was:
User allocates buffer B
Session ends, ReleaseResources is called and B is freed
User frees buffer B as objects are being torn down, which should not throw
as it is somewhat expected
User frees buffer C, which SHOULD throw, as it was never allocated in the
first place
I added this so that I can check if there's no runtime_hexbuffs, then I make
sure that what is being attempted to be freed is something that we owned before
ReleaseResources was called. In which case, that Free is a no-op. I also want
to detect spurious calls to Free that wouldn't have been legit before
ReleaseResources was called.
I'm happy to discuss more, and brainstorm other ways to accomplish this.
--
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]