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


##########
src/runtime/hexagon/hexagon_buffer_manager.h:
##########
@@ -85,6 +86,18 @@ class HexagonBufferManager {
     return hexagon_buffer_map_.empty();
   }
 
+  //! \brief Returns a list of allocated pointers.

Review Comment:
   Nit: Should specify that this is a non-owning set of pointers.



##########
src/runtime/hexagon/hexagon_buffer_manager.h:
##########
@@ -85,6 +86,18 @@ class HexagonBufferManager {
     return hexagon_buffer_map_.empty();
   }
 
+  //! \brief Returns a list of allocated pointers.
+  // 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*> vector() {
+    std::vector<void*> allocated;
+    std::lock_guard<std::mutex> lock(map_mutex_);
+    for (auto it = hexagon_buffer_map_.begin(); it != 
hexagon_buffer_map_.end(); it++) {

Review Comment:
   FYI, since we're on C++17 now, structured bindings with a ranged-based for 
loop reduce a lot of the iterator-based boilerplate.  This is more personal 
style, but it would let the loop be re-written as below.
   
   ```c++
   for(const auto& [data_ptr, buffer] : hexagon_buffer_map_) {
       allocated.push_back(data_ptr);
   }
   ```



##########
src/runtime/hexagon/hexagon_buffer_manager.h:
##########
@@ -85,6 +86,18 @@ class HexagonBufferManager {
     return hexagon_buffer_map_.empty();
   }
 
+  //! \brief Returns a list of allocated pointers.
+  // 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*> vector() {

Review Comment:
   Nit: Renaming to `current_allocations` would tell a reader what is contained 
in the return value.



-- 
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