You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_minddata_analyse.py 2.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Copyright 2020 Huawei Technologies Co., Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ============================================================================
  15. """
  16. Function:
  17. Test profiler to watch the performance of training.
  18. Usage:
  19. pytest tests/ut/profiler
  20. """
  21. import os
  22. from unittest import TestCase
  23. from mindinsight.profiler.analyser.analyser_factory import AnalyserFactory
  24. from ...profiler import BASE_SUMMARY_DIR
  25. class TestMinddataAnalyser(TestCase):
  26. """Test minddata analyser module."""
  27. def setUp(self) -> None:
  28. """Initialization before test case execution."""
  29. self.summary_dir = os.path.join(BASE_SUMMARY_DIR, "normal_run")
  30. self.profiler = os.path.join(self.summary_dir, "profiler")
  31. self._analyser = AnalyserFactory.instance().get_analyser(
  32. 'minddata', self.profiler, '1')
  33. def test_analyse_get_next_info_queue(self):
  34. """Test analysing the get_next operation info for info_type="queue" """
  35. expect_result = {
  36. "info": {"queue": [3, 2, 1]},
  37. "size": 3,
  38. "summary": {"queue_summary": {"empty_queue": 0}}
  39. }
  40. result, _ = self._analyser.analyse_get_next_info(info_type="queue")
  41. self.assertDictEqual(expect_result, result)
  42. def test_analyse_device_queue_info_queue(self):
  43. """Test analysing the device_queue operation info for info_type="queue" """
  44. expect_result = {
  45. "info": {"queue": [0]},
  46. "size": 1,
  47. "summary": {"queue_summary": {"empty_queue": 1, "full_queue": 0}}
  48. }
  49. result, _ = self._analyser.analyse_device_queue_info(info_type="queue")
  50. self.assertDictEqual(expect_result, result)