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_proposer_analyser.py 2.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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/st/func/profiler
  20. """
  21. import os
  22. import pytest
  23. from mindinsight.profiler.proposer.compose_proposer import ComposeProposal
  24. from .conftest import BASE_SUMMARY_DIR_RUN_2
  25. class TestProposerAnalyser:
  26. """Test minddata 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. @pytest.mark.level0
  33. @pytest.mark.env_single
  34. @pytest.mark.platform_x86_cpu
  35. @pytest.mark.platform_arm_ascend_training
  36. @pytest.mark.platform_x86_gpu_training
  37. @pytest.mark.platform_x86_ascend_training
  38. def test_analyser_proposal(self):
  39. """Test the function of querying the proposals from multiple different proposers"""
  40. expect_result = {
  41. "minddata_device_queue": [1, 1, 0, 1],
  42. "minddata_get_next_queue": [0, 3],
  43. "minddata_pipeline-dataset_op": ["ImageFolderOp_3"],
  44. "minddata_pipeline-general": ["ImageFolderOp_3"]
  45. }
  46. step_trace_condition = {"filter_condition": {"mode": "proc",
  47. "proc_name": "iteration_interval",
  48. "step_id": 0}}
  49. options = {'step_trace': {"iter_interval": step_trace_condition}}
  50. proposal_type_list = ['step_trace', 'minddata', 'minddata_pipeline', 'common']
  51. proposal_obj = ComposeProposal(self.profiler, '1', proposal_type_list)
  52. proposal_info = proposal_obj.get_proposal(options)
  53. assert expect_result["minddata_device_queue"] == proposal_info["minddata_device_queue"]
  54. assert expect_result["minddata_get_next_queue"] == proposal_info["minddata_get_next_queue"]
  55. assert expect_result["minddata_pipeline-dataset_op"] == proposal_info["minddata_pipeline-dataset_op"]
  56. assert expect_result["minddata_pipeline-general"] == proposal_info["minddata_pipeline-general"]