diff --git a/profiler/advisor/advisor_backend/cluster_advice/cluster_pipeline_advice.py b/profiler/advisor/advisor_backend/cluster_advice/cluster_pipeline_advice.py index 1a057e2bdee982fc3c14cfc8f1148970d1964a80..5213d715e26765281a5916b1797aede2d5837300 100644 --- a/profiler/advisor/advisor_backend/cluster_advice/cluster_pipeline_advice.py +++ b/profiler/advisor/advisor_backend/cluster_advice/cluster_pipeline_advice.py @@ -291,8 +291,8 @@ class ClusterPipelineAdvice(ClusterAdviceBase): process all rank profiling data by using multi-process """ start_time = time.time() - logger.info("Start to process %s rank profiling data with %s workers." - , str(len(self.rank_prof_dirs)), str(self.worker_num)) + logger.info("Start to process %s rank profiling data with %s workers.", + str(len(self.rank_prof_dirs)), str(self.worker_num)) with multiprocessing.Pool(self.worker_num) as pool: results = pool.map(self.work, self.rank_prof_dirs.items()) @@ -321,14 +321,14 @@ class ClusterPipelineAdvice(ClusterAdviceBase): timeslice_list = self.get_pipeline_timeslice(fine_data.hcom_ops, fine_data.hcom_tids, fine_data.min_ts, fine_data.max_ts) if not fine_data.fp_ops or not fine_data.bp_ops: - logger.info("[Rank %s] No frameWork data in trace view, only show stage and bubble." - , str(rank_id)) + logger.info("[Rank %s] No frameWork data in trace view, only show stage and bubble.", + str(rank_id)) elif len(fine_data.hcom_tids) > 1: - logger.warning("[Rank %s] More than one hcom tid found, only show stage and bubble." - , str(rank_id)) + logger.warning("[Rank %s] More than one hcom tid found, only show stage and bubble.", + str(rank_id)) else: - logger.info("[Rank %s] Found frameWork data in trace view, show fp bp and bubble." - , rank_id) + logger.info("[Rank %s] Found frameWork data in trace view, show fp bp and bubble.", + rank_id) bp_ops = self.get_fp_bp_bound_ops(fine_data) self.update_stage_fp_bp(timeslice_list, bp_ops) show_fp_bp = True diff --git a/profiler/advisor/advisor_backend/compute_advice/npu_fused/op_perf.py b/profiler/advisor/advisor_backend/compute_advice/npu_fused/op_perf.py index 7bcbed5a75807b57a55787c743cfaaff55a68589..7fb2580f3e5f0110ce326b98c55fd3585315fbb0 100644 --- a/profiler/advisor/advisor_backend/compute_advice/npu_fused/op_perf.py +++ b/profiler/advisor/advisor_backend/compute_advice/npu_fused/op_perf.py @@ -151,11 +151,12 @@ class OpPerf: return (intput_size + output_size) / (Constant.BYTE_UNIT_TRANS * Constant.BYTE_UNIT_TRANS) def get_throughput(self): - # throughput(GB/s) + # throughput bytes (GB/s) if not self.task_duration or abs(self.task_duration) < 1e-6: print("[ERROR] There is no task_duration, do not assess vector op performance.") return 0 - return self.row[Constant.TITLE.SIZE] / Constant.BYTE_UNIT_TRANS / self.task_duration * Constant.UNIT_TRANS * Constant.UNIT_TRANS + return (self.row[Constant.TITLE.SIZE] / + Constant.BYTE_UNIT_TRANS / self.task_duration * Constant.UNIT_TRANS * Constant.UNIT_TRANS) def get_perf_color(self): return PerfColor.WHITE diff --git a/profiler/advisor/advisor_backend/overall_advice/overall_summary_advice.py b/profiler/advisor/advisor_backend/overall_advice/overall_summary_advice.py index effa9099e2bffbd3e36858218b6271ba3fab851e..4310c41ce126d13ec9ce673b3f6a840bfb4ed4f6 100644 --- a/profiler/advisor/advisor_backend/overall_advice/overall_summary_advice.py +++ b/profiler/advisor/advisor_backend/overall_advice/overall_summary_advice.py @@ -14,14 +14,12 @@ # limitations under the License. import os -from advisor_backend.advice_base import AdviceBase - from profiler.advisor.display.prompt.base_prompt import BasePrompt +from profiler.prof_common.additional_args_manager import AdditionalArgsManager from profiler.prof_common.constant import Constant from compare_interface.comparison_interface import ComparisonInterface - -from profiler.prof_common.additional_args_manager import AdditionalArgsManager +from advisor_backend.advice_base import AdviceBase class OverallSummaryAdvice(AdviceBase): diff --git a/profiler/advisor/advisor_backend/timeline_advice/op_schedule_advice.py b/profiler/advisor/advisor_backend/timeline_advice/op_schedule_advice.py index 5bf2fed3cbe6f4e21ffd94cdcd1d5b290b587881..11008b2f375345a98cd1d20d22333a2138c8dfa9 100644 --- a/profiler/advisor/advisor_backend/timeline_advice/op_schedule_advice.py +++ b/profiler/advisor/advisor_backend/timeline_advice/op_schedule_advice.py @@ -66,8 +66,9 @@ class OpScheduleAdvice(TimelineAdviceBase): self.cur_bottleneck = f"NPU Utilication: {round(free_ratio * 100, 2)}%, " \ f"NPU Free Utilization: {round(cpt_ratio * 100, 2)}%." if len(self.preparse_data[self.PreParseType.SYNCHRONIZE]) > 1: - self.cur_advice = f"Device synchronize {len(self.preparse_data[self.PreParseType.SYNCHRONIZE])} times, " \ - "try to reduce synchronization statements to alleviate the bottleneck of operator delivery.\n" + self.cur_advice = \ + f"Device synchronize {len(self.preparse_data[self.PreParseType.SYNCHRONIZE])} times, " \ + "try to reduce synchronization statements to alleviate the bottleneck of operator delivery.\n" small_op_num = self.small_op_block(op_free, op_dur) small_op_ratio = small_op_num / len(op_dur) if op_dur else 0.0 if small_op_ratio > Constant.SMALL_OP_NUM_RATIO: diff --git a/profiler/advisor/advisor_backend/timeline_advice/timeline_advice_base.py b/profiler/advisor/advisor_backend/timeline_advice/timeline_advice_base.py index 1889972f84118ab334e5e7ff499ab472a9741818..98842cf84baa2d0984a17c388833d504b62debf3 100644 --- a/profiler/advisor/advisor_backend/timeline_advice/timeline_advice_base.py +++ b/profiler/advisor/advisor_backend/timeline_advice/timeline_advice_base.py @@ -61,8 +61,8 @@ class TimelineAdviceBase(AdviceBase): (self.collection_path.endswith("ascend_pt") or self.collection_path.endswith("ascend_ms")): self.trace_view_path = os.path.join(self.collection_path, "ASCEND_PROFILER_OUTPUT", "trace_view.json") if not os.path.exists(self.trace_view_path): - logger.error("trace_view.json is not exist in the Path: %s." \ - , str(os.path.join(self.collection_path, "ASCEND_PROFILER_OUTPUT"))) + logger.error("trace_view.json is not exist in the Path: %s.", + str(os.path.join(self.collection_path, "ASCEND_PROFILER_OUTPUT"))) return False elif os.path.isfile(self.collection_path) and os.path.basename(self.collection_path) == "trace_view.json": self.trace_view_path = self.collection_path diff --git a/profiler/advisor/analyzer/analyzer_controller.py b/profiler/advisor/analyzer/analyzer_controller.py index 879b04ecb38130d59744b137d646880ea90c9d69..1a5a28b637ace3adff3dd93eb1d9d11d4242e886 100644 --- a/profiler/advisor/analyzer/analyzer_controller.py +++ b/profiler/advisor/analyzer/analyzer_controller.py @@ -313,7 +313,9 @@ class AnalyzerController: >>> analyzer_controller = AnalyzerController() >>> analysis_kwargs = dict(advisor_analyze_processes=2, disable_profiling_comparison=True) >>> - >>> async_analysis_process = analyzer_controller.async_do_analysis(Interface.all_dimension, **analysis_kwargs) + >>> async_analysis_process = analyzer_controller.async_do_analysis( + >>> Interface.all_dimension, **analysis_kwargs) + >>> >>> >>> # query the job status every second >>> while True: diff --git a/profiler/advisor/analyzer/communication/retransmission/communication_retransmission_analyzer.py b/profiler/advisor/analyzer/communication/retransmission/communication_retransmission_analyzer.py index 31a024a644baf382876340f208da1eac26f6f010..bd5d76a40f94b69a34af9a5ceb75c88ac9c2ea0c 100644 --- a/profiler/advisor/analyzer/communication/retransmission/communication_retransmission_analyzer.py +++ b/profiler/advisor/analyzer/communication/retransmission/communication_retransmission_analyzer.py @@ -47,6 +47,6 @@ class RDMARetransmissionAnalyzer(BaseCommunicationAnalyzer): self.html = rdma_checker.make_render(self.html_render, add_render_list, priority=self.get_priority()) return self.result - def get_priority(self, max_mem_op_dur): + def get_priority(self, max_mem_op_dur=None): # 单次重传最少4s,高优先级 return PriorityBackgroundColor.high diff --git a/profiler/advisor/analyzer/computation/ai_core_freq/ai_core_freq_checker.py b/profiler/advisor/analyzer/computation/ai_core_freq/ai_core_freq_checker.py index a0190b3c04ee7b6ca9752767b1b9aca4ba6bd696..b203514208b3a5481e5fd01134029200a6a03c90 100644 --- a/profiler/advisor/analyzer/computation/ai_core_freq/ai_core_freq_checker.py +++ b/profiler/advisor/analyzer/computation/ai_core_freq/ai_core_freq_checker.py @@ -75,9 +75,8 @@ class AICoreFreqChecker: if self.decrease_freq_ops: # 按算子总耗时和降频比率 降序排列 - self.decrease_freq_ops.sort(key= - lambda x: (x[self.TOTAL_DURATION_INDEX], x[self.DECREASE_FREQ_RATIO_INDEX]), - reverse=True) + self.decrease_freq_ops.sort( + key=lambda x: (x[self.TOTAL_DURATION_INDEX], x[self.DECREASE_FREQ_RATIO_INDEX]), reverse=True) if not self.ai_core_freq_issues: return diff --git a/profiler/advisor/analyzer/memory/memory_analyzer.py b/profiler/advisor/analyzer/memory/memory_analyzer.py index 939e2de90c634ee6cca584dca345111dce26bb7b..799094ef55c99f16d6c8db09eaa2eaffccbe1bbe 100644 --- a/profiler/advisor/analyzer/memory/memory_analyzer.py +++ b/profiler/advisor/analyzer/memory/memory_analyzer.py @@ -39,7 +39,8 @@ class MemoryAnalyzer(BaseAnalyzer): memory_checker = MemoryOpsChecker() memory_checker.check_memory_ops(self.dataset) memory_checker.make_record(self.result) - memory_checker.make_render(self.html_render, priority=self.get_priority(memory_checker.max_mem_op_dur), rank=kwargs.get("rank")) + memory_checker.make_render( + self.html_render, priority=self.get_priority(memory_checker.max_mem_op_dur), rank=kwargs.get("rank")) return self.result def get_priority(self, max_mem_op_dur): diff --git a/profiler/advisor/analyzer/schedule/fusion_ops/fusion_ops_analyzer.py b/profiler/advisor/analyzer/schedule/fusion_ops/fusion_ops_analyzer.py index 6e212e55b9b25723e41bbc1e1e1e503a8d8b332d..89e5807c4aed984242459fc6fd264e053c4ef12d 100644 --- a/profiler/advisor/analyzer/schedule/fusion_ops/fusion_ops_analyzer.py +++ b/profiler/advisor/analyzer/schedule/fusion_ops/fusion_ops_analyzer.py @@ -210,7 +210,8 @@ class TimelineFusionOpsAnalyzer(BaseAnalyzer): # by the regex index and then calculate the real index for matched fusion operators in event dataset for left, right in zip(total_ops_split_points, total_ops_split_points[1:]): matched_op_flag = True if (left, right) in matched_pattern_index_tuple else False - matched_ops_list = total_op_name[left: right].strip(Constant.OP_SEP).split(Constant.OP_SEP + Constant.OP_SEP) + matched_ops_list = \ + total_op_name[left: right].strip(Constant.OP_SEP).split(Constant.OP_SEP + Constant.OP_SEP) op_index.append([matched_op_flag, len(matched_ops_list)]) for i, _ in enumerate(op_index): if i > 0: diff --git a/profiler/advisor/analyzer/schedule/synchronize_stream/synchronize_stream_analyzer.py b/profiler/advisor/analyzer/schedule/synchronize_stream/synchronize_stream_analyzer.py index 2f5ee5c47bf3111f105e336e84703bb51f119ebe..0dceaa1afd22e7a3f543b9707f39784cac792af0 100644 --- a/profiler/advisor/analyzer/schedule/synchronize_stream/synchronize_stream_analyzer.py +++ b/profiler/advisor/analyzer/schedule/synchronize_stream/synchronize_stream_analyzer.py @@ -15,10 +15,10 @@ import logging from profiler.advisor.analyzer.base_analyzer import BaseAnalyzer -from profiler.advisor.result.result import OptimizeResult from profiler.advisor.analyzer.schedule.synchronize_stream.synchronize_stream_checker import SynchronizeStreamChecker -from profiler.advisor.display.html.render import HTMLRender from profiler.advisor.dataset.timeline_event_dataset import ScheduleAnalysisDataset +from profiler.advisor.display.html.render import HTMLRender +from profiler.advisor.result.result import OptimizeResult logger = logging.getLogger() @@ -43,5 +43,5 @@ class SynchronizeStreamAnalyzer(BaseAnalyzer): rank=kwargs.get("rank")) return self.result - def get_priority(self, max_mem_op_dur): - return max_mem_op_dur.priority + def get_priority(self, max_mem_op_dur): + return max_mem_op_dur.priority diff --git a/profiler/advisor/common/async_analysis_status.py b/profiler/advisor/common/async_analysis_status.py index 3d9a5d7c102ef0a2a20fb4c84cfc00c6a8568899..98bb458105421b38395f745f2913311a24a5ce40 100644 --- a/profiler/advisor/common/async_analysis_status.py +++ b/profiler/advisor/common/async_analysis_status.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -""" + # Copyright (C) 2024-2024. Huawei Technologies Co., Ltd. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" + class AsyncAnalysisStatus: diff --git a/profiler/advisor/common/enum_params_parser.py b/profiler/advisor/common/enum_params_parser.py index e9a3f6639cda5942ee849b4401268e87378cbc6f..2f0fe3a2a3a5a24009f762ae312a256577c0e8ff 100644 --- a/profiler/advisor/common/enum_params_parser.py +++ b/profiler/advisor/common/enum_params_parser.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -""" + # Copyright (C) 2024-2024. Huawei Technologies Co., Ltd. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" + import os import logging import typing diff --git a/profiler/advisor/common/graph/graph.py b/profiler/advisor/common/graph/graph.py index f86f5db7f2cec8f51d3daab6b9c6e9d22de44483..ad68da9174712b1c6c703389c5dfe02c22a7ee66 100644 --- a/profiler/advisor/common/graph/graph.py +++ b/profiler/advisor/common/graph/graph.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -""" + # Copyright (C) 2024-2024. Huawei Technologies Co., Ltd. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" + import logging from typing import Dict, List, Tuple, Callable, Any, Optional, Union diff --git a/profiler/advisor/common/graph/graph_match.py b/profiler/advisor/common/graph/graph_match.py index fbf0a8abe8e049ccb6f9ff2baaa528e94cb3d7e2..1cf2fe170d2ab8d3e29429785c7b6398cc0dd964 100644 --- a/profiler/advisor/common/graph/graph_match.py +++ b/profiler/advisor/common/graph/graph_match.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -""" + # Copyright (C) 2024-2024. Huawei Technologies Co., Ltd. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" + import itertools import logging from functools import lru_cache diff --git a/profiler/advisor/common/graph/graph_parser.py b/profiler/advisor/common/graph/graph_parser.py index cffbfa19b4ed99d4597605785ade750982f522b4..bc0b04a357258e8bb1f9c6dc86cb522a524600f0 100644 --- a/profiler/advisor/common/graph/graph_parser.py +++ b/profiler/advisor/common/graph/graph_parser.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -""" + # Copyright (C) 2024-2024. Huawei Technologies Co., Ltd. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" + import os import logging import itertools diff --git a/profiler/advisor/common/profiling/ge_info.py b/profiler/advisor/common/profiling/ge_info.py index 91642f967970fdf27f76754ee4bbd7f4ab4fcc50..927f5d3e714583c4a1aac9b5b72bfd8ef70998b4 100644 --- a/profiler/advisor/common/profiling/ge_info.py +++ b/profiler/advisor/common/profiling/ge_info.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -""" + # Copyright (C) 2024-2024. Huawei Technologies Co., Ltd. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" + import logging import os from typing import Any, List diff --git a/profiler/advisor/common/profiling/msprof.py b/profiler/advisor/common/profiling/msprof.py index 54206bb471afce3842c3fd0faf5d78311d339592..76f51b672d4a6d13f40e30362f3b9900b88c2d80 100644 --- a/profiler/advisor/common/profiling/msprof.py +++ b/profiler/advisor/common/profiling/msprof.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -""" + # Copyright (C) 2024-2024. Huawei Technologies Co., Ltd. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" + import logging from typing import Dict, List diff --git a/profiler/advisor/common/profiling/op_summary.py b/profiler/advisor/common/profiling/op_summary.py index c042509df96c0c8feacb39a56e6f73358cd5d8a9..b1b416888f516559bfcbbfc8a4150c9070bde7fe 100644 --- a/profiler/advisor/common/profiling/op_summary.py +++ b/profiler/advisor/common/profiling/op_summary.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -""" + # Copyright (C) 2024-2024. Huawei Technologies Co., Ltd. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" + import logging from decimal import Decimal from typing import List, Any diff --git a/profiler/advisor/common/profiling/tasktime.py b/profiler/advisor/common/profiling/tasktime.py index 211800585a6b3385e41d009827ec675bfa9df560..7891f890395bd2d5566cfc59fb7579c25f55dff8 100644 --- a/profiler/advisor/common/profiling/tasktime.py +++ b/profiler/advisor/common/profiling/tasktime.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -""" + # Copyright (C) 2024-2024. Huawei Technologies Co., Ltd. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" + import logging from typing import Dict, List diff --git a/profiler/advisor/common/timeline/event.py b/profiler/advisor/common/timeline/event.py index 79ee63211c33515ce8bad1a3a537caa65ac86511..f6afb7359494e561fc2e403c29ed4481d12c7529 100644 --- a/profiler/advisor/common/timeline/event.py +++ b/profiler/advisor/common/timeline/event.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -""" + # Copyright (C) 2024-2024. Huawei Technologies Co., Ltd. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" + from decimal import Decimal diff --git a/profiler/advisor/common/timeline/fusion_ops_db.py b/profiler/advisor/common/timeline/fusion_ops_db.py index 11727bf3ed299777a3dab3457c396bff3b75365e..e2228f3480324495e2ffa1e3733a6ae833bbb56c 100644 --- a/profiler/advisor/common/timeline/fusion_ops_db.py +++ b/profiler/advisor/common/timeline/fusion_ops_db.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -""" + # Copyright (C) 2024-2024. Huawei Technologies Co., Ltd. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" + import logging import os diff --git a/profiler/advisor/common/version_control.py b/profiler/advisor/common/version_control.py index ec30b3be9d84532ff4e8829341dd2da4d3dfc49f..f04f097ca4d238f6917b2bb94dde0564a742fc84 100644 --- a/profiler/advisor/common/version_control.py +++ b/profiler/advisor/common/version_control.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -""" +# # Copyright (C) 2024-2024. Huawei Technologies Co., Ltd. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" + import logging from typing import List diff --git a/profiler/advisor/dataset/profiling/device_info.py b/profiler/advisor/dataset/profiling/device_info.py index 707e726ce29e55b41a6c6a3d7723b21550f935fc..52c811e6dd3d7f349d0b7b5c648467d9d6e99a9d 100644 --- a/profiler/advisor/dataset/profiling/device_info.py +++ b/profiler/advisor/dataset/profiling/device_info.py @@ -1,3 +1,16 @@ +# Copyright (C) 2024-2024. Huawei Technologies Co., Ltd. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """ profiling info """ diff --git a/profiler/advisor/dataset/profiling/profiling_dataset.py b/profiler/advisor/dataset/profiling/profiling_dataset.py index cd1d953aa0fd355328bc823e4a064d012a06e3f3..99f11e171a05362ea10311c593f488838f0ae08d 100644 --- a/profiler/advisor/dataset/profiling/profiling_dataset.py +++ b/profiler/advisor/dataset/profiling/profiling_dataset.py @@ -37,7 +37,8 @@ class ProfilingDataset(Dataset): def __init__(self, collection_path, data: dict, **kwargs) -> None: self.cann_version = kwargs.get(Constant.CANN_VERSION, EnumParamsParser().get_default(Constant.CANN_VERSION)) - self.prof_type = kwargs.get(Constant.PROFILING_TYPE_UNDER_LINE, EnumParamsParser().get_default(Constant.PROFILING_TYPE_UNDER_LINE)) + self.prof_type = kwargs.get( + Constant.PROFILING_TYPE_UNDER_LINE, EnumParamsParser().get_default(Constant.PROFILING_TYPE_UNDER_LINE)) self.patterns = self.parse_pattern() self.current_version_pattern = self.get_current_version_pattern() self._info = None diff --git a/profiler/advisor/dataset/timeline_event_dataset.py b/profiler/advisor/dataset/timeline_event_dataset.py index fbac2c5bf0198bf2cec6aef4513ccfaf8aed0396..77d64267c41d272f3c071f120ddd64f67736bdd2 100644 --- a/profiler/advisor/dataset/timeline_event_dataset.py +++ b/profiler/advisor/dataset/timeline_event_dataset.py @@ -80,10 +80,10 @@ class BaseTimelineEventDataset: kwargs = {} if func_name == FrequencyCollector.__name__: ops_with_task_type = getattr(self, "ops_with_task_type", {}).values() - kwargs["ai_core_ops"] = [ - op for op in ops_with_task_type if - op.get(Constant.TASK_TYPE) in [Constant.AI_CORE, Constant.MIX_AIC] - ] + kwargs["ai_core_ops"] = [op + for op in ops_with_task_type if + op.get(Constant.TASK_TYPE) in [Constant.AI_CORE, Constant.MIX_AIC] + ] return kwargs def add_event(self, index, event): diff --git a/profiler/advisor/dataset/timeline_op_collector/timeline_op_collector.py b/profiler/advisor/dataset/timeline_op_collector/timeline_op_collector.py index ab3433a7545d881a17a04b81845d31b603f0a354..a1aa68d208c786a3090988be2d689e712dff017a 100644 --- a/profiler/advisor/dataset/timeline_op_collector/timeline_op_collector.py +++ b/profiler/advisor/dataset/timeline_op_collector/timeline_op_collector.py @@ -1,3 +1,16 @@ +# Copyright (C) 2024-2024. Huawei Technologies Co., Ltd. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import logging import math import os diff --git a/profiler/advisor/display/prompt/en/dynamic_shape_prompt.py b/profiler/advisor/display/prompt/en/dynamic_shape_prompt.py index b350f603f115eb9dad32c49b2d1659ec367df6fe..e8a785b2f5a1b7a462d72d37549ca6cc5fc45419 100644 --- a/profiler/advisor/display/prompt/en/dynamic_shape_prompt.py +++ b/profiler/advisor/display/prompt/en/dynamic_shape_prompt.py @@ -17,8 +17,9 @@ class DynamicShapePrompt(object): RANK_ID = "RANK {} " PROBLEM = "Dynamic Shape Operator" DESCRIPTION = "Found all operators are dynamic shape" - ENABLE_COMPILED_SUGGESTION = "1. Please try to set environment by execute `export HOST_CACHE_CAPACITY=20`.\n." \ - "2. Please place the following code at the entrance of the python script to disable jit compile.\n " \ - "Code: `torch_npu.npu.set_compile_mode(jit_compile=False) \n " \ - "torch_npu.npu.config.allow_internal_format = False`.\n" + ENABLE_COMPILED_SUGGESTION = \ + "1. Please try to set environment by execute `export HOST_CACHE_CAPACITY=20`.\n." \ + "2. Please place the following code at the entrance of the python script to disable jit compile.\n " \ + "Code: `torch_npu.npu.set_compile_mode(jit_compile=False) \n " \ + "torch_npu.npu.config.allow_internal_format = False`.\n" RELEASE_SUGGESTION = "for details please refer to link : LINK" diff --git a/profiler/advisor/utils/log.py b/profiler/advisor/utils/log.py index 5d9757ebf461d8bece983f56d20770ce9a4c4a17..853d9e15599b1c3667104699e3de0be58f8c61e7 100644 --- a/profiler/advisor/utils/log.py +++ b/profiler/advisor/utils/log.py @@ -1,3 +1,15 @@ +# Copyright (C) 2024-2024. Huawei Technologies Co., Ltd. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ log module """ diff --git a/profiler/advisor/utils/tools.py b/profiler/advisor/utils/tools.py index 90c2c9cf0be337a0f08e289499ce215e8299b5c4..4887dc49583c7619899e0c58629ba1b39861b2da 100644 --- a/profiler/advisor/utils/tools.py +++ b/profiler/advisor/utils/tools.py @@ -1,3 +1,16 @@ +# Copyright (C) 2024-2024. Huawei Technologies Co., Ltd. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from functools import partial import click diff --git a/profiler/advisor/utils/utils.py b/profiler/advisor/utils/utils.py index 710084ef8c942bf1a3699cd7015b50c6d1676333..0e928edde9d5b99a0974734e0ac0c9356fa8484c 100644 --- a/profiler/advisor/utils/utils.py +++ b/profiler/advisor/utils/utils.py @@ -119,10 +119,10 @@ def singleton(cls): members = inspect.getmembers(base_class) # 过滤出函数对象 - function_objs = [ - member[1] for member in members - if inspect.isfunction(member[1]) or inspect.ismethod(member[1]) - ] + function_objs = [member[1] + for member in members + if inspect.isfunction(member[1]) or inspect.ismethod(member[1]) + ] for function_obj in function_objs: if inspect.isfunction(function_obj) and not is_static_func(function_obj): continue