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 4.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. Fuction:
  17. Test profiler to watch the performance of training.
  18. Usage:
  19. pytest tests/st/func/profiler
  20. """
  21. import os
  22. import pytest
  23. from mindinsight.profiler.analyser.minddata_analyser import MinddataAnalyser
  24. from mindinsight.profiler.analyser.analyser_factory import AnalyserFactory
  25. from .conftest import BASE_SUMMARY_DIR_RUN_2
  26. class TestMinddataAnalyser:
  27. """Test minddata analyser module."""
  28. @classmethod
  29. def setup_class(cls):
  30. """Generate parsed files."""
  31. cls.summary_dir = os.path.join(BASE_SUMMARY_DIR_RUN_2, 'normal_run')
  32. cls.profiler = os.path.join(cls.summary_dir, 'profiler')
  33. def setup_method(self):
  34. """Create analyser."""
  35. self._analyser = AnalyserFactory.instance().get_analyser(
  36. 'minddata', self.profiler, '1')
  37. @pytest.mark.level0
  38. @pytest.mark.env_single
  39. @pytest.mark.platform_x86_cpu
  40. @pytest.mark.platform_arm_ascend_training
  41. @pytest.mark.platform_x86_gpu_training
  42. @pytest.mark.platform_x86_ascend_training
  43. def test_analyse_queue_summary(self):
  44. """Test analysing the queue summary info."""
  45. expect_result = {
  46. "data_process": {"status": "normal"},
  47. "device_queue_info": {"summary": {"empty_batch_count": 1, "full_batch_count": 0, "total_batch": 1}},
  48. "device_queue_op": {"status": "normal"},
  49. "get_next": {"status": "normal"},
  50. "get_next_queue_info": {"summary": {"empty_batch_count": 0, "total_batch": 3}},
  51. "tdt": {"status": "normal"}
  52. }
  53. get_next_queue_info, _ = self._analyser.analyse_get_next_info(info_type="queue")
  54. device_queue_info, _ = self._analyser.analyse_device_queue_info(info_type="queue")
  55. result = MinddataAnalyser.analyse_queue_summary(get_next_queue_info, device_queue_info)
  56. assert expect_result == result
  57. @pytest.mark.level0
  58. @pytest.mark.env_single
  59. @pytest.mark.platform_x86_cpu
  60. @pytest.mark.platform_arm_ascend_training
  61. @pytest.mark.platform_x86_gpu_training
  62. @pytest.mark.platform_x86_ascend_training
  63. def test_analyse_get_next_info(self):
  64. """Test analysing the get_next operation info for info_type="time" """
  65. expect_result = {
  66. "info": {"get_next": [0.001, 0, 0.001]},
  67. "size": 3,
  68. "summary": {"time_summary": {"avg_cost": "0.0006666666666666666"}}
  69. }
  70. time_info = {
  71. "size": 0,
  72. "info": [],
  73. "summary": {"time_summary": {}},
  74. "advise": {}
  75. }
  76. _, time_info = self._analyser.analyse_get_next_info(info_type="time")
  77. assert expect_result == time_info
  78. @pytest.mark.level0
  79. @pytest.mark.env_single
  80. @pytest.mark.platform_x86_cpu
  81. @pytest.mark.platform_arm_ascend_training
  82. @pytest.mark.platform_x86_gpu_training
  83. @pytest.mark.platform_x86_ascend_training
  84. def test_analyse_device_queue_info(self):
  85. """Test analysing the device_queue operation info for info_type="time" """
  86. expect_result = {
  87. "info": {"total_cost": [4], "push_cost": [4], "get_cost": [0]},
  88. "size": 1,
  89. "summary": {"time_summary": {"avg_cost": 4, "get_cost": 0, "push_cost": 4}}
  90. }
  91. time_info = {
  92. "size": 0,
  93. "info": [],
  94. "summary": {"time_summary": {}},
  95. "advise": {}
  96. }
  97. _, time_info = self._analyser.analyse_device_queue_info(info_type="time")
  98. assert expect_result == time_info