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 2.8 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/ut/func/profiler
  20. """
  21. import os
  22. from mindinsight.profiler.analyser.analyser_factory import AnalyserFactory
  23. from tests.ut.profiler import BASE_SUMMARY_DIR
  24. class TestAicpuAnalyser:
  25. """Test AICPU analyser module."""
  26. @classmethod
  27. def setup_class(cls):
  28. """Generate parsed files."""
  29. cls.summary_dir = os.path.join(BASE_SUMMARY_DIR, 'normal_run')
  30. cls.profiler = os.path.join(cls.summary_dir, 'profiler')
  31. def setup_method(self):
  32. """Create analyser."""
  33. self._analyser_aicpu_type = AnalyserFactory.instance().get_analyser(
  34. 'aicpu_type', self.profiler, '1')
  35. self._analyser_aicpu_detail = AnalyserFactory.instance().get_analyser(
  36. 'aicpu_detail', self.profiler, '1')
  37. def test_query_aicpu_type(self):
  38. """Test the function of querying AICPU operator type infomation."""
  39. expect_result = {
  40. 'col_name': ['op_type', 'execution_time', 'execution_frequency', 'percent'],
  41. 'object': [
  42. ['InitData', 7.906, 1, 89.84],
  43. ],
  44. 'size': 1
  45. }
  46. condition = {
  47. 'filter_condition': {
  48. 'op_type': {
  49. 'partial_match_str_in': ['init']
  50. }
  51. }
  52. }
  53. result = self._analyser_aicpu_type.query(condition)
  54. assert expect_result == result
  55. def test_query_aicpu_detail(self):
  56. """Test the function of querying AICPU operator detail infomation."""
  57. expect_result = {
  58. 'col_name': ['serial_number', 'op_type', 'total_time',
  59. 'dispatch_time', 'run_start', 'run_end'],
  60. 'size': 2
  61. }
  62. condition = {
  63. 'filter_condition': {
  64. 'op_type': {
  65. 'partial_match_str_in': ['get']
  66. }
  67. }
  68. }
  69. result = self._analyser_aicpu_detail.query(condition)
  70. del result["object"]
  71. assert expect_result == result