From 717a8a87ce3194d01ac2b25e295d51bf942914ce Mon Sep 17 00:00:00 2001 From: zhouxianqi <13165993773@163.com> Date: Tue, 29 Aug 2023 10:44:00 +0800 Subject: [PATCH] memory_compare_bug_fix --- .../compare_tools/generation/op_comparison_generator.py | 7 ++++--- profiler/compare_tools/utils/compare_event.py | 2 +- profiler/compare_tools/utils/constant.py | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/profiler/compare_tools/generation/op_comparison_generator.py b/profiler/compare_tools/generation/op_comparison_generator.py index 980b683896..1e48d7d0b4 100644 --- a/profiler/compare_tools/generation/op_comparison_generator.py +++ b/profiler/compare_tools/generation/op_comparison_generator.py @@ -96,7 +96,7 @@ class OpComparisonGenerator: diff = Constant.NA op_name = data[0].name if data[0] else data[1].name - summary_data = base_summary_data + comparison_summary_data + [diff, op_name, diff] + summary_data = base_summary_data + comparison_summary_data + [diff, op_name, Constant.NA] for index in range(len(headers)): value = summary_data[index] if headers[index] == Constant.DIFF: @@ -106,10 +106,11 @@ class OpComparisonGenerator: elif value != Constant.NA and value >= 0: ws.cell(row=row_index, column=index + 1).font = Font(name='Arial', color=Constant.RED_COLOR) if headers[index] == Constant.DIFF_FILTER: - if value != Constant.NA and value < 0: + diff_value = summary_data[headers.index(Constant.DIFF)] + if diff_value != Constant.NA and diff_value < 0: ws.cell(row=row_index, column=index + 1).fill = PatternFill("solid", fgColor=Constant.GREEN_COLOR) - elif value != Constant.NA and value >= 0: + elif diff_value != Constant.NA and diff_value >= 0: ws.cell(row=row_index, column=index + 1).fill = PatternFill("solid", fgColor=Constant.RED_COLOR) elif headers[index] != Constant.OP_NAME_FILTER: ws.cell(row=row_index, column=index + 1).fill = PatternFill("solid", diff --git a/profiler/compare_tools/utils/compare_event.py b/profiler/compare_tools/utils/compare_event.py index 1ce2d820d7..a994d8d6fc 100644 --- a/profiler/compare_tools/utils/compare_event.py +++ b/profiler/compare_tools/utils/compare_event.py @@ -47,4 +47,4 @@ class MemoryEvent: else: duration = Constant.NA name = self._event.get(Constant.NAME, "") if self._event.get(Constant.NAME, "") else self._name - return [name, self._event.get(Constant.SIZE, 0), duration] + return [name, duration, self._event.get(Constant.SIZE, 0)] diff --git a/profiler/compare_tools/utils/constant.py b/profiler/compare_tools/utils/constant.py index ff39744b64..8c4d4a7681 100644 --- a/profiler/compare_tools/utils/constant.py +++ b/profiler/compare_tools/utils/constant.py @@ -57,9 +57,10 @@ class Constant(object): TS = "ts" ALLOCATION_TIME = "Allocation Time(us)" RELEASE_TIME = "Release Time(us)" + MEMORY_DURATION = "Memory Duration(us)" MEMORY_OP_NAME = 'OP Name' NAME = "Name" - CMP_MEMORY_HEADER = [OP_NAME, INPUT_SHAPE + " / " + MEMORY_OP_NAME, INPUT_TYPE + " / " + RELEASE_TIME, SIZE] + CMP_MEMORY_HEADER = [OP_NAME, INPUT_SHAPE + " / " + MEMORY_OP_NAME, INPUT_TYPE + " / " + MEMORY_DURATION, SIZE] # compare type OPERATOR_COMPARE = "OperatorCompare" -- Gitee