-
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
Add namespace on image C++ codebase #3312
Conversation
8424391
to
8450858
Compare
8450858
to
7136251
Compare
Codecov Report
@@ Coverage Diff @@
## master #3312 +/- ##
=======================================
Coverage 73.93% 73.93%
=======================================
Files 104 104
Lines 9594 9594
Branches 1531 1531
=======================================
Hits 7093 7093
Misses 2024 2024
Partials 477 477 Continue to review full report at Codecov.
|
1690a5f
to
22925ff
Compare
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.
Git completely dropped the ball tracking which file was moved to what, so I left a couple of comments in places it gets it wrong. You can validate what I say by checking the individual commits.
namespace vision { | ||
namespace image { | ||
|
||
C10_EXPORT torch::Tensor decode_jpeg( |
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.
Here Github fails to track the right file renames and thinks I moved png to jpeg and vice versa.
namespace vision { | ||
namespace image { | ||
|
||
C10_EXPORT torch::Tensor decode_png( |
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.
Again Github fails to figure out which file was moved to what here.
namespace vision { | ||
namespace image { | ||
|
||
C10_EXPORT torch::Tensor encode_jpeg( |
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.
Git fails to track the old file.
|
||
#include <torch/types.h> | ||
|
||
C10_EXPORT torch::Tensor encodeJPEG(const torch::Tensor& data, int64_t quality); |
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.
Git fails to track the move to the new file...
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.
Looks great to me, thanks!
namespace image { | ||
namespace detail { | ||
|
||
#if JPEG_FOUND |
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.
Looks like we have two #if JPEG_FOUND
in this file, but there doesn't seem to be any code not within JPEG_FOUND
. Should we have instead a single #if JPEG_FOUND
?
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 intentionally use two because I wanted to put the headers on top and then actually have the namespace vision::image::detail because I open it from a different file. This way even if it's empty the code will still work. I think I can refactor this to make it work with one if statement.
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.
Fixed!
@@ -0,0 +1,13 @@ | |||
#pragma once | |||
|
|||
#include <torch/types.h> |
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 need to start using a smart editor. I would have just #include <torch/torch.h>
and brought everything in :-)
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.
Unfortunately that's not a smart editor feature but I wish they had that functionality too.
Summary: * Moving jpegcommon inside cpu implementation * Adding namespaces on image and moving private methods to anonymous. * Fixing headers. * Renaming public image methods to match the ones on python. * Refactoring to remove the double ifs in common_jpeg.h Reviewed By: fmassa Differential Revision: D26197738 fbshipit-source-id: a9d3ca2d8a248504fbe4bdfda94b6cbdda2270f1
Aligning the C++ codebase in
image
with the rest of the library, similar to #3311:vision::image
namespace.