perf_utils.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. //
  5. // Copyright (C) 2017, Intel Corporation, all rights reserved.
  6. // Third party copyrights are property of their respective owners.
  7. #include "perf_precomp.hpp"
  8. namespace opencv_test {
  9. using Utils_blobFromImage = TestBaseWithParam<std::vector<int>>;
  10. PERF_TEST_P_(Utils_blobFromImage, HWC_TO_NCHW) {
  11. std::vector<int> input_shape = GetParam();
  12. Mat input(input_shape, CV_32FC3);
  13. randu(input, -10.0f, 10.f);
  14. TEST_CYCLE() {
  15. Mat blob = blobFromImage(input);
  16. }
  17. SANITY_CHECK_NOTHING();
  18. }
  19. INSTANTIATE_TEST_CASE_P(/**/, Utils_blobFromImage,
  20. Values(std::vector<int>{ 32, 32},
  21. std::vector<int>{ 64, 64},
  22. std::vector<int>{ 128, 128},
  23. std::vector<int>{ 256, 256},
  24. std::vector<int>{ 512, 512},
  25. std::vector<int>{1024, 1024},
  26. std::vector<int>{2048, 2048})
  27. );
  28. using Utils_blobFromImages = TestBaseWithParam<std::vector<int>>;
  29. PERF_TEST_P_(Utils_blobFromImages, HWC_TO_NCHW) {
  30. std::vector<int> input_shape = GetParam();
  31. int batch = input_shape.front();
  32. std::vector<int> input_shape_no_batch(input_shape.begin()+1, input_shape.end());
  33. std::vector<Mat> inputs;
  34. for (int i = 0; i < batch; i++) {
  35. Mat input(input_shape_no_batch, CV_32FC3);
  36. randu(input, -10.0f, 10.f);
  37. inputs.push_back(input);
  38. }
  39. TEST_CYCLE() {
  40. Mat blobs = blobFromImages(inputs);
  41. }
  42. SANITY_CHECK_NOTHING();
  43. }
  44. INSTANTIATE_TEST_CASE_P(/**/, Utils_blobFromImages,
  45. Values(std::vector<int>{16, 32, 32},
  46. std::vector<int>{16, 64, 64},
  47. std::vector<int>{16, 128, 128},
  48. std::vector<int>{16, 256, 256},
  49. std::vector<int>{16, 512, 512},
  50. std::vector<int>{16, 1024, 1024},
  51. std::vector<int>{16, 2048, 2048})
  52. );
  53. }