@@ -182,21 +182,6 @@ TYPED_TEST(nvjpegDecodeDecoupledAPITest, TestSingleTiffDecode4T) {
182182 this ->TiffTestDecode (4 );
183183}
184184
185- #if NVJPEG_VER_MAJOR >= 11 && NVML_ENABLED
186- void PrintDeviceInfo () {
187- unsigned int device_count;
188- auto nvml_handle = nvml::NvmlInstance::CreateNvmlInstance ();
189- CUDA_CALL (nvmlDeviceGetCount_v2 (&device_count));
190- for (unsigned int device_idx = 0 ; device_idx < device_count; device_idx++) {
191- auto info = nvml::GetDeviceInfo (device_idx);
192- std::cerr << " Device " << device_idx
193- << " brand " << info.type
194- << " cc_M " << info.cap_major
195- << " cc_m " << info.cap_minor
196- << std::endl;
197- }
198- }
199-
200185/* *
201186 * @brief Return true if current configuration should be using HW decoder
202187 */
@@ -238,73 +223,6 @@ class CudaDecoderUtilizationTest : public ::testing::Test {
238223 std::string decoder_name_ = " Lorem Ipsum" ;
239224};
240225
241- TEST_F (CudaDecoderUtilizationTest, UtilizationTest) {
242- this ->pipeline_ .Run ();
243-
244- auto op = this ->pipeline_ .GetOperator (this ->decoder_name_ );
245- auto nsamples_hw = op->GetDiagnostic <int64_t >(" nsamples_hw" );
246- auto nsamples_cuda = op->GetDiagnostic <int64_t >(" nsamples_cuda" );
247- auto nsamples_host = op->GetDiagnostic <int64_t >(" nsamples_host" );
248- EXPECT_EQ (nsamples_hw, 0 );
249- EXPECT_EQ (nsamples_cuda, 47 ) << " HW Decoder malfunction: incorrect number "
250- " of images decoded by CUDA" ;
251- EXPECT_EQ (nsamples_host, 0 )
252- << " Image decoding malfuntion: all images should've been decoded by CUDA or HW" ;
253- }
254-
255- class HwDecoderUtilizationTest : public ::testing::Test {
256- public:
257- void SetUp () final {
258- dali::string list_root (testing::dali_extra_path () + " /db/single/jpeg" );
259-
260- pipeline_.AddOperator (
261- OpSpec (" FileReader" )
262- .AddArg (" device" , " cpu" )
263- .AddArg (" file_root" , list_root)
264- .AddOutput (" compressed_images" , StorageDevice::CPU)
265- .AddOutput (" labels" , StorageDevice::CPU));
266- auto decoder_spec =
267- OpSpec (" ImageDecoder" )
268- .AddArg (" device" , " mixed" )
269- .AddArg (" output_type" , DALI_RGB)
270- .AddArg (" hw_decoder_load" , 1 .f )
271- .AddInput (" compressed_images" , StorageDevice::CPU)
272- .AddOutput (" images" , StorageDevice::GPU);
273- pipeline_.AddOperator (decoder_spec, decoder_name_);
274-
275- pipeline_.Build (outputs_);
276-
277- auto op = pipeline_.GetOperator (decoder_name_);
278- if (!op->GetDiagnostic <bool >(" using_hw_decoder" )) {
279- PrintDeviceInfo ();
280- if (ShouldUseHwDecoder ()) {
281- FAIL () << " HW Decoder exists in the system and failed to open" ;
282- }
283- GTEST_SKIP ();
284- }
285- }
286-
287-
288- int batch_size_ = 47 ;
289- Pipeline pipeline_{batch_size_, 1 , 0 , -1 , false , 2 , false };
290- vector<std::pair<string, string>> outputs_ = {{" images" , " gpu" }};
291- std::string decoder_name_ = " Lorem Ipsum" ;
292- };
293-
294-
295- TEST_F (HwDecoderUtilizationTest, UtilizationTest) {
296- this ->pipeline_ .Run ();
297-
298- auto op = this ->pipeline_ .GetOperator (this ->decoder_name_ );
299- auto nsamples_hw = op->GetDiagnostic <int64_t >(" nsamples_hw" );
300- auto nsamples_cuda = op->GetDiagnostic <int64_t >(" nsamples_cuda" );
301- auto nsamples_host = op->GetDiagnostic <int64_t >(" nsamples_host" );
302- EXPECT_EQ (nsamples_hw, 47 ) << " HW Decoder malfunction: incorrect number of images decoded in HW" ;
303- EXPECT_EQ (nsamples_cuda, 0 );
304- EXPECT_EQ (nsamples_host, 0 )
305- << " Image decoding malfuntion: all images should've been decoded by CUDA or HW" ;
306- }
307-
308226class HwDecoderMemoryPoolTest : public ::testing::Test {
309227 public:
310228 void SetUp () final {
@@ -341,222 +259,5 @@ TEST_F(HwDecoderMemoryPoolTest, MemoryPoolTest) {
341259 this ->pipeline_ .Run ();
342260}
343261
344- class HwDecoderSliceUtilizationTest : public ::testing::Test {
345- public:
346- void SetUp () final {
347- dali::string list_root (testing::dali_extra_path () + " /db/single/jpeg" );
348-
349- auto shape = uniform_list_shape (batch_size_, {2 });
350- TensorList<CPUBackend> begin_data;
351- begin_data.Resize (shape, DALI_FLOAT);
352- float crop_x = 0 .25f , crop_y = 0 .124f ;
353- for (int k = 0 ; k < batch_size_; k++) {
354- begin_data.mutable_tensor <float >(k)[0 ] = crop_x;
355- begin_data.mutable_tensor <float >(k)[1 ] = crop_y;
356- }
357-
358- TensorList<CPUBackend> crop_data;
359- float crop_w = 0 .5f , crop_h = 0 .25f ;
360- crop_data.Resize (shape, DALI_FLOAT);
361- for (int k = 0 ; k < batch_size_; k++) {
362- crop_data.mutable_tensor <float >(k)[0 ] = crop_w;
363- crop_data.mutable_tensor <float >(k)[1 ] = crop_h;
364- }
365-
366- pipeline_.AddOperator (
367- OpSpec (" FileReader" )
368- .AddArg (" device" , " cpu" )
369- .AddArg (" file_root" , list_root)
370- .AddOutput (" compressed_images" , StorageDevice::CPU)
371- .AddOutput (" labels" , StorageDevice::CPU));
372- auto decoder_spec =
373- OpSpec (" ImageDecoderSlice" )
374- .AddArg (" device" , " mixed" )
375- .AddArg (" output_type" , DALI_RGB)
376- .AddArg (" hw_decoder_load" , 1 .f )
377- .AddInput (" compressed_images" , StorageDevice::CPU)
378- .AddInput (" begin_data" , StorageDevice::CPU)
379- .AddInput (" crop_data" , StorageDevice::CPU)
380- .AddOutput (" images" , StorageDevice::GPU);
381- pipeline_.AddExternalInput (" begin_data" );
382- pipeline_.AddExternalInput (" crop_data" );
383- pipeline_.AddOperator (decoder_spec, decoder_name_);
384-
385- pipeline_.Build (outputs_);
386- pipeline_.SetExternalInput (" begin_data" , begin_data);
387- pipeline_.SetExternalInput (" crop_data" , crop_data);
388-
389- auto op = pipeline_.GetOperator (decoder_name_);
390- if (!op->GetDiagnostic <bool >(" using_hw_decoder_roi" )) {
391- PrintDeviceInfo ();
392- if (ShouldUseHwDecoder ()) {
393- FAIL () << " HW Decoder exists in the system and failed to open" ;
394- }
395- GTEST_SKIP ();
396- }
397- }
398-
399- int batch_size_ = 47 ;
400- Pipeline pipeline_{batch_size_, 1 , 0 , -1 , false , 2 , false };
401- vector<std::pair<string, string>> outputs_ = {{" images" , " gpu" }};
402- std::string decoder_name_ = " Lorem Ipsum" ;
403- };
404-
405- TEST_F (HwDecoderSliceUtilizationTest, UtilizationTest) {
406- this ->pipeline_ .Run ();
407-
408- auto op = this ->pipeline_ .GetOperator (this ->decoder_name_ );
409- auto nsamples_hw = op->GetDiagnostic <int64_t >(" nsamples_hw" );
410- auto nsamples_cuda = op->GetDiagnostic <int64_t >(" nsamples_cuda" );
411- auto nsamples_host = op->GetDiagnostic <int64_t >(" nsamples_host" );
412- EXPECT_EQ (nsamples_hw, 47 ) << " HW Decoder malfunction: incorrect number of images decoded in HW" ;
413- EXPECT_EQ (nsamples_cuda, 0 );
414- EXPECT_EQ (nsamples_host, 0 )
415- << " Image decoding malfunction: all images should've been decoded by CUDA or HW" ;
416- }
417-
418- class HwDecoderCropUtilizationTest : public ::testing::Test {
419- public:
420- void SetUp () final {
421- dali::string list_root (testing::dali_extra_path () + " /db/single/jpeg" );
422-
423- pipeline_.AddOperator (
424- OpSpec (" FileReader" )
425- .AddArg (" device" , " cpu" )
426- .AddArg (" file_root" , list_root)
427- .AddOutput (" compressed_images" , StorageDevice::CPU)
428- .AddOutput (" labels" , StorageDevice::CPU));
429- auto decoder_spec =
430- OpSpec (" ImageDecoderCrop" )
431- .AddArg (" device" , " mixed" )
432- .AddArg (" output_type" , DALI_RGB)
433- .AddArg (" hw_decoder_load" , 1 .f )
434- .AddArg (" crop" , std::vector<float >{224 .0f , 224 .0f })
435- .AddInput (" compressed_images" , StorageDevice::CPU)
436- .AddOutput (" images" , StorageDevice::GPU);
437- pipeline_.AddOperator (decoder_spec, decoder_name_);
438-
439- pipeline_.Build (outputs_);
440-
441- auto op = pipeline_.GetOperator (decoder_name_);
442- if (!op->GetDiagnostic <bool >(" using_hw_decoder_roi" )) {
443- PrintDeviceInfo ();
444- if (ShouldUseHwDecoder ()) {
445- FAIL () << " HW Decoder exists in the system and failed to open" ;
446- }
447- GTEST_SKIP ();
448- }
449- }
450-
451- int batch_size_ = 47 ;
452- Pipeline pipeline_{batch_size_, 1 , 0 , -1 , false , 2 , false };
453- vector<std::pair<string, string>> outputs_ = {{" images" , " gpu" }};
454- std::string decoder_name_ = " Lorem Ipsum" ;
455- };
456-
457- TEST_F (HwDecoderCropUtilizationTest, UtilizationTest) {
458- this ->pipeline_ .Run ();
459- auto op = this ->pipeline_ .GetOperator (this ->decoder_name_ );
460- auto nsamples_hw = op->GetDiagnostic <int64_t >(" nsamples_hw" );
461- auto nsamples_cuda = op->GetDiagnostic <int64_t >(" nsamples_cuda" );
462- auto nsamples_host = op->GetDiagnostic <int64_t >(" nsamples_host" );
463- EXPECT_EQ (nsamples_hw, 47 ) << " HW Decoder malfunction: incorrect number of images decoded in HW" ;
464- EXPECT_EQ (nsamples_cuda, 0 );
465- EXPECT_EQ (nsamples_host, 0 )
466- << " Image decoding malfuntion: all images should've been decoded by CUDA or HW" ;
467- }
468-
469-
470- class HwDecoderRandomCropUtilizationTest : public ::testing::Test {
471- public:
472- void SetUp () final {
473- dali::string list_root (testing::dali_extra_path () + " /db/single/jpeg" );
474-
475- pipeline_.AddOperator (
476- OpSpec (" FileReader" )
477- .AddArg (" device" , " cpu" )
478- .AddArg (" file_root" , list_root)
479- .AddOutput (" compressed_images" , StorageDevice::CPU)
480- .AddOutput (" labels" , StorageDevice::CPU));
481- auto decoder_spec =
482- OpSpec (" ImageDecoderRandomCrop" )
483- .AddArg (" device" , " mixed" )
484- .AddArg (" output_type" , DALI_RGB)
485- .AddArg (" hw_decoder_load" , 1 .f )
486- .AddInput (" compressed_images" , StorageDevice::CPU)
487- .AddOutput (" images" , StorageDevice::GPU);
488- pipeline_.AddOperator (decoder_spec, decoder_name_);
489-
490- pipeline_.Build (outputs_);
491-
492- auto op = pipeline_.GetOperator (decoder_name_);
493- if (!op->GetDiagnostic <bool >(" using_hw_decoder" )) {
494- PrintDeviceInfo ();
495- if (ShouldUseHwDecoder ()) {
496- FAIL () << " HW Decoder exists in the system and failed to open" ;
497- }
498- GTEST_SKIP ();
499- }
500- }
501-
502- int batch_size_ = 47 ;
503- Pipeline pipeline_{batch_size_, 1 , 0 , -1 , false , 2 , false };
504- vector<std::pair<string, string>> outputs_ = {{" images" , " gpu" }};
505- std::string decoder_name_ = " Lorem Ipsum" ;
506- };
507-
508- TEST_F (HwDecoderRandomCropUtilizationTest, UtilizationTest) {
509- this ->pipeline_ .Run ();
510- }
511- #endif // NVJPEG_VER_MAJOR >= 11 && NVML_ENABLED
512-
513- class Nvjpeg2kTest : public ::testing::Test {
514- public:
515- void SetUp () final {
516- dali::string list_root (testing::dali_extra_path () + " /db/single/jpeg2k" );
517-
518- pipeline_.AddOperator (
519- OpSpec (" FileReader" )
520- .AddArg (" device" , " cpu" )
521- .AddArg (" file_root" , list_root)
522- .AddOutput (" compressed_images" , StorageDevice::CPU)
523- .AddOutput (" labels" , StorageDevice::CPU));
524- auto decoder_spec =
525- OpSpec (" ImageDecoder" )
526- .AddArg (" device" , " mixed" )
527- .AddArg (" output_type" , DALI_RGB)
528- .AddInput (" compressed_images" , StorageDevice::CPU)
529- .AddOutput (" images" , StorageDevice::GPU);
530- pipeline_.AddOperator (decoder_spec, decoder_name_);
531-
532- pipeline_.Build (outputs_);
533- }
534-
535-
536- int batch_size_ = 21 ;
537- Pipeline pipeline_{batch_size_, 1 , 0 , -1 , false , 2 , false };
538- vector<std::pair<string, string>> outputs_ = {{" images" , " gpu" }};
539- std::string decoder_name_ = " Lorem Ipsum" ;
540- };
541-
542-
543- TEST_F (Nvjpeg2kTest, UtilizationTest) {
544- this ->pipeline_ .Run ();
545-
546- auto op = this ->pipeline_ .GetOperator (this ->decoder_name_ );
547- auto nsamples_nvjpeg2k = op->GetDiagnostic <int64_t >(" nsamples_nvjpeg2k" );
548- auto nsamples_host = op->GetDiagnostic <int64_t >(" nsamples_host" );
549- #if NVJPEG2K_ENABLED
550- std::cout << " Using nvJPEG2k" << std::endl;
551- EXPECT_EQ (nsamples_nvjpeg2k, 21 );
552- EXPECT_EQ (nsamples_host, 0 );
553- #else
554- std::cout << " Using CPU fallback" << std::endl;
555- EXPECT_EQ (nsamples_nvjpeg2k, 0 );
556- EXPECT_EQ (nsamples_host, 21 );
557- #endif // NVJPEG2K_ENABLED
558- }
559-
560-
561262} // namespace dali
562263
0 commit comments