Skip to content

Commit

Permalink
[Hexagon] Remove temporary VTCM workspace APIs (apache#13681)
Browse files Browse the repository at this point in the history
  • Loading branch information
janetsc authored and fzi-peccia committed Mar 27, 2023
1 parent 5a043c9 commit 942abff
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 30 deletions.
18 changes: 2 additions & 16 deletions src/runtime/hexagon/hexagon_device_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,6 @@ void HexagonDeviceAPI::FreeWorkspace(Device dev, void* data) {
dmlc::ThreadLocalStore<HexagonWorkspacePool>::Get()->FreeWorkspace(dev, data);
}

void* HexagonDeviceAPI::AllocVtcmWorkspace(Device dev, int ndim, const int64_t* shape,
DLDataType dtype, Optional<String> mem_scope) {
// must be Hexagon device (not CPU)
CHECK(dev.device_type == kDLHexagon) << "dev.device_type: " << dev.device_type;
CHECK((ndim == 1 || ndim == 2) && "Hexagon Device API supports only 1d and 2d allocations");
return AllocDataSpace(dev, ndim, shape, dtype, mem_scope);
}

void HexagonDeviceAPI::FreeVtcmWorkspace(Device dev, void* ptr) {
// must be Hexagon device (not CPU)
CHECK(dev.device_type == kDLHexagon) << "dev.device_type: " << dev.device_type;
FreeDataSpace(dev, ptr);
}

void HexagonDeviceAPI::CopyDataFromTo(DLTensor* from, DLTensor* to, TVMStreamHandle stream) {
CHECK_EQ(from->byte_offset, 0);
CHECK_EQ(to->byte_offset, 0);
Expand Down Expand Up @@ -268,7 +254,7 @@ TVM_REGISTER_GLOBAL("device_api.hexagon.alloc_nd").set_body([](TVMArgs args, TVM
type_hint.lanes = 1;

HexagonDeviceAPI* hexapi = HexagonDeviceAPI::Global();
*rv = hexapi->AllocVtcmWorkspace(dev, ndim, shape, type_hint, String(scope));
*rv = hexapi->AllocDataSpace(dev, ndim, shape, type_hint, String(scope));
});

TVM_REGISTER_GLOBAL("device_api.hexagon.free_nd").set_body([](TVMArgs args, TVMRetValue* rv) {
Expand All @@ -283,7 +269,7 @@ TVM_REGISTER_GLOBAL("device_api.hexagon.free_nd").set_body([](TVMArgs args, TVMR
dev.device_id = device_id;

HexagonDeviceAPI* hexapi = HexagonDeviceAPI::Global();
hexapi->FreeVtcmWorkspace(dev, ptr);
hexapi->FreeDataSpace(dev, ptr);
*rv = static_cast<int32_t>(0);
});

Expand Down
14 changes: 0 additions & 14 deletions src/runtime/hexagon/hexagon_device_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,6 @@ class HexagonDeviceAPI final : public DeviceAPI {
void* AllocDataSpace(Device dev, int ndim, const int64_t* shape, DLDataType dtype,
Optional<String> mem_scope) final;

/*!
* \brief Allocate an Nd VTCM workspace.
* \param dev The device to perform the operation.
* \param ndim The number of dimensions of allocated tensor.
* \param shape The shape of allocated tensor.
* \param dtype The element type.
* \return The allocated HexagonBuffer pointer.
*/
void* AllocVtcmWorkspace(Device dev, int ndim, const int64_t* shape, DLDataType dtype,
Optional<String> mem_scope);

//! \brief Free the allocated Nd VTCM workspace.
void FreeVtcmWorkspace(Device dev, void* ptr);

/*!
* \brief Copy data from one storage to another.
* \note This API is designed to support special memory with shape dependent layout.
Expand Down

0 comments on commit 942abff

Please sign in to comment.