adstraw commented on code in PR #13028:
URL: https://github.com/apache/tvm/pull/13028#discussion_r997478332
##########
src/runtime/hexagon/hexagon_device_api.cc:
##########
@@ -115,13 +120,34 @@ void* HexagonDeviceAPI::AllocDataSpace(Device dev, size_t
nbytes, size_t alignme
if (alignment < kHexagonAllocAlignment) {
alignment = kHexagonAllocAlignment;
}
- return mgr->AllocateHexagonBuffer(nbytes, alignment, String("global"));
+ CHECK(runtime_hexbuffs) << "Attempted to allocate Hexagon data with "
+ << "HexagonDeviceAPI::AllocDataSpace before
initializing resources. "
+ << "Please call HexagonDeviceAPI::AcquireResources";
+ return runtime_hexbuffs->AllocateHexagonBuffer(nbytes, alignment,
String("global"));
}
void HexagonDeviceAPI::FreeDataSpace(Device dev, void* ptr) {
CHECK(ptr) << "buffer pointer is null";
CHECK(IsValidDevice(dev)) << "dev.device_type: " << dev.device_type;
- mgr->FreeHexagonBuffer(ptr);
+ if (runtime_hexbuffs) {
+ runtime_hexbuffs->FreeHexagonBuffer(ptr);
+ } else {
Review Comment:
Making sure all "temporal" frees occur before Release is a good idea and
worthwhile endeavor. ✅
I am not convinced that two `HexagonBufferManager` objects are required.
Instead, you could have separate interfaces in a single `HexagonBufferManager`
class to track "permanent" (for RPC e.g.) versus "temporal" allocations. And,
in this way, alleviate the need for the `current_allocations` method which
exposes the internals of the `HexagonBufferManager` class to its users.
Something to consider for a future cleanup, perhaps.
--
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]