Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
Signed-off-by: Janusz Lisiecki <[email protected]>
  • Loading branch information
JanuszL committed Sep 9, 2024
1 parent d886ad6 commit 2eaa801
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions dali/operators/reader/video_reader_decoder_op_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,23 @@ class VideoReaderDecoderBaseTest : public VideoTestBase {
auto &ground_truth_video = cfr_videos_[0];

Pipeline pipe(batch_size, 1, device_id, seed);
std::vector<std::int> labels(cfr_videos_[0].NumFrames());
std::iota(a.begin(), a.end(), 1);

pipe.AddOperator(OpSpec("experimental__readers__Video")
.AddArg("device", backend)
.AddArg("sequence_length", sequence_length)
.AddArg("random_shuffle", true)
.AddArg("initial_fill", cfr_videos_[0].NumFrames())
.AddArg(
"labels", labels)
.AddArg(
"filenames",
std::vector<std::string>{cfr_videos_paths_[0]})
.AddOutput("frames", backend));
.AddOutput("frames", backend)
.AddOutput("frame_labels", backend));

pipe.Build({{"frames", backend}});
pipe.Build({{"frames", backend}, {"frame_labels", backend}});

// ToFix
std::vector<int> expected_order = {29, 46, 33, 6, 37};
Expand All @@ -148,7 +153,12 @@ class VideoReaderDecoderBaseTest : public VideoTestBase {
pipe.Outputs(&ws);

auto &frame_video_output = ws.Output<Backend>(0);
auto &cpu_label_output = ws.Output<Backend(1);
const auto sample = frame_video_output.template tensor<uint8_t>(0);
const auto cpu_label = cpu_label_output.tensor<int>(sample_id);
int label_buffer = -1;
MemCopy(&label_buffer, cpu_label, sizeof(int));
std::cout << " labels " << label_buffer << " vs " << expected_order[sequence_id],

// We want to access correct order, so we compare only the first frame of the sequence
AssertFrame(expected_order[sequence_id], sample, ground_truth_video);
Expand Down

0 comments on commit 2eaa801

Please sign in to comment.