-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Hexagon] Refactor to keep HexagonBuffer private to the device api #10910
Conversation
cc @adstraw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few general cleanups, and looks good to me. I like this change, so that nothing outside the device api needs to track how the internal memory is handled.
@@ -47,14 +47,6 @@ | |||
namespace tvm { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove the now empty namespace blocks?
if (it != this->hexagon_buffer_map_.end()) { | ||
return it->second.get(); | ||
} | ||
return nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the nullptr
check is done after each lookup, let's move it in here as CHECK(it != this->hexagon_buffer_map_.end())
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that, because that would let it be used in the free_nd
function as well. Though, I think it should be private, unlike the "Allocate" and "Free" methods.
*/ | ||
template <typename... Args> | ||
void* AllocateHexagonBuffer(Args&&... args) { | ||
auto buf = std::unique_ptr<HexagonBuffer>(new HexagonBuffer(std::forward<Args>(args)...)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since TVM uses C++14, we can use std::make_unique<HexagonBuffer>(std::forward<Args>(args)...)
instead of new
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alas my configuration for hexagon was giving false negatives on finding std::make_unique in the std. I had intended to circle back on this one before pushing but forgot, so thank you for the reminder!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. No comments beyond what @Lunderberg already mentioned. Thanks @csullivan!
Note that the "external" constructor for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@csullivan @adstraw @Lunderberg @kparzysz-quic thanks! merged now! |
…pache#10910) * No longer return HexagonBuffer from device api. * fixup! No longer return HexagonBuffer from device api.
…pache#10910) * No longer return HexagonBuffer from device api. * fixup! No longer return HexagonBuffer from device api.
…pache#10910) * No longer return HexagonBuffer from device api. * fixup! No longer return HexagonBuffer from device api.
…pache#10910) * No longer return HexagonBuffer from device api. * fixup! No longer return HexagonBuffer from device api.
Refactoring the DeviceAPI a bit to privatize the HexagonBuffer class and no longer return it across the API boundary. So far we haven't seen a need to identify the memory scope, layout, and other properties of a HexagonBuffer outside the Device API.