Skip to content
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

Refactor video tests #3864

Merged
merged 9 commits into from
May 10, 2022
Merged

Refactor video tests #3864

merged 9 commits into from
May 10, 2022

Conversation

awolant
Copy link
Contributor

@awolant awolant commented Apr 28, 2022

Refactor video tests for new video readers to make it easier to add new tests for new formats in the future. Extend tests coverage.

Category:

Refactoring of the video tests.

Checklist

Tests

  • Existing tests apply
  • New tests added
    • Python tests
    • GTests
    • Benchmark
    • Other
  • N/A

Documentation

  • Existing documentation applies
  • Documentation updated
    • Docstring
    • Doxygen
    • RST
    • Jupyter
    • Other
  • N/A

DALI team only

Requirements

  • Implements new requirements
  • Affects existing requirements
  • N/A

REQ IDs: N/A

JIRA TASK: N/A

Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
@awolant
Copy link
Contributor Author

awolant commented Apr 28, 2022

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4701610]: BUILD STARTED

Comment on lines +200 to +204

if (flush_state_) {
flush_state_ = false;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While improving tests coverage I found this small bug in the frames decoder - flush_state_ flag was not cleared while decoder was reset.

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4701610]: BUILD PASSED

@JanuszL JanuszL self-requested a review April 28, 2022 17:06
@JanuszL JanuszL self-assigned this Apr 28, 2022

TEST_F(FramesDecoderGpuTest, VariableFrameRateGpu) {
class FramesDecoderGpuTest : public FramesDecoderTestBase {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to unify this with FramesDecoderTest_CpuOnlyTests?
The main difference I see is the additional copy of the data from DeviceBuffer to frame_cpu, and the different method of validation compared to ground_truth. I think these two things could be just a specialization of a method for the GPU test, but other steps could be common (the flow of the tests itself).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't want to over do it in the beginning but sure, done.

std::vector<std::vector<cv::Mat>> VideoTestBase::vfr_frames_;
void CompareFrameAvgError(
const uint8_t *ground_truth, const uint8_t *frame, int frame_size, double eps) {
std::vector<double> sums(std::thread::hardware_concurrency(), 0.0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if you can hide the fact that detail::parallel_for uses std::thread::hardware_concurrency() for the thread number it spawns?
Maybe it could be detail::parallel_for_threads_no()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done



TEST_F(FramesDecoderTest_CpuOnlyTests, ConstantFrameRate) {
RunTest("/db/video/cfr/test_1.mp4", cfr_videos_[0]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can have the path to the video and frames in the same place. Like:

RunTest("cfr_videos_[0].video",cfr_videos_[0].ref_frames);

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Now I keep all paths in VideoTestBase in lists and match by index. I did to to be able to pass whole list to op specs in reader tests.

const int sequence_length = 6;
const int stride = 3;
const int step = 10;
class VideoReaderDecoderGpuTest : public VideoReaderDecoderBaseTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we combine common parts with VideoReaderDecoderBaseTest? Or it is too much?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Signed-off-by: Albert Wolant <awolant@nvidia.com>
}
}
private:
std::vector<uint8_t> frame_buffer;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::vector<uint8_t> frame_buffer;
std::vector<uint8_t> frame_buffer_;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 141 to 142
std::vector<uint8_t> frame_cpu_buffer;
DeviceBuffer<uint8_t> frame_gpu_buffer;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::vector<uint8_t> frame_cpu_buffer;
DeviceBuffer<uint8_t> frame_gpu_buffer;
std::vector<uint8_t> frame_cpu_buffer_;
DeviceBuffer<uint8_t> frame_gpu_buffer_;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
@@ -18,6 +18,7 @@ namespace dali {
void VideoLoaderDecoderCpu::PrepareEmpty(VideoSample<CPUBackend> &sample) {
sample = {};
sample.data_.set_pinned(false);
sample.data_.SetLayout("FHWC");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another small bug fix I found during the tests rework - layout was not set in CPU reader.

Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
@awolant
Copy link
Contributor Author

awolant commented May 2, 2022

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4728585]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4728585]: BUILD FAILED

@awolant
Copy link
Contributor Author

awolant commented May 4, 2022

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4746024]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [4746024]: BUILD PASSED

@awolant awolant merged commit ebd64eb into NVIDIA:main May 10, 2022
cyyever pushed a commit to cyyever/DALI that referenced this pull request May 13, 2022
* Refactor video tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jun 7, 2022
* Refactor video tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants