-
Notifications
You must be signed in to change notification settings - Fork 629
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
Test refactor #91
Test refactor #91
Conversation
Elimination of duplicated code from WriteImage functions. Signed-off-by: Andrei <andreii@nvidia.com>
Signed-off-by: Andrei <andreii@nvidia.com>
Signed-off-by: Andrei <andreii@nvidia.com>
Signed-off-by: Andrei <andreii@nvidia.com>
Signed-off-by: Andrei <andreii@nvidia.com>
Signed-off-by: Andrei <andreii@nvidia.com>
The JPEG/PNG files are loaded and decoded only when it's is really need to be done for performing of current test. Signed-off-by: Andrei <andreii@nvidia.com>
Output of the images in benchmark eliminate Signed-off-by: Andrei <andreii@nvidia.com>
Signed-off-by: Andrei <andreii@nvidia.com>
@@ -112,7 +112,7 @@ BENCHMARK_DEFINE_F(RealRN50, nvjpegPipe)(benchmark::State& st) { // NOLINT | |||
} | |||
} | |||
|
|||
WriteHWCBatch<uint8_t>(*ws.Output<GPUBackend>(0), 0, 1, "img"); | |||
// WriteHWCBatch(*ws.Output<GPUBackend>(0), "img"); |
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.
IIRC, the reason we keep this line here is for debugging, right? If so can we put it in #if DALI_DEBUG
instead of commenting it out? Like was done below in dali/pipeline/operators/fused/crop_mirror_normalize_test.cc .
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.
DONE
dali/benchmark/dali_bench.h
Outdated
} | ||
|
||
virtual ~DALIBenchmark() { | ||
for (auto &ptr : jpegs_) { | ||
for (auto &ptr : jpegs_.data_) { |
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 it more future-proof to delete jpegs_ and count on its destructor to delete jpegs_.data_ in turn? That would mean ImgSetDescr
in dali/util/image.h should be a class rather than a struct and have a non-default destructor (which is probably reasonable anyway).
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.
Yes, it is a very useful change. It also fixes memory leak in DALISingleOpTest
- Destructor for ImageSetDescr - Conditional compilation of WriteHWCBatch for resnet50 benchmark Signed-off-by: Andrei <andreii@nvidia.com>
3521365
to
21ee128
Compare
} | ||
}; | ||
|
||
typedef ::testing::Types<RGB, BGR, Gray> Types; | ||
TYPED_TEST_CASE(HostDecodeTest, Types); | ||
|
||
TYPED_TEST(HostDecodeTest, TestJPEGDecode) { | ||
this->RunTestDecode(t_jpegImgType, 0.00000005); | ||
this->RunTestDecode(t_jpegImgType, 1.6); |
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 1.6 and not 1.7 or 1.4?
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.
Actually, on my machine all HostDecode tests are passing with 0.0 tolerance.
But in GitLab version the average deviation for different images is in following range
0.299477 - 1.57299. I am using 1.6 just to make these tests passed.
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 strange. As I see this test generates reference data using cv::imdecode, decoder itself should use jpeg turbo. Could you try investigate a bit more if this is jpeg turbo itself or other case condition?
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 agree- it's very strange. I also see the discrepancy in JpegDecodeTest results. I will investigate.
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.
Cliff helped me to investigate this issue. This is what we found by comparing the images constructed on my machine and during CI testing:
a) the images decoded by DALI are the same;
b) the images constructed by openCV methods are different.
c) the difference is not significant - the absolute values of the average deviation for different colored images are in range of (0.3 - 1.16), which is 0.11% -0.63% of the full color range of 255.
The real cause of this discrepancy is still unclear. I reinstalled openCV/JpegTurbo/NvJpeg
and could not reproduce CI results.
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.
@drivanov - I still recommend rescaling the results by 1/255.f and changing the threshold to match and being done with it.
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.
OK, I will do that. It should not be difficult because in that branch the calculation of the average deviation is in one place for all tests which are using it.
Signed-off-by: Andrei <andreii@nvidia.com>
This class was used for - new tests for Displacement Operators. - refactoring of the tests for Color Operators Signed-off-by: Andrei <andreii@nvidia.com>
(normalized to color range and converted to percentages) Signed-off-by: Andrei <andreii@nvidia.com>
@cliffwoolley @drivanov What is the status of this PR? Can we review/merge it? I see that Andrei added commits from #93 here as well, which is confusing. |
@ptrendx Actually, #91 and #93 should be identical. Yesterday @cliffwoolley asked me to merge everything into #91 and I did it. |
Ok, please close #93 then. |
@@ -37,10 +37,11 @@ class OperatorRegistry { | |||
|
|||
OperatorRegistry() {} | |||
|
|||
void Register(const std::string &name, Creator creator) { | |||
void Register(const std::string &name, Creator creator, const char *devName = NULL) { |
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.
const string &
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.
And then use "" instead of NULL in allocator.h
@@ -71,8 +72,8 @@ class Registerer { | |||
public: | |||
Registerer(const std::string &name, | |||
OperatorRegistry<OpType> *registry, | |||
typename OperatorRegistry<OpType>::Creator creator) { | |||
registry->Register(name, creator); | |||
typename OperatorRegistry<OpType>::Creator creator, const char *devName = NULL) { |
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.
same
@@ -143,7 +143,7 @@ class NewResize : public Resize<Backend> { | |||
void SetupSharedSampleParams(Workspace<Backend> *ws) override { | |||
Resize<Backend> ::SetupSharedSampleParams(ws); | |||
} | |||
uint ResizeInfoNeeded() const override { return t_crop + t_mirrorHor; } | |||
virtual uint ResizeInfoNeeded() const { return t_crop + t_mirrorHor; } |
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? Override makes the code clearer.
dali/test/dali_test_single_op.h
Outdated
RunOperator(AddArguments(&spec, descr.args), descr.epsVal); | ||
} | ||
|
||
void RunOperator(const OpSpec& spec, double eps, DeviceWorkspace *pWS = NULL) { |
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.
use nullptr instead of NULL
Signed-off-by: Andrei <andreii@nvidia.com>
* Division by 0 in in CropMirrorNormalizeTest was fixed. Elimination of duplicated code from WriteImage functions. Signed-off-by: Andrei <andreii@nvidia.com> * Fix of problem in bresnet50 benchmark Signed-off-by: Andrei <andreii@nvidia.com> * CropMirrorNormalizePermuteTest refactored Signed-off-by: Andrei <andreii@nvidia.com> * Lint problem fixed Signed-off-by: Andrei <andreii@nvidia.com> * JpegDecodeTest re-implemented Signed-off-by: Andrei <andreii@nvidia.com> * Nondefault bound for average deviation implemented for 2 decode tests Signed-off-by: Andrei <andreii@nvidia.com> * Executore test refactored. The JPEG/PNG files are loaded and decoded only when it's is really need to be done for performing of current test. Signed-off-by: Andrei <andreii@nvidia.com> * Lint problem fixed Output of the images in benchmark eliminate Signed-off-by: Andrei <andreii@nvidia.com> * Eps for ExecutorTest and some changes, suggested by Cliff Signed-off-by: Andrei <andreii@nvidia.com> * Changes requested by Cliff. - Destructor for ImageSetDescr - Conditional compilation of WriteHWCBatch for resnet50 benchmark Signed-off-by: Andrei <andreii@nvidia.com> * Color augmentations on CPU Signed-off-by: Andrei <andreii@nvidia.com> * GenericMatchingTest class implemented This class was used for - new tests for Displacement Operators. - refactoring of the tests for Color Operators Signed-off-by: Andrei <andreii@nvidia.com> * Average deviation of pixel colors for unit tests rescaled (normalized to color range and converted to percentages) Signed-off-by: Andrei <andreii@nvidia.com> * Changes requested by Przemek Signed-off-by: Andrei <andreii@nvidia.com> Signed-off-by: Andrei <andreii@nvidia.com>
* Division by 0 in in CropMirrorNormalizeTest was fixed. Elimination of duplicated code from WriteImage functions. Signed-off-by: Andrei <andreii@nvidia.com> * Fix of problem in bresnet50 benchmark Signed-off-by: Andrei <andreii@nvidia.com> * CropMirrorNormalizePermuteTest refactored Signed-off-by: Andrei <andreii@nvidia.com> * Lint problem fixed Signed-off-by: Andrei <andreii@nvidia.com> * JpegDecodeTest re-implemented Signed-off-by: Andrei <andreii@nvidia.com> * Nondefault bound for average deviation implemented for 2 decode tests Signed-off-by: Andrei <andreii@nvidia.com> * Executore test refactored. The JPEG/PNG files are loaded and decoded only when it's is really need to be done for performing of current test. Signed-off-by: Andrei <andreii@nvidia.com> * Lint problem fixed Output of the images in benchmark eliminate Signed-off-by: Andrei <andreii@nvidia.com> * Eps for ExecutorTest and some changes, suggested by Cliff Signed-off-by: Andrei <andreii@nvidia.com> * Changes requested by Cliff. - Destructor for ImageSetDescr - Conditional compilation of WriteHWCBatch for resnet50 benchmark Signed-off-by: Andrei <andreii@nvidia.com> * Color augmentations on CPU Signed-off-by: Andrei <andreii@nvidia.com> * GenericMatchingTest class implemented This class was used for - new tests for Displacement Operators. - refactoring of the tests for Color Operators Signed-off-by: Andrei <andreii@nvidia.com> * Average deviation of pixel colors for unit tests rescaled (normalized to color range and converted to percentages) Signed-off-by: Andrei <andreii@nvidia.com> * Changes requested by Przemek Signed-off-by: Andrei <andreii@nvidia.com> Signed-off-by: Andrei <andreii@nvidia.com>
Refactoring of the unit tests