-
Notifications
You must be signed in to change notification settings - Fork 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
use from_blob to avoid memcpy #4118
Conversation
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.
The changes seem reasonable to me.
@andfoy have also a look if your don't mind. Thx!
Good to see that |
Nice, thanks for doing this and handling the deleter! |
|
||
return outTensor; | ||
auto out_tensor = | ||
torch::from_blob(jpegBuf, {(long)jpegSize}, ::free, options); |
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.
This line is raising the following clang-tidy warning in our internal CI:
There's an unchecked dereference of an object that is nullable. Make sure you null-check the object before you call methods on it, pass it as non-nullable parameter, or dereference it. If you are sure the the object cannot be nullptr, make it explicit with CHECK_NOTNULL() or assert(). jpegBuf is nullable.
Looks like jpegBuf
is set above in jpeg_mem_dest
, but I couldn't find any relevant docs about this function to know what happens if the allocation fails.
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 think if we have errors the setjmp
that we do in https://github.com/pytorch/vision/pull/4118/files#diff-dfb505641c632421ae5cc17a4398fe0e3a47c436f62825e88ba2b0aebf497d5eR37 will kick in and the check that jpegBuf != nullptr
, so maybe this clang-tidy error is a false-positive.
Still let's keep an eye on this
Summary: Reviewed By: NicolasHug Differential Revision: D29516853 fbshipit-source-id: 88d8c3962204071883317d1b2eb383900d90d430 Co-authored-by: Nicolas Hug <nicolashug@fb.com> Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com>
No description provided.