MCPcopy Create free account
hub / github.com/NVIDIA/DALI / DecoderPipelineTest

Method DecoderPipelineTest

dali/benchmark/decoder_bench.cc:26–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24class DecoderBench : public DALIBenchmark {
25 public:
26 void DecoderPipelineTest(benchmark::State& st,
27 int batch_size,
28 int num_thread,
29 std::string output_device,
30 const OpSpec &decoder_operator,
31 std::function<void(Pipeline&)> add_other_inputs = {}) {
32 DALIImageType img_type = DALI_RGB;
33
34 // Create the pipeline
35 Pipeline pipe(
36 batch_size,
37 num_thread,
38 0, -1,
39 true, // pipelined
40 2, // pipe length
41 true); // async
42
43 TensorList<CPUBackend> data;
44 this->MakeJPEGBatch(&data, batch_size);
45 pipe.AddExternalInput("raw_jpegs");
46
47 if (add_other_inputs)
48 add_other_inputs(pipe);
49
50 pipe.AddOperator(decoder_operator);
51
52 // Build and run the pipeline
53 vector<std::pair<string, string>> outputs = {{"images", output_device}};
54 pipe.Build(outputs);
55
56 // Run once to allocate the memory
57 Workspace ws;
58 pipe.SetExternalInput("raw_jpegs", data);
59 pipe.Run();
60 pipe.Outputs(&ws);
61
62 while (st.KeepRunning()) {
63 if (st.iterations() == 1) {
64 // We will start the processing for the next batch
65 // immediately after issueing work to the gpu to
66 // pipeline the cpu/copy/gpu work
67 pipe.SetExternalInput("raw_jpegs", data);
68 pipe.Run();
69 }
70
71 pipe.SetExternalInput("raw_jpegs", data);
72 pipe.Run();
73 pipe.Outputs(&ws);
74
75 if (st.iterations() == st.max_iterations) {
76 // Block for the last batch to finish
77 pipe.Outputs(&ws);
78 }
79 }
80
81 // WriteCHWBatch<float16>(ws.Output<GPUBackend>(0), 128, 1, "img");
82 int num_batches = st.iterations() + 1;
83 st.counters["FPS"] = benchmark::Counter(batch_size*num_batches,

Calls 6

AddExternalInputMethod · 0.80
MakeJPEGBatchMethod · 0.45
AddOperatorMethod · 0.45
BuildMethod · 0.45
RunMethod · 0.45
OutputsMethod · 0.45

Tested by

no test coverage detected