Lunderberg commented on code in PR #13028:
URL: https://github.com/apache/tvm/pull/13028#discussion_r994869218


##########
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:
   As an alternative, what if the `HexagonBufferManager` allows three states 
for buffers instead of two.
   
   * Valid to use, valid to free (Initial state after allocating memory)
   * Invalid to use, valid to free (State after closing a session)
   * Invalid to use, invalid to free (State of unknown pointer)
   
   That way, instead of discarding the `HexagonBufferManager runtime_hexbuffs` 
altogether when the session closes, it instead moves all keys from the internal 
`std::unordered_map<void*, std::unique_ptr<HexagonBuffer>> 
hexagon_buffer_map_;` to an internal `std::unordered_set<void*>`.  This avoids 
exposing any of the buffers to the outside, but does allow the 
`HexagonBufferManager` to identify a previously freed pointer.



-- 
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: commits-unsubscr...@tvm.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to