adstraw commented on code in PR #10910:
URL: https://github.com/apache/tvm/pull/10910#discussion_r844101727


##########
src/runtime/hexagon/hexagon/hexagon_device_api_v2.cc:
##########
@@ -148,20 +139,29 @@ void HexagonDeviceAPIv2::CopyDataFromTo(DLTensor* from, 
DLTensor* to, TVMStreamH
   CHECK_EQ(to->byte_offset, 0);
   CHECK_EQ(GetDataSize(*from), GetDataSize(*to));
 
-  HexagonBuffer* hex_from_buf = static_cast<HexagonBuffer*>(from->data);
-  HexagonBuffer* hex_to_buf = static_cast<HexagonBuffer*>(to->data);
+  auto lookup_hexagon_buffer = [this](void* ptr) -> HexagonBuffer* {
+    auto it = this->hexagon_buffer_map_.find(ptr);
+    if (it != this->hexagon_buffer_map_.end()) {
+      return it->second.get();
+    }
+    return nullptr;

Review Comment:
   Agree with @Lunderberg's comment and also think that `lookup_hexagon_buffer` 
could / should be a member of `HexagonDeviceAPIv2` named `LookupHexagonBuffer` 
alongside the "Allocate" and "Free" methods.



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

Reply via email to