-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
inference/unify output buffer management #11569
inference/unify output buffer management #11569
Conversation
|
||
namespace paddle { | ||
|
||
PaddleBuf::PaddleBuf(PaddleBuf&& other) |
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.
Is this used?
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.
Free(); | ||
data_ = new char[length]; | ||
length_ = length; | ||
memory_owned_ = true; |
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.
why assign again?
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.
reset a new length.
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 mean memory_owned_ is already true, as assert before.
std::memcpy( | ||
outputs->at(i).data.data, data.data(), outputs->at(i).data.length); | ||
auto &buffer = outputs->at(i).data; | ||
if (buffer.empty() || buffer.length() < sizeof(float) * data.size()) { |
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.
Maybe we don't want to allow buffer.length() > sizeof(float) * data.size()
? If that's the case, how does client know how many bytes to use?
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.
It is safe to Resize
here.
If the client doesn't know how much to allocate or Resize
, just init with a large enough memory, and do not resize it.
// Only the owned memory can be reset, the external memory can't be changed. | ||
assert(memory_owned_); | ||
Free(); | ||
data_ = new char[length]; |
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.
If the length == length_
, can return early?
Free(); | ||
data_ = new char[length]; | ||
length_ = length; | ||
memory_owned_ = true; |
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 mean memory_owned_ is already true, as assert before.
PaddleBuf
possible to manage the buffer