From 512205bfa96932e770d2daf6982f0a45301678c8 Mon Sep 17 00:00:00 2001 From: mei-feiyao <1332490378@qq.com> Date: Sat, 13 Sep 2025 17:17:00 +0800 Subject: [PATCH] fix err --- .../profiler/analysis/prof_config/_parser_config.py | 11 ++++++----- .../analysis/prof_config/_parser_deps_config.py | 6 +++++- .../prof_view/prof_db_parse/_step_info_db_parser.py | 6 +++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/torch_npu/profiler/analysis/prof_config/_parser_config.py b/torch_npu/profiler/analysis/prof_config/_parser_config.py index 8ad26ed7cb..588e36d785 100644 --- a/torch_npu/profiler/analysis/prof_config/_parser_config.py +++ b/torch_npu/profiler/analysis/prof_config/_parser_config.py @@ -93,8 +93,8 @@ class ParserConfig: IntegrateParser, CommunicationParser ], - Constant.EXPORT_CHROME_TRACE: [TorchOpParser, TaskQueueParser, TracePreParser, TreeBuildParser, CANNExportParser, - CANNTimelineParser, TraceViewParser], + Constant.EXPORT_CHROME_TRACE: [TorchOpParser, TaskQueueParser, TracePreParser, TreeBuildParser, + CANNExportParser, CANNTimelineParser, TraceViewParser], Constant.EXPORT_STACK: [TorchOpParser, TaskQueueParser, TreeBuildParser, CANNExportParser, CANNTimelineParser, StackViewParser], Constant.EXPORT_MEMORY_TIMELINE: [MemoryTimelineParser] @@ -116,14 +116,15 @@ class ParserConfig: ONLY_FWK_CONFIG = { Constant.Text: { - Constant.TENSORBOARD_TRACE_HANDLER: [TorchOpParser, TaskQueueParser, MemoryPrepareParser, OperatorViewParser, TraceViewParser, - MemoryViewParser], + Constant.TENSORBOARD_TRACE_HANDLER: [TorchOpParser, TaskQueueParser, MemoryPrepareParser, + OperatorViewParser, TraceViewParser, MemoryViewParser], Constant.EXPORT_CHROME_TRACE: [TorchOpParser, TaskQueueParser, TraceViewParser], Constant.EXPORT_STACK: [TorchOpParser, TaskQueueParser, StackViewParser], Constant.EXPORT_MEMORY_TIMELINE: [MemoryTimelineParser] }, Constant.Db: { - Constant.TENSORBOARD_TRACE_HANDLER: [TorchOpParser, TaskQueueParser, DbPreParser, MemoryPrepareParser, DbParser] + Constant.TENSORBOARD_TRACE_HANDLER: [TorchOpParser, TaskQueueParser, DbPreParser, + TreeBuildParser, MemoryPrepareParser, DbParser] } } diff --git a/torch_npu/profiler/analysis/prof_config/_parser_deps_config.py b/torch_npu/profiler/analysis/prof_config/_parser_deps_config.py index 2afd5874b4..94b1622182 100644 --- a/torch_npu/profiler/analysis/prof_config/_parser_deps_config.py +++ b/torch_npu/profiler/analysis/prof_config/_parser_deps_config.py @@ -72,6 +72,8 @@ class ParserDepsConfig: ONLY_FWK_CONFIG = { Constant.TORCH_OP_PARSER: {Constant.MODE: ConcurrentMode.PTHREAD, Constant.DEPS: []}, Constant.TASK_QUEUE_PARSER: {Constant.MODE: ConcurrentMode.PTHREAD, Constant.DEPS: []}, + Constant.TREE_BUILD_PARSER: {Constant.MODE: ConcurrentMode.PTHREAD, + Constant.DEPS: [Constant.TORCH_OP_PARSER, Constant.TASK_QUEUE_PARSER]}, Constant.OPERATOR_VIEW_PARSER: {Constant.MODE: ConcurrentMode.SUB_PROCESS, Constant.DEPS: [Constant.TORCH_OP_PARSER]}, Constant.TRACE_VIEW_PARSER: {Constant.MODE: ConcurrentMode.SUB_PROCESS, Constant.DEPS: [Constant.TASK_QUEUE_PARSER, Constant.TORCH_OP_PARSER]}, Constant.MEMORY_VIEW_PARSER: {Constant.MODE: ConcurrentMode.SUB_PROCESS, Constant.DEPS: [Constant.MEMORY_PREPARE]}, @@ -81,6 +83,8 @@ class ParserDepsConfig: Constant.DEPS: [Constant.TORCH_OP_PARSER, Constant.TASK_QUEUE_PARSER]}, Constant.MEMORY_PREPARE: {Constant.MODE: ConcurrentMode.PTHREAD, Constant.DEPS: [Constant.TASK_QUEUE_PARSER, Constant.TORCH_OP_PARSER]}, - Constant.DB_PARSER: {Constant.MODE: ConcurrentMode.PTHREAD, Constant.DEPS: [Constant.DB_PRE_PARSER, Constant.MEMORY_PREPARE]}, + Constant.DB_PARSER: {Constant.MODE: ConcurrentMode.PTHREAD, + Constant.DEPS: [Constant.DB_PRE_PARSER, Constant.MEMORY_PREPARE, + Constant.TREE_BUILD_PARSER]}, Constant.MEMORY_TIMELINE_PARSER: {} } diff --git a/torch_npu/profiler/analysis/prof_view/prof_db_parse/_step_info_db_parser.py b/torch_npu/profiler/analysis/prof_view/prof_db_parse/_step_info_db_parser.py index 3c6e5674eb..5ab346e8ab 100644 --- a/torch_npu/profiler/analysis/prof_view/prof_db_parse/_step_info_db_parser.py +++ b/torch_npu/profiler/analysis/prof_view/prof_db_parse/_step_info_db_parser.py @@ -13,10 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. from .._base_parser import BaseParser +from ..._profiler_config import ProfilerConfig from ...prof_bean._torch_op_node import TorchOpNode from ...prof_common_func._constant import DbConstant, Constant, TableColumnsManager, print_warn_msg from ...prof_common_func._db_manager import TorchDb from ...prof_common_func._log import ProfilerLogger +from ...prof_common_func._path_manager import ProfilerPathManager __all__ = [] @@ -76,7 +78,10 @@ class StepInfoDbParser(BaseParser): if not TorchDb().create_connect_db(): print_warn_msg(f"Failed to connect to db file: {TorchDb().get_db_path()}") return [] + self.save_step_time(step_node_list) step_range = [] + if not ProfilerPathManager.get_cann_path(self._profiler_path) or ProfilerConfig().get_level() != Constant.LEVEL_NONE: + return step_range if not step_node_list: start_time = 0 end_time = float('inf') @@ -112,7 +117,6 @@ class StepInfoDbParser(BaseParser): Constant.FWK_START_TS: step_node.start_time } ) - self.save_step_time(step_node_list) return step_range def save_step_time(self, step_node_list: list) -> None: -- Gitee