From c262caf46f8c502c889c7cd841ec35c84ae24dc0 Mon Sep 17 00:00:00 2001 From: Janusz Lisiecki Date: Mon, 9 Sep 2024 16:21:33 +0200 Subject: [PATCH 1/5] Adds `enable_frame_num` to the experimental video reader - adds an ability to output frame numbers in the experimental video reader - this allows making VideoReaderDecoderCpuTest.RandomShuffle_* test independent from the hardcoding of the expected frame order (in case random generator implementation changes) Signed-off-by: Janusz Lisiecki --- .../loader/video/video_loader_decoder_base.h | 3 + .../loader/video/video_loader_decoder_cpu.cc | 3 + .../reader/video_reader_decoder_cpu_op.cc | 23 ++++++- .../reader/video_reader_decoder_cpu_op.h | 1 + .../reader/video_reader_decoder_gpu_op.cc | 66 +++++++++++++------ .../reader/video_reader_decoder_gpu_op.h | 1 + .../reader/video_reader_decoder_op_test.cc | 34 ++++++++-- 7 files changed, 101 insertions(+), 30 deletions(-) diff --git a/dali/operators/reader/loader/video/video_loader_decoder_base.h b/dali/operators/reader/loader/video/video_loader_decoder_base.h index 1d64263fcfa..4413f53ac6e 100644 --- a/dali/operators/reader/loader/video/video_loader_decoder_base.h +++ b/dali/operators/reader/loader/video/video_loader_decoder_base.h @@ -36,6 +36,7 @@ class VideoSample { public: Tensor data_; int label_; + int first_frame_; }; class VideoLoaderDecoderBase { @@ -46,6 +47,7 @@ class VideoLoaderDecoderBase { stride_(spec.GetArgument("stride")), step_(spec.GetArgument("step")) { has_labels_ = spec.TryGetRepeatedArgument(labels_, "labels"); + has_frame_no_ = spec.GetArgument("enable_frame_num"); DALI_ENFORCE( !has_labels_ || labels_.size() == filenames_.size(), make_string( @@ -61,6 +63,7 @@ class VideoLoaderDecoderBase { std::vector filenames_; std::vector labels_; bool has_labels_ = false; + bool has_frame_no_ = false; Index current_index_ = 0; diff --git a/dali/operators/reader/loader/video/video_loader_decoder_cpu.cc b/dali/operators/reader/loader/video/video_loader_decoder_cpu.cc index 3fea566242c..20743462060 100644 --- a/dali/operators/reader/loader/video/video_loader_decoder_cpu.cc +++ b/dali/operators/reader/loader/video/video_loader_decoder_cpu.cc @@ -45,6 +45,9 @@ void VideoLoaderDecoderCpu::ReadSample(VideoSample &sample) { if (has_labels_) { sample.label_ = labels_[sample_span.video_idx_]; } + if (has_frame_no_) { + sample.first_frame_ = sample_span.start_; + } } Index VideoLoaderDecoderCpu::SizeImpl() { diff --git a/dali/operators/reader/video_reader_decoder_cpu_op.cc b/dali/operators/reader/video_reader_decoder_cpu_op.cc index bae530606dd..09a5ece3741 100644 --- a/dali/operators/reader/video_reader_decoder_cpu_op.cc +++ b/dali/operators/reader/video_reader_decoder_cpu_op.cc @@ -20,7 +20,8 @@ namespace dali { VideoReaderDecoderCpu::VideoReaderDecoderCpu(const OpSpec &spec) : DataReader(spec), - has_labels_(spec.HasArgument("labels")) { + has_labels_(spec.HasArgument("labels")), + has_frame_no_(spec.GetArgument("enable_frame_num")) { loader_ = InitLoader(spec); this->SetInitialSnapshot(); } @@ -32,16 +33,28 @@ void VideoReaderDecoderCpu::RunImpl(SampleWorkspace &ws) { video_output.Copy(sample.data_); video_output.SetSourceInfo(sample.data_.GetSourceInfo()); + int out_index = 1; if (has_labels_) { - auto &label_output = ws.Output(1); + auto &label_output = ws.Output(out_index); label_output.Resize({}, DALIDataType::DALI_INT32); label_output.mutable_data()[0] = sample.label_; + out_index++; + } + if (has_frame_no_) { + auto &frame_no_output = ws.Output(out_index); + frame_no_output.Resize({}, DALIDataType::DALI_INT32); + frame_no_output.mutable_data()[0] = sample.first_frame_; + out_index++; } } namespace detail { inline int VideoReaderDecoderOutputFn(const OpSpec &spec) { - return spec.HasArgument("labels") ? 2 : 1; + int num_outputs = 1; + if (spec.HasArgument("labels")) num_outputs++; + bool enable_frame_num = spec.GetArgument("enable_frame_num"); + if (enable_frame_num) num_outputs++; + return num_outputs; } } // namespace detail @@ -68,6 +81,10 @@ even in the variable frame rate scenario.)code") .AddArg("sequence_length", R"code(Frames to load per sequence.)code", DALI_INT32) + .AddOptionalArg("enable_frame_num", + R"code(If set, returns the first frame number in the decoded sequence +as a separate output.)code", + false) .AddOptionalArg("step", R"code(Frame interval between each sequence. diff --git a/dali/operators/reader/video_reader_decoder_cpu_op.h b/dali/operators/reader/video_reader_decoder_cpu_op.h index 3292e8fe777..2d32edec6b8 100644 --- a/dali/operators/reader/video_reader_decoder_cpu_op.h +++ b/dali/operators/reader/video_reader_decoder_cpu_op.h @@ -29,6 +29,7 @@ class VideoReaderDecoderCpu private: bool has_labels_ = false; + bool has_frame_no_ = false; }; } // namespace dali diff --git a/dali/operators/reader/video_reader_decoder_gpu_op.cc b/dali/operators/reader/video_reader_decoder_gpu_op.cc index 3e570490b8d..06c44c2bdac 100644 --- a/dali/operators/reader/video_reader_decoder_gpu_op.cc +++ b/dali/operators/reader/video_reader_decoder_gpu_op.cc @@ -20,7 +20,8 @@ namespace dali { VideoReaderDecoderGpu::VideoReaderDecoderGpu(const OpSpec &spec) : DataReader(spec), - has_labels_(spec.HasArgument("labels")) { + has_labels_(spec.HasArgument("labels")), + has_frame_no_(spec.GetArgument("enable_frame_num")) { loader_ = InitLoader(spec); this->SetInitialSnapshot(); } @@ -50,14 +51,21 @@ bool VideoReaderDecoderGpu::SetupImpl( output_desc[0] = { video_shape, DALI_UINT8 }; - if (!has_labels_) { - return true; + int out_index = 1; + if (has_labels_) { + output_desc[out_index] = { + uniform_list_shape<1>(batch_size, {1}), + DALI_INT32 + }; + out_index++; + } + if (has_frame_no_) { + output_desc[out_index] = { + uniform_list_shape<1>(batch_size, {1}), + DALI_INT32 + }; + out_index++; } - - output_desc[1] = { - uniform_list_shape<1>(batch_size, {1}), - DALI_INT32 - }; return true; } @@ -80,23 +88,39 @@ void VideoReaderDecoderGpu::RunImpl(Workspace &ws) { video_output.SetSourceInfo(sample_id, sample.data_.GetSourceInfo()); } - if (!has_labels_) { - return; - } + int out_index = 1; + if (has_labels_) { + auto &labels_output = ws.Output(out_index); + SmallVector labels_cpu; - auto &labels_output = ws.Output(1); - SmallVector labels_cpu; + for (int sample_id = 0; sample_id < batch_size; ++sample_id) { + auto &sample = GetSample(sample_id); + labels_cpu[sample_id] = sample.label_; + } - for (int sample_id = 0; sample_id < batch_size; ++sample_id) { - auto &sample = GetSample(sample_id); - labels_cpu[sample_id] = sample.label_; + MemCopy( + labels_output.AsTensor().raw_mutable_data(), + labels_cpu.data(), + batch_size * sizeof(DALI_INT32), + ws.stream()); + out_index++; } + if (has_frame_no_) { + auto &frame_no_output = ws.Output(out_index); + SmallVector frame_no_output_cpu; + + for (int sample_id = 0; sample_id < batch_size; ++sample_id) { + auto &sample = GetSample(sample_id); + frame_no_output_cpu[sample_id] = sample.span_ ? sample.span_->start_ : -1; + } - MemCopy( - labels_output.AsTensor().raw_mutable_data(), - labels_cpu.data(), - batch_size * sizeof(DALI_INT32), - ws.stream()); + MemCopy( + frame_no_output.AsTensor().raw_mutable_data(), + frame_no_output_cpu.data(), + batch_size * sizeof(DALI_INT32), + ws.stream()); + out_index++; + } } DALI_REGISTER_OPERATOR(experimental__readers__Video, VideoReaderDecoderGpu, GPU); diff --git a/dali/operators/reader/video_reader_decoder_gpu_op.h b/dali/operators/reader/video_reader_decoder_gpu_op.h index e452554b57a..a496f9ec990 100644 --- a/dali/operators/reader/video_reader_decoder_gpu_op.h +++ b/dali/operators/reader/video_reader_decoder_gpu_op.h @@ -35,6 +35,7 @@ class VideoReaderDecoderGpu : public DataReader + int GetFrameNo(dali::TensorList &device_frame_no); + private: template void RunTestImpl( @@ -129,15 +132,15 @@ class VideoReaderDecoderBaseTest : public VideoTestBase { .AddArg("device", backend) .AddArg("sequence_length", sequence_length) .AddArg("random_shuffle", true) + .AddArg("enable_frame_num", true) .AddArg("initial_fill", cfr_videos_[0].NumFrames()) .AddArg( "filenames", std::vector{cfr_videos_paths_[0]}) - .AddOutput("frames", backend)); - - pipe.Build({{"frames", backend}}); + .AddOutput("frames", backend) + .AddOutput("frame_no", backend)); - std::vector expected_order = {29, 46, 33, 6, 37}; + pipe.Build({{"frames", backend}, {"frame_no", backend}}); int num_sequences = 5; @@ -148,9 +151,10 @@ class VideoReaderDecoderBaseTest : public VideoTestBase { auto &frame_video_output = ws.Output(0); const auto sample = frame_video_output.template tensor(0); + int frame_no = GetFrameNo(ws.Output(1)); - // We want to access correct order, so we comapre only the first frame of the sequence - AssertFrame(expected_order[sequence_id], sample, ground_truth_video); + // We want to access correct order, so we compare only the first frame of the sequence + AssertFrame(frame_no, sample, ground_truth_video); } } }; @@ -168,6 +172,15 @@ void VideoReaderDecoderBaseTest::RunShuffleTest() { RunShuffleTestImpl("cpu", dali::CPU_ONLY_DEVICE_ID); } +template<> +int VideoReaderDecoderBaseTest::GetFrameNo( + dali::TensorList &device_frame_no) { + const auto frame_no = device_frame_no.template tensor(0); + int frame_no_buffer = -1; + std::copy_n(frame_no, 1, &frame_no_buffer); + return frame_no_buffer; +} + template<> void VideoReaderDecoderBaseTest::RunTest( std::vector &videos_paths, @@ -181,6 +194,15 @@ void VideoReaderDecoderBaseTest::RunShuffleTest() { RunShuffleTestImpl("gpu", 0); } +template<> +int VideoReaderDecoderBaseTest::GetFrameNo( + dali::TensorList &device_frame_no) { + const auto frame_no = device_frame_no.template tensor(0); + int frame_no_buffer = -1; + MemCopy(&frame_no_buffer, frame_no, sizeof(int)); + return frame_no_buffer; +} + class VideoReaderDecoderCpuTest : public VideoReaderDecoderBaseTest { public: void AssertLabel(const int *label, int ground_truth_label) override { From f621fe6b6707c13541f6df1241f6bffce0790e0d Mon Sep 17 00:00:00 2001 From: Janusz Lisiecki Date: Tue, 10 Sep 2024 11:33:51 +0200 Subject: [PATCH 2/5] Review fix Signed-off-by: Janusz Lisiecki --- .../operators/reader/loader/video/video_loader_decoder_base.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dali/operators/reader/loader/video/video_loader_decoder_base.h b/dali/operators/reader/loader/video/video_loader_decoder_base.h index 4413f53ac6e..a9c6784ea3e 100644 --- a/dali/operators/reader/loader/video/video_loader_decoder_base.h +++ b/dali/operators/reader/loader/video/video_loader_decoder_base.h @@ -35,8 +35,8 @@ template class VideoSample { public: Tensor data_; - int label_; - int first_frame_; + int label_ = -1; + int first_frame_ = -1; }; class VideoLoaderDecoderBase { From ec7fa6874e33e34aa8b8d6f7b963be74388644c9 Mon Sep 17 00:00:00 2001 From: Janusz Lisiecki Date: Tue, 10 Sep 2024 12:34:29 +0200 Subject: [PATCH 3/5] Review fixes Signed-off-by: Janusz Lisiecki --- .../loader/video/video_loader_decoder_base.h | 4 ++-- .../loader/video/video_loader_decoder_cpu.cc | 2 +- .../reader/video_reader_decoder_cpu_op.cc | 12 +++++------- .../reader/video_reader_decoder_cpu_op.h | 2 +- .../reader/video_reader_decoder_gpu_op.cc | 6 +++--- .../reader/video_reader_decoder_gpu_op.h | 2 +- .../reader/video_reader_decoder_op_test.cc | 16 ++++++++-------- 7 files changed, 21 insertions(+), 23 deletions(-) diff --git a/dali/operators/reader/loader/video/video_loader_decoder_base.h b/dali/operators/reader/loader/video/video_loader_decoder_base.h index a9c6784ea3e..79087d28542 100644 --- a/dali/operators/reader/loader/video/video_loader_decoder_base.h +++ b/dali/operators/reader/loader/video/video_loader_decoder_base.h @@ -47,7 +47,7 @@ class VideoLoaderDecoderBase { stride_(spec.GetArgument("stride")), step_(spec.GetArgument("step")) { has_labels_ = spec.TryGetRepeatedArgument(labels_, "labels"); - has_frame_no_ = spec.GetArgument("enable_frame_num"); + has_frame_idx_ = spec.GetArgument("enable_frame_num"); DALI_ENFORCE( !has_labels_ || labels_.size() == filenames_.size(), make_string( @@ -63,7 +63,7 @@ class VideoLoaderDecoderBase { std::vector filenames_; std::vector labels_; bool has_labels_ = false; - bool has_frame_no_ = false; + bool has_frame_idx_ = false; Index current_index_ = 0; diff --git a/dali/operators/reader/loader/video/video_loader_decoder_cpu.cc b/dali/operators/reader/loader/video/video_loader_decoder_cpu.cc index 20743462060..3a3a3715d8a 100644 --- a/dali/operators/reader/loader/video/video_loader_decoder_cpu.cc +++ b/dali/operators/reader/loader/video/video_loader_decoder_cpu.cc @@ -45,7 +45,7 @@ void VideoLoaderDecoderCpu::ReadSample(VideoSample &sample) { if (has_labels_) { sample.label_ = labels_[sample_span.video_idx_]; } - if (has_frame_no_) { + if (has_frame_idx_) { sample.first_frame_ = sample_span.start_; } } diff --git a/dali/operators/reader/video_reader_decoder_cpu_op.cc b/dali/operators/reader/video_reader_decoder_cpu_op.cc index 09a5ece3741..faf1eceb4bc 100644 --- a/dali/operators/reader/video_reader_decoder_cpu_op.cc +++ b/dali/operators/reader/video_reader_decoder_cpu_op.cc @@ -50,11 +50,9 @@ void VideoReaderDecoderCpu::RunImpl(SampleWorkspace &ws) { namespace detail { inline int VideoReaderDecoderOutputFn(const OpSpec &spec) { - int num_outputs = 1; - if (spec.HasArgument("labels")) num_outputs++; - bool enable_frame_num = spec.GetArgument("enable_frame_num"); - if (enable_frame_num) num_outputs++; - return num_outputs; + bool has_labels = spec.HasArgument("labels") + bool has_frame_num_output = spec.GetArgument("enable_frame_num"); + return 1 + has_labels + has_frame_num_output; } } // namespace detail @@ -82,8 +80,8 @@ even in the variable frame rate scenario.)code") R"code(Frames to load per sequence.)code", DALI_INT32) .AddOptionalArg("enable_frame_num", - R"code(If set, returns the first frame number in the decoded sequence -as a separate output.)code", + R"code(If set, returns the index of the first frame in the decoded sequence +as an additional output.)code", false) .AddOptionalArg("step", R"code(Frame interval between each sequence. diff --git a/dali/operators/reader/video_reader_decoder_cpu_op.h b/dali/operators/reader/video_reader_decoder_cpu_op.h index 2d32edec6b8..9912f18bcd3 100644 --- a/dali/operators/reader/video_reader_decoder_cpu_op.h +++ b/dali/operators/reader/video_reader_decoder_cpu_op.h @@ -29,7 +29,7 @@ class VideoReaderDecoderCpu private: bool has_labels_ = false; - bool has_frame_no_ = false; + bool has_frame_idx_ = false; }; } // namespace dali diff --git a/dali/operators/reader/video_reader_decoder_gpu_op.cc b/dali/operators/reader/video_reader_decoder_gpu_op.cc index 06c44c2bdac..d9d105d2951 100644 --- a/dali/operators/reader/video_reader_decoder_gpu_op.cc +++ b/dali/operators/reader/video_reader_decoder_gpu_op.cc @@ -21,7 +21,7 @@ namespace dali { VideoReaderDecoderGpu::VideoReaderDecoderGpu(const OpSpec &spec) : DataReader(spec), has_labels_(spec.HasArgument("labels")), - has_frame_no_(spec.GetArgument("enable_frame_num")) { + has_frame_idx_(spec.GetArgument("enable_frame_num")) { loader_ = InitLoader(spec); this->SetInitialSnapshot(); } @@ -59,7 +59,7 @@ bool VideoReaderDecoderGpu::SetupImpl( }; out_index++; } - if (has_frame_no_) { + if (has_frame_idx_) { output_desc[out_index] = { uniform_list_shape<1>(batch_size, {1}), DALI_INT32 @@ -105,7 +105,7 @@ void VideoReaderDecoderGpu::RunImpl(Workspace &ws) { ws.stream()); out_index++; } - if (has_frame_no_) { + if (has_frame_idx_) { auto &frame_no_output = ws.Output(out_index); SmallVector frame_no_output_cpu; diff --git a/dali/operators/reader/video_reader_decoder_gpu_op.h b/dali/operators/reader/video_reader_decoder_gpu_op.h index a496f9ec990..64c24163e0c 100644 --- a/dali/operators/reader/video_reader_decoder_gpu_op.h +++ b/dali/operators/reader/video_reader_decoder_gpu_op.h @@ -35,7 +35,7 @@ class VideoReaderDecoderGpu : public DataReader - int GetFrameNo(dali::TensorList &device_frame_no); + int GetFrameIdx(dali::TensorList &device_frame_idx); private: template @@ -151,7 +151,7 @@ class VideoReaderDecoderBaseTest : public VideoTestBase { auto &frame_video_output = ws.Output(0); const auto sample = frame_video_output.template tensor(0); - int frame_no = GetFrameNo(ws.Output(1)); + int frame_no = GetFrameIdx(ws.Output(1)); // We want to access correct order, so we compare only the first frame of the sequence AssertFrame(frame_no, sample, ground_truth_video); @@ -173,9 +173,9 @@ void VideoReaderDecoderBaseTest::RunShuffleTest() { } template<> -int VideoReaderDecoderBaseTest::GetFrameNo( - dali::TensorList &device_frame_no) { - const auto frame_no = device_frame_no.template tensor(0); +int VideoReaderDecoderBaseTest::GetFrameIdx( + dali::TensorList &device_frame_idx) { + const auto frame_no = device_frame_idx.template tensor(0); int frame_no_buffer = -1; std::copy_n(frame_no, 1, &frame_no_buffer); return frame_no_buffer; @@ -195,9 +195,9 @@ void VideoReaderDecoderBaseTest::RunShuffleTest() { } template<> -int VideoReaderDecoderBaseTest::GetFrameNo( - dali::TensorList &device_frame_no) { - const auto frame_no = device_frame_no.template tensor(0); +int VideoReaderDecoderBaseTest::GetFrameIdx( + dali::TensorList &device_frame_idx) { + const auto frame_no = device_frame_idx.template tensor(0); int frame_no_buffer = -1; MemCopy(&frame_no_buffer, frame_no, sizeof(int)); return frame_no_buffer; From b969f7b64d6f9b79a24930694418e7067077e047 Mon Sep 17 00:00:00 2001 From: Janusz Lisiecki Date: Tue, 10 Sep 2024 12:42:22 +0200 Subject: [PATCH 4/5] More review fixed Signed-off-by: Janusz Lisiecki --- .../reader/video_reader_decoder_cpu_op.cc | 10 ++++---- .../reader/video_reader_decoder_gpu_op.cc | 10 ++++---- .../reader/video_reader_decoder_op_test.cc | 24 +++++++++---------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/dali/operators/reader/video_reader_decoder_cpu_op.cc b/dali/operators/reader/video_reader_decoder_cpu_op.cc index faf1eceb4bc..6c1d9400ac3 100644 --- a/dali/operators/reader/video_reader_decoder_cpu_op.cc +++ b/dali/operators/reader/video_reader_decoder_cpu_op.cc @@ -21,7 +21,7 @@ namespace dali { VideoReaderDecoderCpu::VideoReaderDecoderCpu(const OpSpec &spec) : DataReader(spec), has_labels_(spec.HasArgument("labels")), - has_frame_no_(spec.GetArgument("enable_frame_num")) { + has_frame_idx_(spec.GetArgument("enable_frame_num")) { loader_ = InitLoader(spec); this->SetInitialSnapshot(); } @@ -40,10 +40,10 @@ void VideoReaderDecoderCpu::RunImpl(SampleWorkspace &ws) { label_output.mutable_data()[0] = sample.label_; out_index++; } - if (has_frame_no_) { - auto &frame_no_output = ws.Output(out_index); - frame_no_output.Resize({}, DALIDataType::DALI_INT32); - frame_no_output.mutable_data()[0] = sample.first_frame_; + if (has_frame_idx_) { + auto &frame_idx_output = ws.Output(out_index); + frame_idx_output.Resize({}, DALIDataType::DALI_INT32); + frame_idx_output.mutable_data()[0] = sample.first_frame_; out_index++; } } diff --git a/dali/operators/reader/video_reader_decoder_gpu_op.cc b/dali/operators/reader/video_reader_decoder_gpu_op.cc index d9d105d2951..ec09f7741d9 100644 --- a/dali/operators/reader/video_reader_decoder_gpu_op.cc +++ b/dali/operators/reader/video_reader_decoder_gpu_op.cc @@ -106,17 +106,17 @@ void VideoReaderDecoderGpu::RunImpl(Workspace &ws) { out_index++; } if (has_frame_idx_) { - auto &frame_no_output = ws.Output(out_index); - SmallVector frame_no_output_cpu; + auto &frame_idx_output = ws.Output(out_index); + SmallVector frame_idx_output_cpu; for (int sample_id = 0; sample_id < batch_size; ++sample_id) { auto &sample = GetSample(sample_id); - frame_no_output_cpu[sample_id] = sample.span_ ? sample.span_->start_ : -1; + frame_idx_output_cpu[sample_id] = sample.span_ ? sample.span_->start_ : -1; } MemCopy( - frame_no_output.AsTensor().raw_mutable_data(), - frame_no_output_cpu.data(), + frame_idx_output.AsTensor().raw_mutable_data(), + frame_idx_output_cpu.data(), batch_size * sizeof(DALI_INT32), ws.stream()); out_index++; diff --git a/dali/operators/reader/video_reader_decoder_op_test.cc b/dali/operators/reader/video_reader_decoder_op_test.cc index 5f215d2923b..ba5936f0a64 100644 --- a/dali/operators/reader/video_reader_decoder_op_test.cc +++ b/dali/operators/reader/video_reader_decoder_op_test.cc @@ -138,9 +138,9 @@ class VideoReaderDecoderBaseTest : public VideoTestBase { "filenames", std::vector{cfr_videos_paths_[0]}) .AddOutput("frames", backend) - .AddOutput("frame_no", backend)); + .AddOutput("frame_idx", backend)); - pipe.Build({{"frames", backend}, {"frame_no", backend}}); + pipe.Build({{"frames", backend}, {"frame_idx", backend}}); int num_sequences = 5; @@ -151,10 +151,10 @@ class VideoReaderDecoderBaseTest : public VideoTestBase { auto &frame_video_output = ws.Output(0); const auto sample = frame_video_output.template tensor(0); - int frame_no = GetFrameIdx(ws.Output(1)); + int frame_idx = GetFrameIdx(ws.Output(1)); // We want to access correct order, so we compare only the first frame of the sequence - AssertFrame(frame_no, sample, ground_truth_video); + AssertFrame(frame_idx, sample, ground_truth_video); } } }; @@ -175,10 +175,10 @@ void VideoReaderDecoderBaseTest::RunShuffleTest() { template<> int VideoReaderDecoderBaseTest::GetFrameIdx( dali::TensorList &device_frame_idx) { - const auto frame_no = device_frame_idx.template tensor(0); - int frame_no_buffer = -1; - std::copy_n(frame_no, 1, &frame_no_buffer); - return frame_no_buffer; + const auto frame_idx = device_frame_idx.template tensor(0); + int frame_idx_buffer = -1; + std::copy_n(frame_idx, 1, &frame_idx_buffer); + return frame_idx_buffer; } template<> @@ -197,10 +197,10 @@ void VideoReaderDecoderBaseTest::RunShuffleTest() { template<> int VideoReaderDecoderBaseTest::GetFrameIdx( dali::TensorList &device_frame_idx) { - const auto frame_no = device_frame_idx.template tensor(0); - int frame_no_buffer = -1; - MemCopy(&frame_no_buffer, frame_no, sizeof(int)); - return frame_no_buffer; + const auto frame_idx = device_frame_idx.template tensor(0); + int frame_idx_buffer = -1; + MemCopy(&frame_idx_buffer, frame_idx, sizeof(int)); + return frame_idx_buffer; } class VideoReaderDecoderCpuTest : public VideoReaderDecoderBaseTest { From a8d08cb1f4663351e516f7fbec40731bf46edd51 Mon Sep 17 00:00:00 2001 From: Janusz Lisiecki Date: Tue, 10 Sep 2024 20:21:07 +0200 Subject: [PATCH 5/5] Fix Signed-off-by: Janusz Lisiecki --- dali/operators/reader/video_reader_decoder_cpu_op.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dali/operators/reader/video_reader_decoder_cpu_op.cc b/dali/operators/reader/video_reader_decoder_cpu_op.cc index 6c1d9400ac3..72826a16619 100644 --- a/dali/operators/reader/video_reader_decoder_cpu_op.cc +++ b/dali/operators/reader/video_reader_decoder_cpu_op.cc @@ -50,7 +50,7 @@ void VideoReaderDecoderCpu::RunImpl(SampleWorkspace &ws) { namespace detail { inline int VideoReaderDecoderOutputFn(const OpSpec &spec) { - bool has_labels = spec.HasArgument("labels") + bool has_labels = spec.HasArgument("labels"); bool has_frame_num_output = spec.GetArgument("enable_frame_num"); return 1 + has_labels + has_frame_num_output; }