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_aicpu_analyser.py 3.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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.analyser_factory import AnalyserFactory
  24. from tests.st.func.profiler.conftest import BASE_SUMMARY_DIR_RUN_2
  25. class TestAicpuAnalyser:
  26. """Test AICPU analyser module."""
  27. @classmethod
  28. def setup_class(cls):
  29. """Generate parsed files."""
  30. cls.summary_dir = os.path.join(BASE_SUMMARY_DIR_RUN_2, 'normal_run')
  31. cls.profiler = os.path.join(cls.summary_dir, 'profiler')
  32. def setup_method(self):
  33. """Create analyser."""
  34. self._analyser_aicpu_type = AnalyserFactory.instance().get_analyser(
  35. 'aicpu_type', self.profiler, '1')
  36. self._analyser_aicpu_detail = AnalyserFactory.instance().get_analyser(
  37. 'aicpu_detail', self.profiler, '1')
  38. @pytest.mark.level0
  39. @pytest.mark.env_single
  40. @pytest.mark.platform_x86_cpu
  41. @pytest.mark.platform_arm_ascend_training
  42. @pytest.mark.platform_x86_gpu_training
  43. @pytest.mark.platform_x86_ascend_training
  44. def test_query_aicpu_type(self):
  45. """Test the function of querying AICPU operator type infomation."""
  46. expect_result = {
  47. 'col_name': ['op_type', 'execution_time', 'execution_frequency', 'percent'],
  48. 'object': [
  49. ['InitData', 7.906, 1, 89.84],
  50. ['GetNext', 0.5905, 2, 6.71],
  51. ['EndOfSequence', 0.3035, 2, 3.45]
  52. ],
  53. 'size': 3
  54. }
  55. result = self._analyser_aicpu_type.query()
  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_query_aicpu_detail(self):
  64. """Test the function of querying AICPU operator type infomation."""
  65. expect_result = {
  66. 'col_name': ['serial_number', 'op_type', 'total_time',
  67. 'dispatch_time', 'run_start', 'run_end'],
  68. 'size': 5
  69. }
  70. result = self._analyser_aicpu_detail.query()
  71. del result["object"]
  72. assert expect_result == result