From ba33a4a56b1c4063a574dd2289bef7243e49f7b5 Mon Sep 17 00:00:00 2001 From: sunchao <1299792067@qq.com> Date: Mon, 24 Mar 2025 20:05:15 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=F0=9F=90=8E=20ci:=20=E6=90=AD=E5=BB=BA?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=8E=AF=E5=A2=83=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/controllers/match_nodes_controller.py | 3 + .../server/app/utils/graph_utils.py | 1 + .../tb_graph_ascend/test/test_plugin.py | 488 --------- .../tb_graph_ascend/tests/conftest.py | 39 + .../tb_graph_ascend/tests/pytest.ini | 9 + .../tests/test_data/compare_statis.vis | 948 ++++++++++++++++++ .../tests/test_data/metadata.json | 44 + .../test_match_nodes_controller.py | 11 + .../tests/units/service/test_graph_service.py | 20 + .../tests/units/test_plugin.py | 0 .../tests/units/utils/test_graph_utils.py | 0 11 files changed, 1075 insertions(+), 488 deletions(-) delete mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/test/test_plugin.py create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/tests/pytest.ini create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/tests/test_data/compare_statis.vis create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/tests/test_data/metadata.json create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/tests/units/controllers/test_match_nodes_controller.py create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/tests/units/service/test_graph_service.py create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/tests/units/test_plugin.py create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/tests/units/utils/test_graph_utils.py diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/server/app/controllers/match_nodes_controller.py b/plugins/tensorboard-plugins/tb_graph_ascend/server/app/controllers/match_nodes_controller.py index b2c8e64adff..4951f9dded4 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/server/app/controllers/match_nodes_controller.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/server/app/controllers/match_nodes_controller.py @@ -20,6 +20,9 @@ from ..utils.global_state import ADD_MATCH_KEYS class MatchNodesController: + def add(a, b): + return a + b + @staticmethod def process_md5_task_add(graph_data, npu_node_name, bench_node_name): npu_match_nodes_list = graph_data.get('npu_match_nodes', {}) diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/server/app/utils/graph_utils.py b/plugins/tensorboard-plugins/tb_graph_ascend/server/app/utils/graph_utils.py index 1829f2a80d4..34b5d74550f 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/server/app/utils/graph_utils.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/server/app/utils/graph_utils.py @@ -145,6 +145,7 @@ class GraphUtils: """Load a single .vis file from a given directory based on the tag.""" file_path = os.path.join(run_dir, f"{tag}.vis") file_path = os.path.normpath(file_path) # 标准化路径 + print(os.path.exists(file_path)) if os.path.exists(file_path): # 校验文件的读权限 if not os.access(file_path, os.R_OK): diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/test/test_plugin.py b/plugins/tensorboard-plugins/tb_graph_ascend/test/test_plugin.py deleted file mode 100644 index 3d958e029be..00000000000 --- a/plugins/tensorboard-plugins/tb_graph_ascend/test/test_plugin.py +++ /dev/null @@ -1,488 +0,0 @@ -# Copyright (c) 2025, Huawei Technologies. -# 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 sys -import os -sys.path.append(os.path.pardir) -from unittest.mock import MagicMock, patch -import unittest -from server.plugin import GraphsPlugin - - -class TestGraphsPlugin(unittest.TestCase): - - @property - def plugin(self): - """提供对受保护实例属性 _plugin 的只读访问""" - return self._plugin - - @property - def instance(self): - """提供对受保护实例属性 _instance 的只读访问""" - return self._instance - - def setUp(self): - """在每个测试之前初始化环境""" - fake_context = MagicMock() - - # 创建 GraphsPlugin 实例并传递 context - self.plugin = GraphsPlugin(context=fake_context) - self.plugin._current_file_path = "" # 初始化文件路径 - self.plugin.batch_id = '-1' # 设置为 -1 来触发 _process_subnode 中的判断逻辑 - self.plugin.step_id = '-1' # 设置为 -1 来触发 _process_subnode 中的判断逻辑 - - self.plugin._current_file_data = { - "npu": { - "node": { - "npu_node_1": { - "matched_node_link": [] - } - } - }, - "bench": { - "node": { - "bench_node_1": { - "matched_node_link": [] - } - } - }, - "match": [], - 'task': 'md5' - } - - self.app = Flask(__name__) - self.app.debug = True - self.client = self.app.test_client() - - # 创建模拟的 data_provider - mock_data_provider = MagicMock() - mock_data_provider.some_method.return_value = "some_value" # 根据需要设置模拟的方法 - - # 创建一个模拟的 context,并将 mock_data_provider 赋值给它 - context = MagicMock() - context.data_provider = mock_data_provider - - # 使用 context 创建 GraphsPlugin 实例 - self._instance = GraphsPlugin(context=context) - - def test_get_all_node_name_with_valid_batch_and_step(self): - # 模拟 request.args - mock_request = MagicMock() - mock_request.args.get.return_value = '0' # 模拟 batch=0 和 step=0 - - # 构造 json_data - json_data = { - 'npu': { - 'root': 'root_node', - 'node': { - 'root_node': { - 'micro_step_id': 0, - 'subnodes': ['subnode1', 'subnode2'] - }, - 'subnode1': {'micro_step_id': 0}, - 'subnode2': {'micro_step_id': 0}, - } - }, - 'bench': { - 'node': { - 'bench1': {}, - 'bench2': {} - } - } - } - - # 调用 get_all_nodeName 方法 - npu_ids, bench_ids = self.plugin.get_all_node_names(json_data, mock_request) - - # 验证返回的 npu_ids 和 bench_ids - self.assertEqual(npu_ids, ['subnode1', 'subnode2']) - self.assertEqual(bench_ids, ['bench1', 'bench2']) - - def test_dfs_collect_nodes_with_valid_batch_and_step(self): - # 模拟 request.args - mock_request = MagicMock() - side_effect_dict = { - 'batch': '0', - 'step': '0' - } - - # 设置 mock_request.args.get 的 side_effect - mock_request.args.get.side_effect = side_effect_dict.get - - # 构造 json_data - json_data = { - 'npu': { - 'node': { - 'node1': {'micro_step_id': 0, 'step_id': 0, 'subnodes': []}, - 'node2': {'micro_step_id': 0, 'step_id': 0, 'subnodes': []}, - 'node3': {'micro_step_id': 1, 'step_id': 1, 'subnodes': []}, - 'node4': {'micro_step_id': 0, 'step_id': 1, 'subnodes': ['subnode1']} - } - } - } - - # 调用 dfs_collect_nodes 方法 - all_node_names = self.plugin.dfs_collect_nodes(json_data, mock_request) - - # 验证返回的 all_node_names - self.assertEqual(all_node_names, ['node1', 'node2']) - - def test_group_precision_set_with_even_number_of_elements(self): - # 测试正常的输入(偶数个元素) - precision_set = [1, 2, 3, 4, 5, 6] - expected_result = [[1, 2], [3, 4], [5, 6]] - - # 调用 group_precision_set 方法 - result = self.plugin.group_precision_set(precision_set) - - # 验证结果是否正确 - self.assertEqual(result, expected_result) - - def test_group_precision_set_with_odd_number_of_elements(self): - # 测试输入长度为奇数的情况 - precision_set = [1, 2, 3] - - # 验证是否抛出 ValueError 异常 - with self.assertRaises(ValueError) as context: - self.plugin.group_precision_set(precision_set) - - self.assertEqual(str(context.exception), 'The number of elements in precision_set is not even') - - def test_process_data_with_md5_mismatch(self): - # 测试 md5 不匹配的情况 - data = [] - data_set = { - 'npu_keys': ['npu_key_1'], - 'bench_keys': ['bench_key_1'], - 'input_data': {'npu_key_1': [1, 2, 3], 'md5': 'abcd'}, - 'output_data': {'bench_key_1': [1, 2, 3], 'md5': 'efgh'}, - 'precision_index': 0, - 'file_path': 'test_path', - 'data_type': 'test_type', - } - npu_node = 'test_node' - - # 调用方法 - result = self.plugin.process_data(data, data_set, npu_node) - - # 验证结果 - self.assertEqual(result, 0) - self.assertEqual(data_set['precision_index'], 0) - - def test_should_update_node_with_valid_batch_and_step(self): - # 模拟 json_data 和 subnode_id_data - subnode_id_data = {'micro_step_id': '-1', 'step_id': '-1', 'matched_node_link': ['N___subnode_1']} - subgraph = {'node': {}} - json_data = { - 'StepList': ['0', '1', '2'] # 测试 StepList 数据 - } - - prefix = 'N___' - subnode_id = 'subnode_1' - - # 调用 _process_subnode 方法 - self.plugin._process_subnode(subgraph, prefix, subnode_id, subnode_id_data, json_data) - - # 验证 subnode_id 是否更新 - self.assertIn(prefix + subnode_id, subgraph['node']) - self.assertEqual(subgraph['node'][prefix + subnode_id], subnode_id_data) - - def mock_json_get(self, *args): - """ 模拟 json_get 方法,返回不同层级的数据 """ - if len(args) == 4 and args[1] == "node": - # 返回节点的 matched_node_link 数据 - return self.plugin._current_file_data[args[0]][args[1]].get(args[2], {}).get('matched_node_link', []) - return None - - def test_should_update_node_with_invalid_batch_or_step(self): - # 测试 batch_id 和 step_id 为无效值时不会更新 - self.plugin.batch_id = '-1' - self.plugin.step_id = '-1' - - subnode_id_data = {'micro_step_id': '1', 'step_id': '1', 'matched_node_link': []} - subgraph = {'node': {}} - json_data = { - 'StepList': ['0', '1', '2'] - } - - prefix = 'B___' - subnode_id = 'subnode_1' - - # 调用 _process_subnode 方法 - self.plugin._process_subnode(subgraph, prefix, subnode_id, subnode_id_data, json_data) - - # 验证 subnode_id 是否被更新 - self.assertIn(prefix + subnode_id, subgraph['node']) - self.assertEqual(subgraph['node'][prefix + subnode_id], subnode_id_data) - - def test_update_matched_node_links(self): - subnode_id_data = { - 'matched_node_link': ['link_1', 'link_2'] - } - prefix = 'B___' - - # 调用 _update_matched_node_links 方法 - self.plugin._update_matched_node_links(subnode_id_data, prefix) - - # 验证 matched_node_link 是否被正确更新 - self.assertEqual(subnode_id_data['matched_node_link'], ['N___link_1', 'N___link_2']) - - def test_no_update_matched_node_links(self): - subnode_id_data = { - 'matched_node_link': ['link_1', 'link_2'] - } - prefix = 'N___' - - # 模拟常量 SETS - constants = MagicMock() - constants.SETS = { - 'bench': ('bench', 'B___', 'N___'), - 'npu': ('npu', 'N___', 'B___'), - 'B___': ('bench', 'N___'), - 'N___': ('npu', 'B___') - } - - # 不更新第一个 matched_node_link - subnode_id_data['matched_node_link'][0] = 'prefixlink_1' - - # 调用 _update_matched_node_links 方法 - self.plugin._update_matched_node_links(subnode_id_data, prefix) - - # 验证 linked node 是否正确更新 - self.assertEqual(subnode_id_data['matched_node_link'], ['B___prefixlink_1', 'B___link_2']) - - @patch('os.walk') # 模拟 os.walk - def test_get_run_dirs(self, mock_os_walk): - """测试 _get_run_dirs 方法""" - - # 设置模拟返回的文件夹和文件 - fake_logdir = os.path.join(os.getcwd(), "fake", "logdir") # 使用绝对路径 - mock_os_walk.return_value = [(fake_logdir, [], ["run1_tag1.vis", "run2_tag2.vis"])] - - # 设置文件大小返回值 - with patch('os.path.getsize', return_value=500): # 模拟文件小于限制 - run_tag_pairs = self.plugin._get_run_dirs() - - # 验证返回的 run_tag_pairs - # 使用 os.path.normpath 来确保路径在不同操作系统上被标准化 - expected_run_tag_pairs = [ - (os.path.normpath(os.path.join(fake_logdir)), 'run1_tag1'), - (os.path.normpath(os.path.join(fake_logdir)), 'run2_tag2') - ] - - self.assertEqual(run_tag_pairs, expected_run_tag_pairs) - - @patch('os.path.getsize') # 模拟 os.path.getsize - def test_get_run_dirs_with_large_file(self, mock_getsize): - """测试 _get_run_dirs 方法,当文件超过大小限制时""" - - # 模拟一个文件大于最大限制 - mock_getsize.return_value = 2000 * 1024 * 1024 # 文件超过 1GB - - # 使用 os.path.join 来构建路径,确保兼容 Windows 和 Linux - fake_logdir = os.path.join("fake", "logdir") - large_file = "large_file.vis" - - with patch('os.walk', return_value=[(fake_logdir, [], [large_file])]): - run_tag_pairs = self.plugin._get_run_dirs() - - # 验证文件被跳过,不会返回任何文件 - self.assertEqual(run_tag_pairs, []) # 文件被跳过,不会返回任何文件 - - def test_convert_to_protobuf_format(self): - """测试 _convert_to_protobuf_format 方法""" - # 模拟节点数据 - subgraph = { - 'node': { - 'npu_node_1': { - 'id': 'op_1', - 'node_type': 1, - 'matched_node_link': ['bench_node_1'], - 'data': { - 'precision_index': 10, - 'other_data': 'value' - }, - 'input_data': {}, - 'output_data': {}, - 'suggestions': {}, - 'subnodes': [], - 'stack_info': 'stack_1' - } - } - } - - # 调用方法 - protobuf_format = self.plugin._convert_to_protobuf_format(subgraph) - - # 验证 protobuf 格式是否正确 - self.assertIn('node {', protobuf_format) - self.assertIn('name: "npu_node_1"', protobuf_format) - self.assertIn('op: "op_1"', protobuf_format) - self.assertIn('precision_index: 10', protobuf_format) - self.assertIn('isLeaf: true', protobuf_format) - - @patch('json.load') # 模拟 json.load - def test_read_json_file_invalid(self, mock_json_load): - """测试 _read_json_file 方法,当文件无效时""" - # 设置模拟的文件路径 - mock_file_path = os.path.join("fake", "file.vis") # 使用 os.path.join 来构造路径 - - # 模拟 json.load 抛出异常 - mock_json_load.side_effect = Exception("Invalid JSON") - - # 使用模拟的路径读取文件 - result = self.plugin._read_json_file(mock_file_path) - - # 验证返回值是 None,并且日志中有错误消息 - self.assertIsNone(result) - - @patch('os.path.exists', return_value=False) - def test_load_json_file_not_found(self, mock_exists): - """测试 _load_json_file 方法,当文件不存在时""" - - # 使用 os.path.join 来确保路径的兼容性 - mock_file_path = os.path.join("fake", "file.vis") - mock_tag = "tag1" - - # 调用方法 - result = self.plugin._load_json_file(mock_file_path, mock_tag) - - # 验证返回值是否为 None - self.assertIsNone(result) - - # 验证 _current_file_path 是否为空 - self.assertEqual(self.plugin._current_file_path, "") - - def test_get_input_output_data(self): - npu_node_data = { - 'input_data': {'input_1': 'data1', 'input_2': 'data2'}, - 'output_data': {'output_1': 'data3'} - } - bench_node_data = { - 'input_data': {'input_1': 'dataA', 'input_2': 'dataB'}, - 'output_data': {'output_1': 'dataC', 'output_2': 'dataD'} - } - - # 调用方法 - ( - npu_input_data, - bench_input_data, - npu_output_data, - bench_output_data - ) = self.instance.get_input_output_data(npu_node_data, bench_node_data) - - # 验证返回结果 - self.assertEqual(npu_input_data, {'input_1': 'data1', 'input_2': 'data2'}) - self.assertEqual(bench_input_data, {'input_1': 'dataA', 'input_2': 'dataB'}) - self.assertEqual(npu_output_data, {'output_1': 'data3'}) - self.assertEqual(bench_output_data, {'output_1': 'dataC', 'output_2': 'dataD'}) - - def test_calculate_min_length(self): - # 模拟输入输出数据 - npu_input_data = {'input_1': 'data1', 'input_2': 'data2'} - bench_input_data = {'input_1': 'dataA', 'input_2': 'dataB', 'input_3': 'dataC'} - npu_output_data = {'output_1': 'data3'} - bench_output_data = {'output_1': 'dataC', 'output_2': 'dataD'} - - # 调用方法 - input_min_length, output_min_length = self.instance.calculate_min_length( - npu_input_data, - bench_input_data, - npu_output_data, - bench_output_data - ) - - # 验证返回值 - self.assertEqual(input_min_length, 2) # 最小输入数据长度 - self.assertEqual(output_min_length, 1) # 最小输出数据长度 - - def test_get_keys(self): - # 模拟 npu 和 bench 数据 - npu_data = { - 'input_data': {'input_1': 'data1', 'input_2': 'data2'}, - 'output_data': {'output_1': 'data3'} - } - bench_data = { - 'input_data': {'input_1': 'dataA', 'input_2': 'dataB'}, - 'output_data': {'output_1': 'dataC', 'output_2': 'dataD'} - } - - # 调用方法 - npu_keys, bench_keys = self.instance.get_keys(npu_data, bench_data) - - # 验证返回值 - self.assertEqual(npu_keys, ['input_data', 'output_data']) - self.assertEqual(bench_keys, ['input_data', 'output_data']) - - def test_calculate_diff_and_relative_error(self): - # 模拟 npu_data 和 bench_data - npu_data = { - 'Max': 10.0, - 'Min': 1.0, - 'Mean': 5.5, - 'Norm': 8.0 - } - bench_data = { - 'Max': 12.0, - 'Min': 2.0, - 'Mean': 5.0, - 'Norm': 7.0 - } - - # 调用方法 - results = self.instance.calculate_diff_and_relative_error(npu_data, bench_data) - - # 验证返回结果 - self.assertEqual(results['npu_Max'], 10.0) - self.assertEqual(results['bench_Max'], 12.0) - self.assertEqual(results['Max_relative_err'], "16.666667%") - - self.assertEqual(results['npu_Min'], 1.0) - self.assertEqual(results['bench_Min'], 2.0) - self.assertEqual(results['Min_relative_err'], "50.000000%") - - self.assertEqual(results['npu_Mean'], 5.5) - self.assertEqual(results['bench_Mean'], 5.0) - self.assertEqual(results['Mean_relative_err'], "10.000000%") - - self.assertEqual(results['npu_Norm'], 8.0) - self.assertEqual(results['bench_Norm'], 7.0) - self.assertEqual(results['Norm_relative_err'], "14.285714%") - - def test_calculate_diff_and_relative_error_with_zero_bench_value(self): - # 模拟 npu_data 和 bench_data,其中 bench_data 有零值 - npu_data = { - 'Max': 10.0, - 'Min': 1.0, - 'Mean': 5.5, - 'Norm': 8.0 - } - bench_data = { - 'Max': 12.0, - 'Min': 0.0, # bench Min 为 0,应该触发 "N/A" 处理 - 'Mean': 5.0, - 'Norm': 0.0 # bench Norm 为 0,应该触发 "N/A" 处理 - } - - # 调用方法 - results = self.instance.calculate_diff_and_relative_error(npu_data, bench_data) - - # 验证返回结果 - self.assertEqual(results['Min_relative_err'], "N/A") - self.assertEqual(results['Norm_relative_err'], "N/A") - -if __name__ == '__main__': - unittest.main() \ No newline at end of file diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py b/plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py new file mode 100644 index 00000000000..b3cbc2b1e28 --- /dev/null +++ b/plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py @@ -0,0 +1,39 @@ +import pytest +import json +import os +from pathlib import Path + + +def load_test_cases(): + meta_path = Path(__file__).parent / "test_data/metadata.json" # 修改文件扩展名为 .json + with open(meta_path) as f: + return json.load(f)["test_cases"] # 使用 json.load 代替 yaml.safe_load + + +# 动态生成测试用例 +def pytest_generate_tests(metafunc): + if "meta_data" in metafunc.fixturenames and "operation" in metafunc.fixturenames: + test_cases = load_test_cases() + params = [] + for case in test_cases: + metaData = case["metaData"] + for op in case["operations"]: + params.append(pytest.param( + metaData, + op, + id=f"{metaData['run']}-{op['type']}" + )) + # 确保参数名称与参数值数量一致 + metafunc.parametrize("meta_data, operation", params) + + +@pytest.fixture +def graph_data(meta_data): + # 返回当前测试的操作配置 + return meta_data + + +@pytest.fixture +def operation_config(operation): + # 返回当前测试的操作配置 + return operation diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/pytest.ini b/plugins/tensorboard-plugins/tb_graph_ascend/tests/pytest.ini new file mode 100644 index 00000000000..ddb991b9341 --- /dev/null +++ b/plugins/tensorboard-plugins/tb_graph_ascend/tests/pytest.ini @@ -0,0 +1,9 @@ +[pytest] +testpaths = tests +python_files = test_*.py +norecursedirs = .* venv build dist +addopts = -v --strict-markers +log_cli = true +log_level = DEBUG +markers = + slow: marks tests as slow (deselect with -m 'not slow') \ No newline at end of file diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/test_data/compare_statis.vis b/plugins/tensorboard-plugins/tb_graph_ascend/tests/test_data/compare_statis.vis new file mode 100644 index 00000000000..d37e9f96a3c --- /dev/null +++ b/plugins/tensorboard-plugins/tb_graph_ascend/tests/test_data/compare_statis.vis @@ -0,0 +1,948 @@ +{ + "ToolTip": "{\"shape\": \"\\u6570\"}", + "NPU": { + "edge": [], + "node": { + "AddOne_0": { + "matched_node_link": [ + "B___AddOne_0" + ], + "data": { + "precision_index": 0.0 + }, + "id": "AddOne_0", + "inputs": [], + "input_data": { + "AddOne_0.input_arg.0": { + "type": "torch.Tensor", + "dtype": "", + "shape": [ + 32, + 512, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406", + "MaxAbsErr": 0.0, + "MinAbsErr": 0.0, + "MeanAbsErr": 0.0, + "NormAbsErr": 0.0, + "MaxRelativeErr": "0.0000%", + "MinRelativeErr": "0.0000%", + "MeanRelativeErr": "0.0000%", + "NormRelativeErr": "0.0000%" + }, + "AddOne_0.input_arg.1": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 64, + 256, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406", + "MaxAbsErr": 0.0, + "MinAbsErr": 0.0, + "MeanAbsErr": 0.0, + "NormAbsErr": 0.0, + "MaxRelativeErr": "0.0000%", + "MinRelativeErr": "0.0000%", + "MeanRelativeErr": "0.0000%", + "NormRelativeErr": "0.0000%" + }, + "AddOne_0.1": {}, + "AddOne_0.2": {} + }, + "output_data": { + "AddOne_0.output_arg.0": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 32, + 512, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406", + "MaxAbsErr": 0.0, + "MinAbsErr": 0.0, + "MeanAbsErr": 0.0, + "NormAbsErr": 0.0, + "MaxRelativeErr": "0.0000%", + "MinRelativeErr": "0.0000%", + "MeanRelativeErr": "0.0000%", + "NormRelativeErr": "0.0000%" + }, + "AddOne_0.output_arg.1": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 64, + 256, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406", + "MaxAbsErr": 0.0, + "MinAbsErr": 0.0, + "MeanAbsErr": 0.0, + "NormAbsErr": 0.0, + "MaxRelativeErr": "0.0000%", + "MinRelativeErr": "0.0000%", + "MeanRelativeErr": "0.0000%", + "NormRelativeErr": "0.0000%" + }, + "AddOne_0.1": {}, + "AddOne_0.2": {} + }, + "is_forward": true, + "node_type": 0, + "outputs": [], + "pair": "None", + "subnodes": [ + "Test.add_0_withlonglonglonglonglonglonglonglongname.tt.ee", + "add_51111" + ], + "type": "AddOne", + "upnode": "Test.maxpoolMaxPool2.maxpoolpo.tt.ee" + }, + "AddOne_1": { + "matched_node_link": [], + "data": { + "precision_index": 0.8 + }, + "id": "AddOne_1", + "inputs": [], + "input_data": { + "Test.maxpoolMaxPool2.maxpoolpo.tt.ee.input_arg.0": { + "data_name": "-10", + "longlonglonglonglonglongName": "hah", + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": "[32, 512, 2, 2]", + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406", + "error_key": [ + "type", + "shape" + ] + }, + "Test.maxpoolMaxPool2.maxpoolpo.tt.ee.kwrag_arg.1": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 64, + 256, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + } + }, + "is_forward": true, + "node_type": 9, + "outputs": [], + "output_data": {}, + "pair": "None", + "subnodes": [ + "add_1", + "add_4" + ], + "type": "AddOne", + "upnode": "Test.maxpoolMaxPool2.maxpoolpo.tt.ee" + }, + "Test.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.tt.ee": { + "matched_node_link": [], + "data": { + "precision_index": 0 + }, + "id": "Test.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.tt.ee", + "inputs": [], + "is_forward": true, + "node_type": 0, + "outputs": [], + "output_data": {}, + "pair": "None", + "subnodes": [ + "add_2" + ], + "type": "AddOne", + "upnode": "AddThree_0", + "micro_step_id": "3" + }, + "AddThree_0": { + "matched_node_link": [ + "B___AddThree_0" + ], + "data": { + "precision_index": 0.5 + }, + "id": "AddThree_0", + "input_data": {}, + "is_forward": true, + "node_type": 0, + "outputs": [], + "output_data": {}, + "pair": "None", + "subnodes": [ + "arg0_1_0", + "Test.maxpoolMaxPool2.maxpoolpo.tt.ee", + "Test.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.tt.ee", + "output_0" + ], + "type": "AddThree", + "upnode": "None" + }, + "Test.maxpoolMaxPool2.maxpoolpo.tt.ee": { + "matched_node_link": [ + "B___Test.maxpoolMaxPool2.maxpoolpo.tt.ee" + ], + "data": { + "precision_status": false, + "Host Self Duration(us)": 56.24, + "Host Total Duration(us)": 56.24, + "Device Self Duration(us)": 0, + "Device Total Duration(us)": 0, + "overflow_level": "medium" + }, + "id": "Test.maxpoolMaxPool2.maxpoolpo.tt.ee", + "inputs": [], + "input_data": { + "Test.maxpoolMaxPool2.maxpoolpo.tt.ee.input_arg.0": { + "data_name": "-10", + "longlonglonglonglonglongName": "hah", + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": "[32, 512, 2, 2]", + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406", + "error_key": [ + "type", + "shape" + ] + }, + "Test.maxpoolMaxPool2.maxpoolpo.tt.ee.kwrag_arg.1": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 64, + 256, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + } + }, + "is_forward": true, + "node_type": 0, + "outputs": [], + "output_data": { + "output.0": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 128, + 512, + 2, + 2 + ], + "Max": "538.2343242", + "Min": "-234.124124234", + "Mean": "-510.23432654", + "Norm": "3555.3406" + }, + "output.1": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 16, + 256, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + } + }, + "pair": "None", + "subnodes": [ + "AddOne_0", + "AddOne_1" + ], + "suggestions": { + "text": "test ptdbg工具 with longlong tenm tensldjta te alsejtka gaew jtljae tet jsdklfj.", + "ptdbg工具": "https://gitee.com/ascend/att/tree/master/debug/accuracy_tools/ptdbg_ascend" + }, + "stack_info": [ + "File /home/w3000/xxxx/subnodes/sdd/adad/srit-sda/artar/prased, line 136. om het, \n dada = rtens/sda.ddd(asdw)", + "File /home/w3000/xxxx/subnodes/sdd/adad/srit-sda/artar/prased, line 136. om het, \n dada = rtens/sda.ddd(asdw)", + "File /home/w3000/xxxx/subnodes/sdd/adad/srit-sda/artar/prased, line 136. om het, \n dada = rtens/sda.ddd(asdw)" + ], + "type": "AddTwo", + "upnode": "AddThree_0", + "micro_step_id": "0" + }, + "Test.add_0_withlonglonglonglonglonglonglonglongname.tt.ee": { + "matched_node_link": [ + "B___AddThree_0", + "B___Test.maxpoolMaxPool2.maxpoolpo.tt.ee", + "B___AddOne_0", + "B___Test.add_0_withlonglonglonglonglonglonglonglongname.tt.ee" + ], + "data": { + "precision_index": 0.35 + }, + "id": "Test.add_0_withlonglonglonglonglonglonglonglongname.tt.ee", + "inputs": [], + "input_data": { + "input_arg.0": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 32, + 512, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + }, + "input_arg.1": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 64, + 256, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + }, + "input_arg.2": "None" + }, + "is_forward": true, + "node_type": 0, + "outputs": [], + "output_data": { + "output.0": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 128, + 512, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + }, + "output.1": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 16, + 256, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + } + }, + "pair": "None", + "subnodes": [], + "type": "addlongtingmelasidngkonklajelkjsakljgskadtest", + "upnode": "AddOne_0" + }, + "add_51111": { + "matched_node_link": [], + "data": { + "precision_status": true, + "precision_index": 1, + "md5 Compare Result": "Pass" + }, + "id": "add_51111", + "inputs": [], + "input_data": {}, + "is_forward": true, + "node_type": 0, + "outputs": [], + "output_data": {}, + "pair": "None", + "subnodes": [], + "type": "add", + "upnode": "AddOne_0" + }, + "add_1": { + "matched_node_link": [], + "data": { + "precision_status": false, + "precision_index": 0, + "md5 Compare Result": "Pass" + }, + "id": "add_1", + "inputs": [], + "input_data": {}, + "is_forward": true, + "node_type": 0, + "outputs": [], + "output_data": {}, + "pair": "None", + "subnodes": [], + "type": "add", + "upnode": "AddOne_1" + }, + "add_4": { + "matched_node_link": [], + "data": {}, + "id": "add_4", + "inputs": [], + "input_data": {}, + "is_forward": true, + "node_type": 0, + "outputs": [], + "output_data": {}, + "pair": "None", + "subnodes": [], + "type": "add", + "upnode": "AddOne_1" + }, + "add_2": { + "matched_node_link": [], + "data": {}, + "id": "add_2", + "inputs": [], + "input_data": { + "add_2.input_arg.0": { + "longlonglonglonglonglongName": "hah", + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": "[32, 512, 2, 2]", + "Max": "6408.2343242", + "Min": "-3134.124124234", + "Mean": "-501.23432654", + "Norm": "3555.3406", + "error_key": [ + "type", + "shape" + ] + }, + "add_2.kwrag_arg.1": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 64, + 256, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + } + }, + "is_forward": true, + "node_type": 0, + "outputs": [], + "output_data": {}, + "pair": "None", + "subnodes": [], + "type": "add", + "upnode": "Test.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.tt.ee" + }, + "arg0_1_0": { + "matched_node_link": [], + "data": {}, + "id": "arg0_1_0", + "inputs": [], + "input_data": {}, + "is_forward": true, + "node_type": 0, + "outputs": [], + "output_data": {}, + "pair": "None", + "subnodes": [], + "type": "arg0_1", + "upnode": "AddThree_0", + "micro_step_id": "2", + "suggestions": { + "text": "test ptdbg工" + }, + "stack_info": [ + "File /home/w3000/xxxx/subnodes/sdd/adad/srit-sda/artar/prased, line 136. om het, \n dada = rtens/sda.ddd(asdw)" + ] + }, + "output_0": { + "matched_node_link": [], + "data": {}, + "id": "output_0", + "inputs": [], + "input_data": {}, + "is_forward": true, + "node_type": 0, + "outputs": [], + "output_data": {}, + "pair": "None", + "subnodes": [], + "type": "output", + "upnode": "AddThree_0", + "micro_step_id": "3" + } + }, + "root": "AddThree_0" + }, + "Bench": { + "edge": [], + "node": { + "AddOne_0": { + "matched_node_link": [ + "AddOne_0" + ], + "data": {}, + "id": "AddOne_0", + "inputs": [], + "input_data": { + "AddOne_0.input_arg.0": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 32, + 512, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + }, + "AddOne_0.input_arg.1": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 64, + 256, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + } + }, + "output_data": { + "AddOne_0.output_arg.0": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 32, + 512, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + }, + "AddOne_0.output_arg.1": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 64, + 256, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + } + }, + "is_forward": true, + "node_type": 0, + "outputs": [], + "pair": "None", + "subnodes": [ + "Test.add_0_withlonglonglonglonglonglonglonglongname.tt.ee" + ], + "type": "AddOne", + "upnode": "Test.maxpoolMaxPool2.maxpoolpo.tt.ee" + }, + "AddOne_1": { + "matched_node_link": [], + "data": {}, + "id": "AddOne_1", + "inputs": [], + "input_data": {}, + "is_forward": true, + "node_type": 0, + "outputs": [], + "output_data": {}, + "pair": "None", + "subnodes": [ + "add_1" + ], + "type": "AddOne", + "upnode": "Test.maxpoolMaxPool2.maxpoolpo.tt.ee" + }, + "Test.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.tt.ee": { + "matched_node_link": [], + "data": {}, + "id": "Test.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.tt.ee", + "inputs": [], + "input_data": {}, + "is_forward": true, + "node_type": 0, + "outputs": [], + "output_data": {}, + "pair": "None", + "subnodes": [ + "add_2" + ], + "type": "AddOne", + "upnode": "AddThree_0" + }, + "AddThree_0": { + "matched_node_link": [ + "N___AddThree_0" + ], + "data": {}, + "id": "AddThree_0", + "inputs": [], + "input_data": {}, + "is_forward": true, + "node_type": 0, + "outputs": [], + "output_data": {}, + "pair": "None", + "subnodes": [ + "arg0_1_0", + "Test.maxpoolMaxPool2.maxpoolpo.tt.ee", + "Test.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.tt.ee", + "output_0" + ], + "type": "AddThree", + "upnode": "root" + }, + "Test.maxpoolMaxPool2.maxpoolpo.tt.ee": { + "matched_node_link": [], + "data": {}, + "id": "Test.maxpoolMaxPool2.maxpoolpo.tt.ee", + "inputs": [], + "input_data": { + "Test.maxpoolMaxPool2.maxpoolpo.tt.ee.input_arg.0": { + "longlonglonglonglonglongName": "hah", + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": "[32, 512, 2, 2]", + "Max": "548.2343242", + "Min": "-234.124124234", + "Mean": "-5.23432654", + "Norm": "35555.3406", + "error_key": [ + "type", + "shape" + ] + }, + "Test.maxpoolMaxPool2.maxpoolpo.tt.ee.kwrag_arg.1": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 64, + 256, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + } + }, + "is_forward": true, + "node_type": 0, + "outputs": [], + "output_data": { + "output.0": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 128, + 512, + 2, + 2 + ], + "Max": "5038.2343242", + "Min": "-1234.124124234", + "Mean": "-410.23432654", + "Norm": "3255.3406" + }, + "output.1": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 16, + 256, + 2, + 2 + ], + "Max": "538.2343242", + "Min": "-234.124124234", + "Mean": "-51.23432654", + "Norm": "35555.3406" + } + }, + "pair": "None", + "subnodes": [ + "AddOne_0", + "AddOne_1" + ], + "type": "AddTwo", + "upnode": "AddThree_0" + }, + "Test.add_0_withlonglonglonglonglonglonglonglongname.tt.ee": { + "matched_node_link": [ + "N___AddThree_0", + "N___Test.maxpoolMaxPool2.maxpoolpo.tt.ee", + "N___AddOne_0", + "N___Test.add_0_withlonglonglonglonglonglonglonglongname.tt.ee" + ], + "data": {}, + "id": "Test.add_0_withlonglonglonglonglonglonglonglongname.tt.ee", + "inputs": [], + "input_data": { + "input_arg.0": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 32, + 512, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + }, + "input_arg.1": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 64, + 256, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + } + }, + "is_forward": true, + "node_type": 1, + "outputs": [], + "output_data": { + "output.0": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 128, + 512, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + }, + "output.1": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 16, + 256, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + } + }, + "pair": "None", + "subnodes": [], + "type": "add", + "upnode": "AddOne_0" + }, + "add_1": { + "matched_node_link": [], + "data": {}, + "id": "add_1", + "inputs": [], + "input_data": {}, + "is_forward": true, + "node_type": 1, + "outputs": [], + "output_data": {}, + "pair": "None", + "subnodes": [], + "type": "add", + "upnode": "AddOne_1" + }, + "add_2": { + "matched_node_link": [], + "data": {}, + "id": "add_2", + "inputs": [], + "input_data": { + "add_2.input_arg.0": { + "longlonglonglonglonglongName": "hah", + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": "[32, 512, 2, 2]", + "Max": "548.2343242", + "Min": "-234.124124234", + "Mean": "-5.23432654", + "Norm": "35555.3406", + "error_key": [ + "type", + "shape" + ] + }, + "add_2.kwrag_arg.1": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 64, + 256, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + } + }, + "is_forward": true, + "node_type": 1, + "outputs": [], + "output_data": {}, + "pair": "None", + "subnodes": [], + "type": "add", + "upnode": "Test.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.tt.ee" + }, + "arg0_1_0": { + "matched_node_link": [], + "data": {}, + "id": "arg0_1_0", + "inputs": [], + "input_data": {}, + "is_forward": true, + "node_type": 1, + "outputs": [], + "output_data": {}, + "pair": "None", + "subnodes": [], + "type": "arg0_1", + "upnode": "AddThree_0" + }, + "output_0": { + "matched_node_link": [], + "data": {}, + "id": "output_0", + "inputs": [], + "input_data": {}, + "is_forward": true, + "node_type": 1, + "outputs": [], + "output_data": {}, + "pair": "None", + "subnodes": [], + "type": "output", + "upnode": "AddThree_0" + } + }, + "root": "AddThree_0" + }, + "Colors": { + "#FF9B3D": { + "value": [ + 0, + 0.5 + ], + "description": "此节点所有输入输出的统计量相对误差,值越大代表测量值与标杆值的偏差越大,相对误差计算方式:|(测量值-标杆值)/标杆值|" + }, + "#FFDC7F": { + "value": [ + 0.5, + 1 + ], + "description": "此节点所有输入输出的统计量相对误差,值越大代表测量值与标杆值的偏差越大,相对误差计算方式:|(测量值-标杆值)/标杆值|" + }, + "#C7C7C7": { + "value": "无匹配节点", + "description": "对比过程中节点未匹配上" + } + }, + "MicroSteps": 5, + "StepList": [ + "ALL", + 0, + 1, + 2, + 3 + ], + "task": "summary", + "match": [], + "npu_match_nodes": { + "AddOne_0": "AddOne_0" + }, + "bench_match_nodes": { + "AddOne_0": "AddOne_0" + }, + "OverflowCheck": true +} \ No newline at end of file diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/test_data/metadata.json b/plugins/tensorboard-plugins/tb_graph_ascend/tests/test_data/metadata.json new file mode 100644 index 00000000000..50b3ddf6fc7 --- /dev/null +++ b/plugins/tensorboard-plugins/tb_graph_ascend/tests/test_data/metadata.json @@ -0,0 +1,44 @@ +{ + "test_cases": [ + { + "metaData": { + "run": "C:/code/mstt/plugins/tensorboard-plugins/tb_graph_ascend/tests/test_data", + "tag": "compare_statis" + }, + "operations": [ + { + "type": "add_relation", + "source": "NodeA", + "target": "NodeB", + "expected": "success" + }, + { + "type": "remove_node", + "node": "NodeC", + "expected": null, + "error": "NodeNotFound" + } + ] + }, + { + "metaData": { + "run": "C:/code/mstt/plugins/tensorboard-plugins/tb_graph_ascend/tests/test_data", + "tag": "compare_statis" + }, + "operations": [ + { + "type": "add_relation", + "source": "NodeA", + "target": "NodeB", + "expected": "success" + }, + { + "type": "remove_node", + "node": "NodeC", + "expected": null, + "error": "NodeNotFound" + } + ] + } + ] +} \ No newline at end of file diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/units/controllers/test_match_nodes_controller.py b/plugins/tensorboard-plugins/tb_graph_ascend/tests/units/controllers/test_match_nodes_controller.py new file mode 100644 index 00000000000..1a5393e08bb --- /dev/null +++ b/plugins/tensorboard-plugins/tb_graph_ascend/tests/units/controllers/test_match_nodes_controller.py @@ -0,0 +1,11 @@ +import pytest +from server.app.controllers.match_nodes_controller import MatchNodesController +from server.app.utils.graph_utils import GraphUtils + + +class TestMatchNodesController: + + @pytest.fixture(autouse=True) + def setup_manager(self, graph_data): + self.graph_data = GraphUtils.get_graph_data(graph_data) + diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/units/service/test_graph_service.py b/plugins/tensorboard-plugins/tb_graph_ascend/tests/units/service/test_graph_service.py new file mode 100644 index 00000000000..dcdabf195a1 --- /dev/null +++ b/plugins/tensorboard-plugins/tb_graph_ascend/tests/units/service/test_graph_service.py @@ -0,0 +1,20 @@ +import pytest +from server.app.controllers.match_nodes_controller import MatchNodesController +from server.app.utils.graph_utils import GraphUtils + + +class TestMatchNodesService: + + @pytest.fixture(autouse=True) + def setup_manager(self, meta_data): + print('meta_data', meta_data) + self.graph_data = GraphUtils.get_graph_data(meta_data) + + def test_operation(self, operation_config): + print("operation_config: ", operation_config) + op_type = operation_config["type"] + expected = operation_config["expected"] + print("op_type: ", op_type) + print("expected: ", expected) + assert True + print('---------------') diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/units/test_plugin.py b/plugins/tensorboard-plugins/tb_graph_ascend/tests/units/test_plugin.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/units/utils/test_graph_utils.py b/plugins/tensorboard-plugins/tb_graph_ascend/tests/units/utils/test_graph_utils.py new file mode 100644 index 00000000000..e69de29bb2d -- Gitee From caf884fae78aedcb313736113fede2ddbebe06a1 Mon Sep 17 00:00:00 2001 From: sunchao <1299792067@qq.com> Date: Mon, 24 Mar 2025 20:10:50 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=F0=9F=A6=84=20refactor:=20=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tb_graph_ascend/server/app/utils/graph_utils.py | 1 - plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py | 2 +- .../tests/{test_data => data}/compare_statis.vis | 0 .../tb_graph_ascend/tests/{test_data => data}/metadata.json | 4 ++-- .../{units => integration}/service/test_graph_service.py | 0 5 files changed, 3 insertions(+), 4 deletions(-) rename plugins/tensorboard-plugins/tb_graph_ascend/tests/{test_data => data}/compare_statis.vis (100%) rename plugins/tensorboard-plugins/tb_graph_ascend/tests/{test_data => data}/metadata.json (94%) rename plugins/tensorboard-plugins/tb_graph_ascend/tests/{units => integration}/service/test_graph_service.py (100%) diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/server/app/utils/graph_utils.py b/plugins/tensorboard-plugins/tb_graph_ascend/server/app/utils/graph_utils.py index 34b5d74550f..1829f2a80d4 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/server/app/utils/graph_utils.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/server/app/utils/graph_utils.py @@ -145,7 +145,6 @@ class GraphUtils: """Load a single .vis file from a given directory based on the tag.""" file_path = os.path.join(run_dir, f"{tag}.vis") file_path = os.path.normpath(file_path) # 标准化路径 - print(os.path.exists(file_path)) if os.path.exists(file_path): # 校验文件的读权限 if not os.access(file_path, os.R_OK): diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py b/plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py index b3cbc2b1e28..daf242d2da5 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py @@ -5,7 +5,7 @@ from pathlib import Path def load_test_cases(): - meta_path = Path(__file__).parent / "test_data/metadata.json" # 修改文件扩展名为 .json + meta_path = Path(__file__).parent / "data/metadata.json" # 修改文件扩展名为 .json with open(meta_path) as f: return json.load(f)["test_cases"] # 使用 json.load 代替 yaml.safe_load diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/test_data/compare_statis.vis b/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/compare_statis.vis similarity index 100% rename from plugins/tensorboard-plugins/tb_graph_ascend/tests/test_data/compare_statis.vis rename to plugins/tensorboard-plugins/tb_graph_ascend/tests/data/compare_statis.vis diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/test_data/metadata.json b/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata.json similarity index 94% rename from plugins/tensorboard-plugins/tb_graph_ascend/tests/test_data/metadata.json rename to plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata.json index 50b3ddf6fc7..172ad821f6f 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/tests/test_data/metadata.json +++ b/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata.json @@ -2,7 +2,7 @@ "test_cases": [ { "metaData": { - "run": "C:/code/mstt/plugins/tensorboard-plugins/tb_graph_ascend/tests/test_data", + "run": "C:/code/mstt/plugins/tensorboard-plugins/tb_graph_ascend/tests/data", "tag": "compare_statis" }, "operations": [ @@ -22,7 +22,7 @@ }, { "metaData": { - "run": "C:/code/mstt/plugins/tensorboard-plugins/tb_graph_ascend/tests/test_data", + "run": "C:/code/mstt/plugins/tensorboard-plugins/tb_graph_ascend/tests/data", "tag": "compare_statis" }, "operations": [ diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/units/service/test_graph_service.py b/plugins/tensorboard-plugins/tb_graph_ascend/tests/integration/service/test_graph_service.py similarity index 100% rename from plugins/tensorboard-plugins/tb_graph_ascend/tests/units/service/test_graph_service.py rename to plugins/tensorboard-plugins/tb_graph_ascend/tests/integration/service/test_graph_service.py -- Gitee From 2f7112d3a6712b21fd03d098e0eb37ddc4c02756 Mon Sep 17 00:00:00 2001 From: sunchao <1299792067@qq.com> Date: Tue, 25 Mar 2025 15:15:03 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=F0=9F=A7=AA=20test:=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?service=E5=B1=82=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tb_graph_ascend/.gitignore | 5 +- .../tb_graph_ascend/server/plugin.py | 2 +- .../tb_graph_ascend/tests/conftest.py | 9 +- .../tests/data/compare_statis.vis | 2 +- .../tb_graph_ascend/tests/data/metadata.json | 44 ---- .../tests/data/metadata_st.json | 237 ++++++++++++++++++ .../tests/data/metadata_ut.json | 0 .../integration/service/test_graph_service.py | 43 +++- 8 files changed, 283 insertions(+), 59 deletions(-) delete mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata.json create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata_st.json create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata_ut.json diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/.gitignore b/plugins/tensorboard-plugins/tb_graph_ascend/.gitignore index 75bc12db636..15cd1b851a1 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/.gitignore +++ b/plugins/tensorboard-plugins/tb_graph_ascend/.gitignore @@ -5,4 +5,7 @@ dist/ build/ tb_graph_ascend.egg-info/ __pycache__/ -/server/static/index.html \ No newline at end of file +/server/static/index.html +/report.html +/assets/ +/htmlcov/ \ No newline at end of file diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/server/plugin.py b/plugins/tensorboard-plugins/tb_graph_ascend/server/plugin.py index aea5b10913e..02cf7e75129 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/server/plugin.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/server/plugin.py @@ -170,7 +170,7 @@ class GraphsPlugin(base_plugin.TBPlugin): # 返回格式为 [[NPU节点ID列表], [Bench节点ID列表]] return [npu_ids, bench_ids] - def dfs_collect_nodes(self, json_data, request): + def dfs_collect_nodes(self, json_data, request): root_subnodes_set = [] all_node_names = [] try: diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py b/plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py index daf242d2da5..a45b29625ec 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py @@ -4,8 +4,8 @@ import os from pathlib import Path -def load_test_cases(): - meta_path = Path(__file__).parent / "data/metadata.json" # 修改文件扩展名为 .json +def load_st_test_cases(): + meta_path = Path(__file__).parent / "data/metadata_st.json" # 修改文件扩展名为 .json with open(meta_path) as f: return json.load(f)["test_cases"] # 使用 json.load 代替 yaml.safe_load @@ -13,10 +13,11 @@ def load_test_cases(): # 动态生成测试用例 def pytest_generate_tests(metafunc): if "meta_data" in metafunc.fixturenames and "operation" in metafunc.fixturenames: - test_cases = load_test_cases() + test_cases = load_st_test_cases() params = [] for case in test_cases: - metaData = case["metaData"] + metaData = case["meta_data"] + metaData["run"] = Path(__file__).parent / metaData["run"] for op in case["operations"]: params.append(pytest.param( metaData, diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/compare_statis.vis b/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/compare_statis.vis index d37e9f96a3c..5820af6ac01 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/compare_statis.vis +++ b/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/compare_statis.vis @@ -5,7 +5,7 @@ "node": { "AddOne_0": { "matched_node_link": [ - "B___AddOne_0" + "AddOne_0" ], "data": { "precision_index": 0.0 diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata.json b/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata.json deleted file mode 100644 index 172ad821f6f..00000000000 --- a/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "test_cases": [ - { - "metaData": { - "run": "C:/code/mstt/plugins/tensorboard-plugins/tb_graph_ascend/tests/data", - "tag": "compare_statis" - }, - "operations": [ - { - "type": "add_relation", - "source": "NodeA", - "target": "NodeB", - "expected": "success" - }, - { - "type": "remove_node", - "node": "NodeC", - "expected": null, - "error": "NodeNotFound" - } - ] - }, - { - "metaData": { - "run": "C:/code/mstt/plugins/tensorboard-plugins/tb_graph_ascend/tests/data", - "tag": "compare_statis" - }, - "operations": [ - { - "type": "add_relation", - "source": "NodeA", - "target": "NodeB", - "expected": "success" - }, - { - "type": "remove_node", - "node": "NodeC", - "expected": null, - "error": "NodeNotFound" - } - ] - } - ] -} \ No newline at end of file diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata_st.json b/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata_st.json new file mode 100644 index 00000000000..820e11cc39b --- /dev/null +++ b/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata_st.json @@ -0,0 +1,237 @@ +{ + "test_cases": [ + { + "meta_data": { + "run": "data", + "tag": "compare_statis" + }, + "operations": [ + { + "type": "get_node_info", + "node_info": { + "nodeName": "Test.maxpoolMaxPool2.maxpoolpo.tt.ee", + "nodeType": "Bench" + }, + "expected": { + "success": true, + "data": { + "matched_node_link": [], + "data": {}, + "id": "Test.maxpoolMaxPool2.maxpoolpo.tt.ee", + "inputs": [], + "input_data": { + "Test.maxpoolMaxPool2.maxpoolpo.tt.ee.input_arg.0": { + "longlonglonglonglonglongName": "hah", + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": "[32, 512, 2, 2]", + "Max": "548.2343242", + "Min": "-234.124124234", + "Mean": "-5.23432654", + "Norm": "35555.3406", + "error_key": [ + "type", + "shape" + ] + }, + "Test.maxpoolMaxPool2.maxpoolpo.tt.ee.kwrag_arg.1": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 64, + 256, + 2, + 2 + ], + "Max": "5348.2343242", + "Min": "-2344.124124234", + "Mean": "-51.23432654", + "Norm": "355555.3406" + } + }, + "is_forward": true, + "node_type": 0, + "outputs": [], + "output_data": { + "output.0": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 128, + 512, + 2, + 2 + ], + "Max": "5038.2343242", + "Min": "-1234.124124234", + "Mean": "-410.23432654", + "Norm": "3255.3406" + }, + "output.1": { + "type": "torch.Tensor", + "dtype": "torch.float32", + "shape": [ + 16, + 256, + 2, + 2 + ], + "Max": "538.2343242", + "Min": "-234.124124234", + "Mean": "-51.23432654", + "Norm": "35555.3406" + } + }, + "pair": "None", + "subnodes": [ + "AddOne_0", + "AddOne_1" + ], + "type": "AddTwo", + "upnode": "AddThree_0" + } + } + }, + { + "type": "add_match_nodes", + "npu_node_name": "AddOne_0", + "bench_node_name": "AddOne_0", + "expected": { + "success": true, + "data": { + "precision_error": 0.0, + "intput_statistical_diff": { + "AddOne_0.input_arg.0": { + "MaxAbsErr": 0.0, + "MinAbsErr": 0.0, + "MeanAbsErr": 0.0, + "NormAbsErr": 0.0, + "MaxRelativeErr": "0.0000%", + "MinRelativeErr": "0.0000%", + "MeanRelativeErr": "0.0000%", + "NormRelativeErr": "0.0000%" + }, + "AddOne_0.input_arg.1": { + "MaxAbsErr": 0.0, + "MinAbsErr": 0.0, + "MeanAbsErr": 0.0, + "NormAbsErr": 0.0, + "MaxRelativeErr": "0.0000%", + "MinRelativeErr": "0.0000%", + "MeanRelativeErr": "0.0000%", + "NormRelativeErr": "0.0000%" + } + }, + "output_statistical_diff": { + "AddOne_0.output_arg.0": { + "MaxAbsErr": 0.0, + "MinAbsErr": 0.0, + "MeanAbsErr": 0.0, + "NormAbsErr": 0.0, + "MaxRelativeErr": "0.0000%", + "MinRelativeErr": "0.0000%", + "MeanRelativeErr": "0.0000%", + "NormRelativeErr": "0.0000%" + }, + "AddOne_0.output_arg.1": { + "MaxAbsErr": 0.0, + "MinAbsErr": 0.0, + "MeanAbsErr": 0.0, + "NormAbsErr": 0.0, + "MaxRelativeErr": "0.0000%", + "MinRelativeErr": "0.0000%", + "MeanRelativeErr": "0.0000%", + "NormRelativeErr": "0.0000%" + } + } + } + } + }, + { + "type": "delete_match_nodes", + "npu_node_name": "AddOne_0", + "bench_node_name": "AddOne_0", + "expected": { + "success": true, + "data": {} + } + }, + { + "type": "add_match_nodes", + "npu_node_name": "AddOne_0", + "bench_node_name": "AddOne_0", + "expected": { + "success": true, + "data": { + "precision_error": 0.0, + "intput_statistical_diff": { + "AddOne_0.input_arg.0": { + "MaxAbsErr": 0.0, + "MinAbsErr": 0.0, + "MeanAbsErr": 0.0, + "NormAbsErr": 0.0, + "MaxRelativeErr": "0.0000%", + "MinRelativeErr": "0.0000%", + "MeanRelativeErr": "0.0000%", + "NormRelativeErr": "0.0000%" + }, + "AddOne_0.input_arg.1": { + "MaxAbsErr": 0.0, + "MinAbsErr": 0.0, + "MeanAbsErr": 0.0, + "NormAbsErr": 0.0, + "MaxRelativeErr": "0.0000%", + "MinRelativeErr": "0.0000%", + "MeanRelativeErr": "0.0000%", + "NormRelativeErr": "0.0000%" + } + }, + "output_statistical_diff": { + "AddOne_0.output_arg.0": { + "MaxAbsErr": 0.0, + "MinAbsErr": 0.0, + "MeanAbsErr": 0.0, + "NormAbsErr": 0.0, + "MaxRelativeErr": "0.0000%", + "MinRelativeErr": "0.0000%", + "MeanRelativeErr": "0.0000%", + "NormRelativeErr": "0.0000%" + }, + "AddOne_0.output_arg.1": { + "MaxAbsErr": 0.0, + "MinAbsErr": 0.0, + "MeanAbsErr": 0.0, + "NormAbsErr": 0.0, + "MaxRelativeErr": "0.0000%", + "MinRelativeErr": "0.0000%", + "MeanRelativeErr": "0.0000%", + "NormRelativeErr": "0.0000%" + } + } + } + } + }, + { + "type": "get_matched_state_list", + "expected": { + "success": true, + "data": { + "npu_match_nodes": { + "AddOne_0": "AddOne_0" + }, + "bench_match_nodes": { + "AddOne_0": "AddOne_0" + } + } + } + }, + { + "type": "save_data", + "expected": { + "success": true + } + } + ] + } + ] +} \ No newline at end of file diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata_ut.json b/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata_ut.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/integration/service/test_graph_service.py b/plugins/tensorboard-plugins/tb_graph_ascend/tests/integration/service/test_graph_service.py index dcdabf195a1..6a649e2fd08 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/tests/integration/service/test_graph_service.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/tests/integration/service/test_graph_service.py @@ -1,5 +1,5 @@ import pytest -from server.app.controllers.match_nodes_controller import MatchNodesController +from server.app.service.graph_service import GraphService from server.app.utils.graph_utils import GraphUtils @@ -7,14 +7,41 @@ class TestMatchNodesService: @pytest.fixture(autouse=True) def setup_manager(self, meta_data): - print('meta_data', meta_data) self.graph_data = GraphUtils.get_graph_data(meta_data) - def test_operation(self, operation_config): - print("operation_config: ", operation_config) + def test_service(self, meta_data, operation_config): op_type = operation_config["type"] expected = operation_config["expected"] - print("op_type: ", op_type) - print("expected: ", expected) - assert True - print('---------------') + # 执行操作 + try: + if op_type == "get_node_info": + result = GraphService.get_node_info( + node_info=operation_config["node_info"], + meta_data=meta_data + ) + elif op_type == "add_match_nodes": + result = GraphService.add_match_nodes( + npu_node_name=operation_config["npu_node_name"], + bench_node_name=operation_config["bench_node_name"], + meta_data=meta_data + ) + elif op_type == "delete_match_nodes": + result = GraphService.delete_match_nodes( + npu_node_name=operation_config["npu_node_name"], + bench_node_name=operation_config["bench_node_name"], + meta_data=meta_data + ) + elif op_type == "get_matched_state_list": + result = GraphService.get_matched_state_list( + meta_data=meta_data + ) + elif op_type == "save_data": + result = GraphService.save_data( + meta_data=meta_data + ) + except Exception as e: + result = {"error": type(e).__name__} + + # 验证结果 + assert result == expected, \ + f"Operation {op_type} failed on {operation_config}" -- Gitee From bb820bbf0640526db57e5be41e5c1ca4f50c325f Mon Sep 17 00:00:00 2001 From: sunchao <1299792067@qq.com> Date: Wed, 26 Mar 2025 09:15:32 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=90=AD=E5=BB=BA?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tb_graph_ascend/.gitignore | 4 +- .../app/controllers/match_nodes_controller.py | 19 +- .../tb_graph_ascend/tests/conftest.py | 33 +++- .../tests/data/metadata_ut.json | 174 ++++++++++++++++++ .../integration/service/test_graph_service.py | 5 - .../test_match_nodes_controller.py | 72 +++++++- 6 files changed, 282 insertions(+), 25 deletions(-) diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/.gitignore b/plugins/tensorboard-plugins/tb_graph_ascend/.gitignore index 15cd1b851a1..70f4e767811 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/.gitignore +++ b/plugins/tensorboard-plugins/tb_graph_ascend/.gitignore @@ -6,6 +6,6 @@ build/ tb_graph_ascend.egg-info/ __pycache__/ /server/static/index.html -/report.html -/assets/ +report.html +assets/ /htmlcov/ \ No newline at end of file diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/server/app/controllers/match_nodes_controller.py b/plugins/tensorboard-plugins/tb_graph_ascend/server/app/controllers/match_nodes_controller.py index 83bb2d8362f..9517d252ca2 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/server/app/controllers/match_nodes_controller.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/server/app/controllers/match_nodes_controller.py @@ -20,9 +20,6 @@ from ..utils.global_state import ADD_MATCH_KEYS class MatchNodesController: - def add(a, b): - return a + b - @staticmethod def process_md5_task_add(graph_data, npu_node_name, bench_node_name): npu_match_nodes_list = graph_data.get('npu_match_nodes', {}) @@ -41,10 +38,12 @@ class MatchNodesController: # 在原始数据上,添加匹配节点,和匹配节点信息 npu_node_data['matched_node_link'] = [bench_node_name] bench_node_data['matched_node_link'] = [npu_node_name] - npu_node_data['data']['precision_index'] = precision_error + # 防止 KeyError 或 TypeError + npu_node_data.setdefault('data', {})['precision_index'] = precision_error # 后端维护一个匹配节点列表,前端展示 npu_match_nodes_list[npu_node_name] = bench_node_name bench_match_nodes_list[bench_node_name] = npu_node_name + graph_data['npu_match_nodes'] = npu_match_nodes_list graph_data['bench_match_nodes'] = bench_match_nodes_list return { @@ -84,8 +83,8 @@ class MatchNodesController: def process_summary_task_add(graph_data, npu_node_name, bench_node_name): npu_match_nodes_list = graph_data.get('npu_match_nodes', {}) bench_match_nodes_list = graph_data.get('bench_match_nodes', {}) - npu_node_data = graph_data.get('NPU', {}).get('node', {}).get(npu_node_name, {}) - bench_node_data = graph_data.get('Bench', {}).get('node', {}).get(bench_node_name, {}) + npu_node_data = graph_data.get('NPU', {}).get('node', {}).get(npu_node_name) + bench_node_data = graph_data.get('Bench', {}).get('node', {}).get(bench_node_name) # 计算统计误差 intput_statistical_diff = MatchNodesController.calculate_statistical_diff( npu_node_data.get('input_data'), bench_node_data.get('input_data'), npu_node_name, bench_node_name @@ -112,7 +111,8 @@ class MatchNodesController: bench_node_data['matched_node_link'] = [npu_node_name] MatchNodesController.update_graph_node_data(npu_node_data.get('input_data'), intput_statistical_diff) MatchNodesController.update_graph_node_data(npu_node_data.get('output_data'), output_statistical_diff) - npu_node_data['data']['precision_index'] = precision_error + # 防止 KeyError 或 TypeError + npu_node_data.setdefault('data', {})['precision_index'] = precision_error # 后端维护一个匹配节点列表,前端展示 npu_match_nodes_list[npu_node_name] = bench_node_name bench_match_nodes_list[bench_node_name] = npu_node_name @@ -141,7 +141,8 @@ class MatchNodesController: MatchNodesController.delete_matched_node_data(npu_node_data.get('output_data')) # 后端维护一个匹配节点列表,前端展示 try: - del npu_node_data['data']['precision_index'] + # 防止 KeyError 或 TypeError + npu_node_data.get('data', {}).pop('precision_index', None) del npu_match_nodes_list[npu_node_name] del bench_match_nodes_list[bench_node_name] except KeyError: @@ -222,6 +223,8 @@ class MatchNodesController: @staticmethod def calculate_md5_diff(npu_data, bench_data): + if npu_data == {} or bench_data == {}: + return 0 # 对比每个NPU和Bench所有数据md值,如果有一个不一样则返回0,否则返回1 for npu_key, bench_key in zip(npu_data, npu_data): npu_md5 = npu_data[npu_key].get('md5', '') diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py b/plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py index a45b29625ec..63780cde7b9 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py @@ -5,17 +5,24 @@ from pathlib import Path def load_st_test_cases(): - meta_path = Path(__file__).parent / "data/metadata_st.json" # 修改文件扩展名为 .json + meta_path = Path(__file__).parent / "data/metadata_st.json" with open(meta_path) as f: - return json.load(f)["test_cases"] # 使用 json.load 代替 yaml.safe_load + return json.load(f)["test_cases"] + + +def load_ut_test_cases(): + meta_path = Path(__file__).parent / "data/metadata_ut.json" + with open(meta_path) as f: + return json.load(f)["test_cases"] # 动态生成测试用例 def pytest_generate_tests(metafunc): + print("metafunc.fixturenames", metafunc.fixturenames) if "meta_data" in metafunc.fixturenames and "operation" in metafunc.fixturenames: - test_cases = load_st_test_cases() + ut_test_cases = load_st_test_cases() params = [] - for case in test_cases: + for case in ut_test_cases: metaData = case["meta_data"] metaData["run"] = Path(__file__).parent / metaData["run"] for op in case["operations"]: @@ -26,10 +33,20 @@ def pytest_generate_tests(metafunc): )) # 确保参数名称与参数值数量一致 metafunc.parametrize("meta_data, operation", params) + if "ut_test_case" in metafunc.fixturenames: + ut_test_cases = load_ut_test_cases() + params = [] + for case in ut_test_cases: + params.append(pytest.param( + case, + id=f"{case['type']}-{case['name']}" + )) + # 确保参数名称与参数值数量一致 + metafunc.parametrize("ut_test_case", params) @pytest.fixture -def graph_data(meta_data): +def meta_data(meta_data): # 返回当前测试的操作配置 return meta_data @@ -38,3 +55,9 @@ def graph_data(meta_data): def operation_config(operation): # 返回当前测试的操作配置 return operation + + +@pytest.fixture +def ut_test_case(ut_test_case): + # 返回当前测试的操作配置 + return ut_test_case diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata_ut.json b/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata_ut.json index e69de29bb2d..025fbd14c5f 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata_ut.json +++ b/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata_ut.json @@ -0,0 +1,174 @@ +{ + "test_cases": [ + { + "name": "md5_full_match_success", + "type": "process_md5_task_add", + "input": { + "graph_data": { + "NPU": { + "node": { + "npu_conv2d": { + "input_data": { + "npu_conv2d.data1": { + "md5": "a1b2c3" + }, + "npu_conv2d.data2": { + "md5": "d4e5f6" + } + }, + "output_data": { + "npu_conv2d.out1": { + "md5": "x7y8z9" + } + } + } + } + }, + "Bench": { + "node": { + "bench_conv2d": { + "input_data": { + "bench_conv2d.data1": { + "md5": "a1b2c3" + }, + "bench_conv2d.data2": { + "md5": "d4e5f6" + } + }, + "output_data": { + "bench_conv2d.out1": { + "md5": "x7y8z9" + } + } + } + } + } + }, + "npu_node_name": "npu_conv2d", + "bench_node_name": "bench_conv2d" + }, + "expected": { + "success": true, + "data": { + "precision_error": 1 + } + } + }, + { + "name": "md5_partial_mismatch_failure", + "type": "process_md5_task_add", + "input": { + "graph_data": { + "NPU": { + "node": { + "npu_conv2d": { + "input_data": { + "npu_conv2d.data1": { + "md5": "a1b2c3" + }, + "npu_conv2d.data2": { + "md5": "xxxxxx" + } + } + } + } + }, + "Bench": { + "node": { + "bench_conv2d": { + "input_data": { + "bench_conv2d.data1": { + "md5": "a1b2c3" + }, + "bench_conv2d.data2": { + "md5": "d4e5f6" + } + } + } + } + } + }, + "npu_node_name": "npu_conv2d", + "bench_node_name": "bench_conv2d" + }, + "expected": { + "success": true, + "data": { + "precision_error": 0 + } + } + }, + { + "name": "delete_existing_node_success", + "type": "process_md5_task_delete", + "input": { + "graph_data": { + "npu_match_nodes": { + "npu_conv2d": "bench_conv2d" + }, + "bench_match_nodes": { + "bench_conv2d": "npu_conv2d" + }, + "NPU": { + "node": { + "npu_conv2d": { + "data": { + "precision_index": 1 + }, + "matched_node_link": [ + "bench_conv2d" + ] + } + } + } + }, + "npu_node_name": "npu_conv2d", + "bench_node_name": "bench_conv2d" + }, + "expected": { + "success": true, + "data": {} + } + }, + { + "name": "delete_non_existent_node_failure", + "type": "process_md5_task_delete", + "input": { + "graph_data": { + "NPU": { + "node": { + "npu_conv2d": {} + } + } + }, + "npu_node_name": "npu_conv2d", + "bench_node_name": "bench_conv2d" + }, + "expected": { + "success": false, + "error": "操作失败:删除节点信息失败" + } + }, + { + "name": "missing_input_data_handling", + "type": "process_md5_task_add", + "input": { + "graph_data": { + "NPU": { + "node": { + "npu_conv2d": {} + } + } + }, + "npu_node_name": "npu_conv2d", + "bench_node_name": "bench_conv2d" + }, + "expected": { + "success": true, + "data": { + "precision_error": 0 + } + } + } + ] +} \ No newline at end of file diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/integration/service/test_graph_service.py b/plugins/tensorboard-plugins/tb_graph_ascend/tests/integration/service/test_graph_service.py index 6a649e2fd08..35e3883ac5c 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/tests/integration/service/test_graph_service.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/tests/integration/service/test_graph_service.py @@ -1,13 +1,8 @@ import pytest from server.app.service.graph_service import GraphService -from server.app.utils.graph_utils import GraphUtils class TestMatchNodesService: - - @pytest.fixture(autouse=True) - def setup_manager(self, meta_data): - self.graph_data = GraphUtils.get_graph_data(meta_data) def test_service(self, meta_data, operation_config): op_type = operation_config["type"] diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/units/controllers/test_match_nodes_controller.py b/plugins/tensorboard-plugins/tb_graph_ascend/tests/units/controllers/test_match_nodes_controller.py index 1a5393e08bb..6d23348b3cc 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/tests/units/controllers/test_match_nodes_controller.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/tests/units/controllers/test_match_nodes_controller.py @@ -4,8 +4,70 @@ from server.app.utils.graph_utils import GraphUtils class TestMatchNodesController: - - @pytest.fixture(autouse=True) - def setup_manager(self, graph_data): - self.graph_data = GraphUtils.get_graph_data(graph_data) - + + def test_match_node_controller(self, ut_test_case): + op_type = ut_test_case.get("type") + input = ut_test_case.get('input') + expected = ut_test_case.get("expected") + print('input: ===========', input) + # 执行操作 + try: + if op_type == "process_md5_task_add": + result = MatchNodesController.process_md5_task_add( + graph_data=input.get("graph_data"), + npu_node_name=input.get("npu_node_name"), + bench_node_name=input.get("bench_node_name"), + ) + elif op_type == "process_md5_task_delete": + result = MatchNodesController.process_md5_task_delete( + graph_data=input.get("graph_data"), + npu_node_name=input.get("npu_node_name"), + bench_node_name=input.get("bench_node_name"), + ) + elif op_type == "process_summary_task_add": + + result = MatchNodesController.process_summary_task_add( + graph_data=input.get("graph_data"), + npu_node_name=input.get("npu_node_name"), + bench_node_name=input.get("bench_node_name"), + ) + elif op_type == "process_summary_task_delete": + result = MatchNodesController.process_summary_task_delete( + npu_data=input.get("npu_data"), + bench_data=input.get("bench_data"), + npu_node_name=input.get("npu_node_name"), + bench_node_name=input.get("bench_node_name"), + ) + elif op_type == "calculate_statistical_diff": + result = MatchNodesController.calculate_statistical_diff( + npu_data=input.get("npu_data"), + bench_data=input.get("bench_data"), + npu_node_name=input.get("npu_node_name"), + bench_node_name=input.get("bench_node_name"), + ) + elif op_type == "calculate_max_relative_error": + result = MatchNodesController.calculate_max_relative_error( + result=input.get("result"), + ) + elif op_type == "calculate_md5_diff": + result = MatchNodesController.calculate_md5_diff( + npu_data=input.get("npu_data"), + bench_data=input.get("bench_data"), + ) + elif op_type == "update_graph_node_data": + result = MatchNodesController.update_graph_node_data( + graph_npu_node_data=input.get("graph_npu_node_data"), + statistical_diff=input.get("statistical_diff"), + ) + elif op_type == "delete_matched_node_data": + result = MatchNodesController.delete_matched_node_data( + graph_npu_node_data=input.get("graph_npu_node_data"), + ) + else: + return + except Exception as e: + result = {"error": type(e).__name__} + + # 验证结果 + assert result == expected, \ + f"Operation {op_type} failed on {ut_test_case}" -- Gitee From 24985980e2967675c94274d04d0c920d91337808 Mon Sep 17 00:00:00 2001 From: sunchao <1299792067@qq.com> Date: Tue, 1 Apr 2025 21:00:55 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E2=9C=A8=20feat:=20=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fe/src/main_graph/index.ts | 256 ++++++++++++++++++ .../fe/src/main_graph/useGraph.ts | 7 + .../fe/src/tf_graph/tf-graph-scene.ts | 1 + .../fe/src/tf_graph/tf-graph.ts | 16 +- .../tb_graph_ascend/server/plugin.py | 3 +- 5 files changed, 267 insertions(+), 16 deletions(-) create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/fe/src/main_graph/index.ts create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/fe/src/main_graph/useGraph.ts diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/main_graph/index.ts b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/main_graph/index.ts new file mode 100644 index 00000000000..8ee75f2aa0e --- /dev/null +++ b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/main_graph/index.ts @@ -0,0 +1,256 @@ +/* Copyright (c) 2025, Huawei Technologies. + * 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 { PolymerElement, html } from '@polymer/polymer'; +import { customElement, property, query } from '@polymer/decorators'; +import '@vaadin/grid'; // 引入新的 Vaadin Grid 组件 +import '@vaadin/tooltip'; +import * as d3 from 'd3'; + + +export enum NodeType { + MODULE = 0, + OPERATOR = 1, + MULTI_COLLECTION = 8, + API_LIST = 9, +} + +@customElement('main-graph') +class MainGraph extends PolymerElement { + + static readonly template = html` + + + + `; + + @property({ type: Array }) + data = [ + { + name: 'AddThree_0', + width: 316, + height: 124, + color: 'rgb(255, 237, 190)', + x: 138, + y: 0, + nodeType: 0, + flod: false + }, + { + name: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.tt.ee', + width: 300, + height: 15, + color: 'rgb(199, 199, 199)', + x: 150, + y: 74.5, + nodeType: 0, + flod: true + }, + { + name: 'maxpoolMaxPool2.maxpoolpo.tt.ee', + width: 168, + height: 15, + color: 'rgb(182, 199, 252', + x: 200, + y: 49.5, + nodeType: 0, + flod: true + }, + { + name: 'arg0_1_0', + width: 40, + height: 12, + color: 'rgb(199, 199, 199)', + x: 260, + y: 26, + nodeType: 0, + flod: true + }, + { + name: 'output_0', + width: 40, + height: 12, + color: 'rgb(199, 199, 199)', + x: 260, + y: 98, + nodeType: 0, + flod: true + } + ]; + + override ready(): void { + super.ready(); + this.renderDiagram(this.data); + } + + renderDiagram(data) { + if (!this.shadowRoot) return; + const svg = d3.select(this.shadowRoot.querySelector('#graph')); + // 绑定数据到 g 元素 + const groups = svg.selectAll('g').data(data, (d: any) => d.name); + + // 更新现有矩形和形状(带动画) + groups.each(function (d: any) { + const nodeElement = d3.select(this); + + // 更新矩形的属性 + nodeElement.selectAll('rect') + .transition() + .duration(500) // 动画持续时间 + .attr('x', d.x) + .attr('y', d.y) + .attr('width', d.width) + .attr('height', d.type === NodeType.MODULE && !d.flod ? d.height : 15) + .attr('fill', d.color) + .attr('stroke', d.color) + .attr('stroke-width', 1); + + // 更新文本位置 + nodeElement.selectAll('text') + .transition() + .duration(500) + .attr('x', d.x + d.width / 2) + .attr('y', d.y + (d.type === NodeType.MODULE ? d.height / 2 : 8)); + }); + + // 添加新矩形和形状 + const newGroups = groups.enter() + .append('g') + .attr('name', (d: any) => d.name); + + newGroups.each(function (d: any) { + const nodeElement = d3.select(this); + if (d.nodeType === NodeType.MODULE) { + if (!d.flod) { + nodeElement.append('rect') + .attr('x', d.x) + .attr('y', d.y) + .attr('width', 0) // 初始宽度为 0,用于动画 + .attr('height', 0) // 初始高度为 0,用于动画 + .attr('rx', '5') + .attr('ry', '5') + .attr('fill', 'white') + .attr('stroke', d.color) + .attr('stroke-width', 1) + .transition() + .duration(500) + .attr('width', d.width) + .attr('height', d.height); + } + nodeElement.append('rect') + .attr('x', d.x) + .attr('y', d.y + 1) + .attr('rx', '5') + .attr('ry', '5') + .attr('width', 0) // 初始宽度为 0,用于动画 + .attr('height', 0) // 初始高度为 0,用于动画 + .attr('fill', d.color) + .attr('stroke', d.color) + .attr('stroke-width', 1) + .transition() + .duration(500) + .attr('width', d.width) + .attr('height', 15); + + nodeElement.append('text') + .attr('x', d.x + d.width / 2) + .attr('y', d.y + 8) + .attr('dy', '0.35em') + .attr('text-anchor', 'middle') + .style('opacity', 0) // 初始透明度为 0 + .text(d.name) + .transition() // 添加动画 + .duration(1000) // 动画持续时间 + .style('opacity', 1); // 目标透明度为 1 + } + // 可以根据需要添加其他类型的节点(如 OPERATOR、API_LIST 等) + }); + + // 删除多余的矩形和形状(带动画) + groups.exit() + .selectAll('rect') + .transition() + .duration(500) + .attr('height', 0) // 高度逐渐变为 0 + .remove(); + + groups.exit() + .selectAll('text') + .transition() + .duration(500) + .style('opacity', 0) // 文本透明度逐渐变为 0 + .remove(); + + groups.exit() + .transition() + .duration(500) + .remove(); + } + + updateData() { + // 随机生成新的数据 + // 模拟数据变化:随机更新高度 + this.data = this.generateData(10); + console.log(this.data); + this.renderDiagram(this.data); + } + + generateData(count) { + const data: any = []; + const colors = ['red', 'blue', 'green', 'orange', 'purple']; // 颜色选项 + + for (let i = 0; i < count; i++) { + const name = `Item_${i}`; // 生成唯一的名称 + const width = Math.floor(Math.random() * 300 + 50); // 宽度范围:50 ~ 350 + const height = Math.floor(Math.random() * 100 + 10); // 高度范围:10 ~ 110 + const color = colors[Math.floor(Math.random() * colors.length)]; // 随机颜色 + const x = Math.floor(Math.random() * 500); // x 范围:0 ~ 500 + const y = Math.floor(Math.random() * 500); // y 范围:0 ~ 500 + + data.push({ + name, + width, + height, + color, + x, + y, + }); + } + + return data; + } +} diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/main_graph/useGraph.ts b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/main_graph/useGraph.ts new file mode 100644 index 00000000000..878d3b3ec8a --- /dev/null +++ b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/main_graph/useGraph.ts @@ -0,0 +1,7 @@ +const useMatched = () => { + + const add + return { + + }; +} \ No newline at end of file diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/tf_graph/tf-graph-scene.ts b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/tf_graph/tf-graph-scene.ts index 867fa2f797b..10199c47b17 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/tf_graph/tf-graph-scene.ts +++ b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/tf_graph/tf-graph-scene.ts @@ -303,6 +303,7 @@ class TfGraphScene2 extends LegacyElementMixin(DarkModeMixin(PolymerElement)) im }, tb_debug.GraphDebugEventId.RENDER_SCENE_BUILD_SCENE, ); + console.log('tf-graph-scene: built scene====', renderHierarchy); // Update the minimap again when the graph is done animating. setTimeout((): void => { this.minimap.update(); diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/tf_graph/tf-graph.ts b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/tf_graph/tf-graph.ts index f4eac6ec2eb..8776f5fe856 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/tf_graph/tf-graph.ts +++ b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/tf_graph/tf-graph.ts @@ -30,6 +30,7 @@ import * as tf_graph_scene from '../tf_graph_common/scene'; import * as tf_graph_util from '../tf_graph_common/util'; import * as tf_graph_layout from '../tf_graph_common/layout'; import './tf-graph-scene'; +import '../main_graph/index' import './components/legend/index'; import { Selection } from '../tf_graph_controls/tf-graph-controls'; import { fetchPbTxt, parseGraphPbTxt } from '../tf_graph_common/parser'; @@ -105,20 +106,7 @@ class TfGraph extends LegacyElementMixin(PolymerElement) { diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/server/plugin.py b/plugins/tensorboard-plugins/tb_graph_ascend/server/plugin.py index 5728e894355..b43b4a704f2 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/server/plugin.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/server/plugin.py @@ -353,10 +353,9 @@ class GraphsPlugin(base_plugin.TBPlugin): request, f"Failed to check file '{tag}', view the log for detail.", "text/plain", 400 ) self._current_file_data = json_data - if 'ALL' not in json_data.get('StepList', {}): + if json_data.get('StepList', {}) and 'ALL' not in json_data.get('StepList', {}): json_data['StepList'].insert(0, 'ALL') all_node_names = self.get_all_node_names(json_data, request) - # 读取第一个文件中的Colors和OverflowCheck first_run_tag = get_global_value("first_run_tag") first_file_data, _ = GraphUtils.safe_load_data(run, first_run_tag) -- Gitee From e2d0ab3a9d8f4a28024c18c9712b6444d98c2fc3 Mon Sep 17 00:00:00 2001 From: sunchao <1299792067@qq.com> Date: Fri, 18 Apr 2025 09:25:02 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E2=9C=A8=20feat:=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=97=A0=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fe/src/main_graph/index.ts | 256 ------------------ .../fe/src/main_graph/useGraph.ts | 7 - 2 files changed, 263 deletions(-) delete mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/fe/src/main_graph/index.ts delete mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/fe/src/main_graph/useGraph.ts diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/main_graph/index.ts b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/main_graph/index.ts deleted file mode 100644 index 8ee75f2aa0e..00000000000 --- a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/main_graph/index.ts +++ /dev/null @@ -1,256 +0,0 @@ -/* Copyright (c) 2025, Huawei Technologies. - * 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 { PolymerElement, html } from '@polymer/polymer'; -import { customElement, property, query } from '@polymer/decorators'; -import '@vaadin/grid'; // 引入新的 Vaadin Grid 组件 -import '@vaadin/tooltip'; -import * as d3 from 'd3'; - - -export enum NodeType { - MODULE = 0, - OPERATOR = 1, - MULTI_COLLECTION = 8, - API_LIST = 9, -} - -@customElement('main-graph') -class MainGraph extends PolymerElement { - - static readonly template = html` - - - - `; - - @property({ type: Array }) - data = [ - { - name: 'AddThree_0', - width: 316, - height: 124, - color: 'rgb(255, 237, 190)', - x: 138, - y: 0, - nodeType: 0, - flod: false - }, - { - name: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.tt.ee', - width: 300, - height: 15, - color: 'rgb(199, 199, 199)', - x: 150, - y: 74.5, - nodeType: 0, - flod: true - }, - { - name: 'maxpoolMaxPool2.maxpoolpo.tt.ee', - width: 168, - height: 15, - color: 'rgb(182, 199, 252', - x: 200, - y: 49.5, - nodeType: 0, - flod: true - }, - { - name: 'arg0_1_0', - width: 40, - height: 12, - color: 'rgb(199, 199, 199)', - x: 260, - y: 26, - nodeType: 0, - flod: true - }, - { - name: 'output_0', - width: 40, - height: 12, - color: 'rgb(199, 199, 199)', - x: 260, - y: 98, - nodeType: 0, - flod: true - } - ]; - - override ready(): void { - super.ready(); - this.renderDiagram(this.data); - } - - renderDiagram(data) { - if (!this.shadowRoot) return; - const svg = d3.select(this.shadowRoot.querySelector('#graph')); - // 绑定数据到 g 元素 - const groups = svg.selectAll('g').data(data, (d: any) => d.name); - - // 更新现有矩形和形状(带动画) - groups.each(function (d: any) { - const nodeElement = d3.select(this); - - // 更新矩形的属性 - nodeElement.selectAll('rect') - .transition() - .duration(500) // 动画持续时间 - .attr('x', d.x) - .attr('y', d.y) - .attr('width', d.width) - .attr('height', d.type === NodeType.MODULE && !d.flod ? d.height : 15) - .attr('fill', d.color) - .attr('stroke', d.color) - .attr('stroke-width', 1); - - // 更新文本位置 - nodeElement.selectAll('text') - .transition() - .duration(500) - .attr('x', d.x + d.width / 2) - .attr('y', d.y + (d.type === NodeType.MODULE ? d.height / 2 : 8)); - }); - - // 添加新矩形和形状 - const newGroups = groups.enter() - .append('g') - .attr('name', (d: any) => d.name); - - newGroups.each(function (d: any) { - const nodeElement = d3.select(this); - if (d.nodeType === NodeType.MODULE) { - if (!d.flod) { - nodeElement.append('rect') - .attr('x', d.x) - .attr('y', d.y) - .attr('width', 0) // 初始宽度为 0,用于动画 - .attr('height', 0) // 初始高度为 0,用于动画 - .attr('rx', '5') - .attr('ry', '5') - .attr('fill', 'white') - .attr('stroke', d.color) - .attr('stroke-width', 1) - .transition() - .duration(500) - .attr('width', d.width) - .attr('height', d.height); - } - nodeElement.append('rect') - .attr('x', d.x) - .attr('y', d.y + 1) - .attr('rx', '5') - .attr('ry', '5') - .attr('width', 0) // 初始宽度为 0,用于动画 - .attr('height', 0) // 初始高度为 0,用于动画 - .attr('fill', d.color) - .attr('stroke', d.color) - .attr('stroke-width', 1) - .transition() - .duration(500) - .attr('width', d.width) - .attr('height', 15); - - nodeElement.append('text') - .attr('x', d.x + d.width / 2) - .attr('y', d.y + 8) - .attr('dy', '0.35em') - .attr('text-anchor', 'middle') - .style('opacity', 0) // 初始透明度为 0 - .text(d.name) - .transition() // 添加动画 - .duration(1000) // 动画持续时间 - .style('opacity', 1); // 目标透明度为 1 - } - // 可以根据需要添加其他类型的节点(如 OPERATOR、API_LIST 等) - }); - - // 删除多余的矩形和形状(带动画) - groups.exit() - .selectAll('rect') - .transition() - .duration(500) - .attr('height', 0) // 高度逐渐变为 0 - .remove(); - - groups.exit() - .selectAll('text') - .transition() - .duration(500) - .style('opacity', 0) // 文本透明度逐渐变为 0 - .remove(); - - groups.exit() - .transition() - .duration(500) - .remove(); - } - - updateData() { - // 随机生成新的数据 - // 模拟数据变化:随机更新高度 - this.data = this.generateData(10); - console.log(this.data); - this.renderDiagram(this.data); - } - - generateData(count) { - const data: any = []; - const colors = ['red', 'blue', 'green', 'orange', 'purple']; // 颜色选项 - - for (let i = 0; i < count; i++) { - const name = `Item_${i}`; // 生成唯一的名称 - const width = Math.floor(Math.random() * 300 + 50); // 宽度范围:50 ~ 350 - const height = Math.floor(Math.random() * 100 + 10); // 高度范围:10 ~ 110 - const color = colors[Math.floor(Math.random() * colors.length)]; // 随机颜色 - const x = Math.floor(Math.random() * 500); // x 范围:0 ~ 500 - const y = Math.floor(Math.random() * 500); // y 范围:0 ~ 500 - - data.push({ - name, - width, - height, - color, - x, - y, - }); - } - - return data; - } -} diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/main_graph/useGraph.ts b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/main_graph/useGraph.ts deleted file mode 100644 index 878d3b3ec8a..00000000000 --- a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/main_graph/useGraph.ts +++ /dev/null @@ -1,7 +0,0 @@ -const useMatched = () => { - - const add - return { - - }; -} \ No newline at end of file -- Gitee From 3e73ef455ceaa80bba957f2bb42d8841e3b88409 Mon Sep 17 00:00:00 2001 From: sunchao <1299792067@qq.com> Date: Fri, 18 Apr 2025 09:26:28 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E2=9C=A8=20feat:=20=E9=87=8D=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E6=B5=8B=E8=AF=95=E6=96=87=E4=BB=B6=E5=A4=B9=E4=B8=BA?= =?UTF-8?q?test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tb_graph_ascend/{tests => test}/conftest.py | 0 .../tb_graph_ascend/{tests => test}/data/compare_statis.vis | 0 .../tb_graph_ascend/{tests => test}/data/metadata_st.json | 0 .../tb_graph_ascend/{tests => test}/data/metadata_ut.json | 0 .../{tests => test}/integration/service/test_graph_service.py | 0 .../tb_graph_ascend/{tests => test}/pytest.ini | 0 .../units/controllers/test_match_nodes_controller.py | 0 .../tb_graph_ascend/{tests => test}/units/test_plugin.py | 0 .../{tests => test}/units/utils/test_graph_utils.py | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename plugins/tensorboard-plugins/tb_graph_ascend/{tests => test}/conftest.py (100%) rename plugins/tensorboard-plugins/tb_graph_ascend/{tests => test}/data/compare_statis.vis (100%) rename plugins/tensorboard-plugins/tb_graph_ascend/{tests => test}/data/metadata_st.json (100%) rename plugins/tensorboard-plugins/tb_graph_ascend/{tests => test}/data/metadata_ut.json (100%) rename plugins/tensorboard-plugins/tb_graph_ascend/{tests => test}/integration/service/test_graph_service.py (100%) rename plugins/tensorboard-plugins/tb_graph_ascend/{tests => test}/pytest.ini (100%) rename plugins/tensorboard-plugins/tb_graph_ascend/{tests => test}/units/controllers/test_match_nodes_controller.py (100%) rename plugins/tensorboard-plugins/tb_graph_ascend/{tests => test}/units/test_plugin.py (100%) rename plugins/tensorboard-plugins/tb_graph_ascend/{tests => test}/units/utils/test_graph_utils.py (100%) diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py b/plugins/tensorboard-plugins/tb_graph_ascend/test/conftest.py similarity index 100% rename from plugins/tensorboard-plugins/tb_graph_ascend/tests/conftest.py rename to plugins/tensorboard-plugins/tb_graph_ascend/test/conftest.py diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/compare_statis.vis b/plugins/tensorboard-plugins/tb_graph_ascend/test/data/compare_statis.vis similarity index 100% rename from plugins/tensorboard-plugins/tb_graph_ascend/tests/data/compare_statis.vis rename to plugins/tensorboard-plugins/tb_graph_ascend/test/data/compare_statis.vis diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata_st.json b/plugins/tensorboard-plugins/tb_graph_ascend/test/data/metadata_st.json similarity index 100% rename from plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata_st.json rename to plugins/tensorboard-plugins/tb_graph_ascend/test/data/metadata_st.json diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata_ut.json b/plugins/tensorboard-plugins/tb_graph_ascend/test/data/metadata_ut.json similarity index 100% rename from plugins/tensorboard-plugins/tb_graph_ascend/tests/data/metadata_ut.json rename to plugins/tensorboard-plugins/tb_graph_ascend/test/data/metadata_ut.json diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/integration/service/test_graph_service.py b/plugins/tensorboard-plugins/tb_graph_ascend/test/integration/service/test_graph_service.py similarity index 100% rename from plugins/tensorboard-plugins/tb_graph_ascend/tests/integration/service/test_graph_service.py rename to plugins/tensorboard-plugins/tb_graph_ascend/test/integration/service/test_graph_service.py diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/pytest.ini b/plugins/tensorboard-plugins/tb_graph_ascend/test/pytest.ini similarity index 100% rename from plugins/tensorboard-plugins/tb_graph_ascend/tests/pytest.ini rename to plugins/tensorboard-plugins/tb_graph_ascend/test/pytest.ini diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/units/controllers/test_match_nodes_controller.py b/plugins/tensorboard-plugins/tb_graph_ascend/test/units/controllers/test_match_nodes_controller.py similarity index 100% rename from plugins/tensorboard-plugins/tb_graph_ascend/tests/units/controllers/test_match_nodes_controller.py rename to plugins/tensorboard-plugins/tb_graph_ascend/test/units/controllers/test_match_nodes_controller.py diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/units/test_plugin.py b/plugins/tensorboard-plugins/tb_graph_ascend/test/units/test_plugin.py similarity index 100% rename from plugins/tensorboard-plugins/tb_graph_ascend/tests/units/test_plugin.py rename to plugins/tensorboard-plugins/tb_graph_ascend/test/units/test_plugin.py diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/tests/units/utils/test_graph_utils.py b/plugins/tensorboard-plugins/tb_graph_ascend/test/units/utils/test_graph_utils.py similarity index 100% rename from plugins/tensorboard-plugins/tb_graph_ascend/tests/units/utils/test_graph_utils.py rename to plugins/tensorboard-plugins/tb_graph_ascend/test/units/utils/test_graph_utils.py -- Gitee From 7b8be601d400a71cbbed169000e14b8c61b91a7c Mon Sep 17 00:00:00 2001 From: sunchao <1299792067@qq.com> Date: Fri, 18 Apr 2025 09:30:41 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E2=9C=A8=20feat:=20=E5=88=A0=E9=99=A4pri?= =?UTF-8?q?nt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/tensorboard-plugins/tb_graph_ascend/test/conftest.py | 1 - .../test/units/controllers/test_match_nodes_controller.py | 1 - 2 files changed, 2 deletions(-) diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/test/conftest.py b/plugins/tensorboard-plugins/tb_graph_ascend/test/conftest.py index 63780cde7b9..894f9ce6624 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/test/conftest.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/test/conftest.py @@ -18,7 +18,6 @@ def load_ut_test_cases(): # 动态生成测试用例 def pytest_generate_tests(metafunc): - print("metafunc.fixturenames", metafunc.fixturenames) if "meta_data" in metafunc.fixturenames and "operation" in metafunc.fixturenames: ut_test_cases = load_st_test_cases() params = [] diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/test/units/controllers/test_match_nodes_controller.py b/plugins/tensorboard-plugins/tb_graph_ascend/test/units/controllers/test_match_nodes_controller.py index 6d23348b3cc..f0ac568d821 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/test/units/controllers/test_match_nodes_controller.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/test/units/controllers/test_match_nodes_controller.py @@ -9,7 +9,6 @@ class TestMatchNodesController: op_type = ut_test_case.get("type") input = ut_test_case.get('input') expected = ut_test_case.get("expected") - print('input: ===========', input) # 执行操作 try: if op_type == "process_md5_task_add": -- Gitee From d609aff7a309758ac6b886600aa0362ad1c1d8f3 Mon Sep 17 00:00:00 2001 From: sunchao <1299792067@qq.com> Date: Fri, 18 Apr 2025 09:47:49 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E2=9C=A8=20feat:=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/data/compare_statis.vis | 948 ------------------ 1 file changed, 948 deletions(-) delete mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/test/data/compare_statis.vis diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/test/data/compare_statis.vis b/plugins/tensorboard-plugins/tb_graph_ascend/test/data/compare_statis.vis deleted file mode 100644 index 5820af6ac01..00000000000 --- a/plugins/tensorboard-plugins/tb_graph_ascend/test/data/compare_statis.vis +++ /dev/null @@ -1,948 +0,0 @@ -{ - "ToolTip": "{\"shape\": \"\\u6570\"}", - "NPU": { - "edge": [], - "node": { - "AddOne_0": { - "matched_node_link": [ - "AddOne_0" - ], - "data": { - "precision_index": 0.0 - }, - "id": "AddOne_0", - "inputs": [], - "input_data": { - "AddOne_0.input_arg.0": { - "type": "torch.Tensor", - "dtype": "", - "shape": [ - 32, - 512, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406", - "MaxAbsErr": 0.0, - "MinAbsErr": 0.0, - "MeanAbsErr": 0.0, - "NormAbsErr": 0.0, - "MaxRelativeErr": "0.0000%", - "MinRelativeErr": "0.0000%", - "MeanRelativeErr": "0.0000%", - "NormRelativeErr": "0.0000%" - }, - "AddOne_0.input_arg.1": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 64, - 256, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406", - "MaxAbsErr": 0.0, - "MinAbsErr": 0.0, - "MeanAbsErr": 0.0, - "NormAbsErr": 0.0, - "MaxRelativeErr": "0.0000%", - "MinRelativeErr": "0.0000%", - "MeanRelativeErr": "0.0000%", - "NormRelativeErr": "0.0000%" - }, - "AddOne_0.1": {}, - "AddOne_0.2": {} - }, - "output_data": { - "AddOne_0.output_arg.0": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 32, - 512, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406", - "MaxAbsErr": 0.0, - "MinAbsErr": 0.0, - "MeanAbsErr": 0.0, - "NormAbsErr": 0.0, - "MaxRelativeErr": "0.0000%", - "MinRelativeErr": "0.0000%", - "MeanRelativeErr": "0.0000%", - "NormRelativeErr": "0.0000%" - }, - "AddOne_0.output_arg.1": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 64, - 256, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406", - "MaxAbsErr": 0.0, - "MinAbsErr": 0.0, - "MeanAbsErr": 0.0, - "NormAbsErr": 0.0, - "MaxRelativeErr": "0.0000%", - "MinRelativeErr": "0.0000%", - "MeanRelativeErr": "0.0000%", - "NormRelativeErr": "0.0000%" - }, - "AddOne_0.1": {}, - "AddOne_0.2": {} - }, - "is_forward": true, - "node_type": 0, - "outputs": [], - "pair": "None", - "subnodes": [ - "Test.add_0_withlonglonglonglonglonglonglonglongname.tt.ee", - "add_51111" - ], - "type": "AddOne", - "upnode": "Test.maxpoolMaxPool2.maxpoolpo.tt.ee" - }, - "AddOne_1": { - "matched_node_link": [], - "data": { - "precision_index": 0.8 - }, - "id": "AddOne_1", - "inputs": [], - "input_data": { - "Test.maxpoolMaxPool2.maxpoolpo.tt.ee.input_arg.0": { - "data_name": "-10", - "longlonglonglonglonglongName": "hah", - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": "[32, 512, 2, 2]", - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406", - "error_key": [ - "type", - "shape" - ] - }, - "Test.maxpoolMaxPool2.maxpoolpo.tt.ee.kwrag_arg.1": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 64, - 256, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406" - } - }, - "is_forward": true, - "node_type": 9, - "outputs": [], - "output_data": {}, - "pair": "None", - "subnodes": [ - "add_1", - "add_4" - ], - "type": "AddOne", - "upnode": "Test.maxpoolMaxPool2.maxpoolpo.tt.ee" - }, - "Test.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.tt.ee": { - "matched_node_link": [], - "data": { - "precision_index": 0 - }, - "id": "Test.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.tt.ee", - "inputs": [], - "is_forward": true, - "node_type": 0, - "outputs": [], - "output_data": {}, - "pair": "None", - "subnodes": [ - "add_2" - ], - "type": "AddOne", - "upnode": "AddThree_0", - "micro_step_id": "3" - }, - "AddThree_0": { - "matched_node_link": [ - "B___AddThree_0" - ], - "data": { - "precision_index": 0.5 - }, - "id": "AddThree_0", - "input_data": {}, - "is_forward": true, - "node_type": 0, - "outputs": [], - "output_data": {}, - "pair": "None", - "subnodes": [ - "arg0_1_0", - "Test.maxpoolMaxPool2.maxpoolpo.tt.ee", - "Test.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.tt.ee", - "output_0" - ], - "type": "AddThree", - "upnode": "None" - }, - "Test.maxpoolMaxPool2.maxpoolpo.tt.ee": { - "matched_node_link": [ - "B___Test.maxpoolMaxPool2.maxpoolpo.tt.ee" - ], - "data": { - "precision_status": false, - "Host Self Duration(us)": 56.24, - "Host Total Duration(us)": 56.24, - "Device Self Duration(us)": 0, - "Device Total Duration(us)": 0, - "overflow_level": "medium" - }, - "id": "Test.maxpoolMaxPool2.maxpoolpo.tt.ee", - "inputs": [], - "input_data": { - "Test.maxpoolMaxPool2.maxpoolpo.tt.ee.input_arg.0": { - "data_name": "-10", - "longlonglonglonglonglongName": "hah", - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": "[32, 512, 2, 2]", - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406", - "error_key": [ - "type", - "shape" - ] - }, - "Test.maxpoolMaxPool2.maxpoolpo.tt.ee.kwrag_arg.1": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 64, - 256, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406" - } - }, - "is_forward": true, - "node_type": 0, - "outputs": [], - "output_data": { - "output.0": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 128, - 512, - 2, - 2 - ], - "Max": "538.2343242", - "Min": "-234.124124234", - "Mean": "-510.23432654", - "Norm": "3555.3406" - }, - "output.1": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 16, - 256, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406" - } - }, - "pair": "None", - "subnodes": [ - "AddOne_0", - "AddOne_1" - ], - "suggestions": { - "text": "test ptdbg工具 with longlong tenm tensldjta te alsejtka gaew jtljae tet jsdklfj.", - "ptdbg工具": "https://gitee.com/ascend/att/tree/master/debug/accuracy_tools/ptdbg_ascend" - }, - "stack_info": [ - "File /home/w3000/xxxx/subnodes/sdd/adad/srit-sda/artar/prased, line 136. om het, \n dada = rtens/sda.ddd(asdw)", - "File /home/w3000/xxxx/subnodes/sdd/adad/srit-sda/artar/prased, line 136. om het, \n dada = rtens/sda.ddd(asdw)", - "File /home/w3000/xxxx/subnodes/sdd/adad/srit-sda/artar/prased, line 136. om het, \n dada = rtens/sda.ddd(asdw)" - ], - "type": "AddTwo", - "upnode": "AddThree_0", - "micro_step_id": "0" - }, - "Test.add_0_withlonglonglonglonglonglonglonglongname.tt.ee": { - "matched_node_link": [ - "B___AddThree_0", - "B___Test.maxpoolMaxPool2.maxpoolpo.tt.ee", - "B___AddOne_0", - "B___Test.add_0_withlonglonglonglonglonglonglonglongname.tt.ee" - ], - "data": { - "precision_index": 0.35 - }, - "id": "Test.add_0_withlonglonglonglonglonglonglonglongname.tt.ee", - "inputs": [], - "input_data": { - "input_arg.0": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 32, - 512, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406" - }, - "input_arg.1": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 64, - 256, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406" - }, - "input_arg.2": "None" - }, - "is_forward": true, - "node_type": 0, - "outputs": [], - "output_data": { - "output.0": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 128, - 512, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406" - }, - "output.1": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 16, - 256, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406" - } - }, - "pair": "None", - "subnodes": [], - "type": "addlongtingmelasidngkonklajelkjsakljgskadtest", - "upnode": "AddOne_0" - }, - "add_51111": { - "matched_node_link": [], - "data": { - "precision_status": true, - "precision_index": 1, - "md5 Compare Result": "Pass" - }, - "id": "add_51111", - "inputs": [], - "input_data": {}, - "is_forward": true, - "node_type": 0, - "outputs": [], - "output_data": {}, - "pair": "None", - "subnodes": [], - "type": "add", - "upnode": "AddOne_0" - }, - "add_1": { - "matched_node_link": [], - "data": { - "precision_status": false, - "precision_index": 0, - "md5 Compare Result": "Pass" - }, - "id": "add_1", - "inputs": [], - "input_data": {}, - "is_forward": true, - "node_type": 0, - "outputs": [], - "output_data": {}, - "pair": "None", - "subnodes": [], - "type": "add", - "upnode": "AddOne_1" - }, - "add_4": { - "matched_node_link": [], - "data": {}, - "id": "add_4", - "inputs": [], - "input_data": {}, - "is_forward": true, - "node_type": 0, - "outputs": [], - "output_data": {}, - "pair": "None", - "subnodes": [], - "type": "add", - "upnode": "AddOne_1" - }, - "add_2": { - "matched_node_link": [], - "data": {}, - "id": "add_2", - "inputs": [], - "input_data": { - "add_2.input_arg.0": { - "longlonglonglonglonglongName": "hah", - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": "[32, 512, 2, 2]", - "Max": "6408.2343242", - "Min": "-3134.124124234", - "Mean": "-501.23432654", - "Norm": "3555.3406", - "error_key": [ - "type", - "shape" - ] - }, - "add_2.kwrag_arg.1": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 64, - 256, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406" - } - }, - "is_forward": true, - "node_type": 0, - "outputs": [], - "output_data": {}, - "pair": "None", - "subnodes": [], - "type": "add", - "upnode": "Test.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.tt.ee" - }, - "arg0_1_0": { - "matched_node_link": [], - "data": {}, - "id": "arg0_1_0", - "inputs": [], - "input_data": {}, - "is_forward": true, - "node_type": 0, - "outputs": [], - "output_data": {}, - "pair": "None", - "subnodes": [], - "type": "arg0_1", - "upnode": "AddThree_0", - "micro_step_id": "2", - "suggestions": { - "text": "test ptdbg工" - }, - "stack_info": [ - "File /home/w3000/xxxx/subnodes/sdd/adad/srit-sda/artar/prased, line 136. om het, \n dada = rtens/sda.ddd(asdw)" - ] - }, - "output_0": { - "matched_node_link": [], - "data": {}, - "id": "output_0", - "inputs": [], - "input_data": {}, - "is_forward": true, - "node_type": 0, - "outputs": [], - "output_data": {}, - "pair": "None", - "subnodes": [], - "type": "output", - "upnode": "AddThree_0", - "micro_step_id": "3" - } - }, - "root": "AddThree_0" - }, - "Bench": { - "edge": [], - "node": { - "AddOne_0": { - "matched_node_link": [ - "AddOne_0" - ], - "data": {}, - "id": "AddOne_0", - "inputs": [], - "input_data": { - "AddOne_0.input_arg.0": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 32, - 512, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406" - }, - "AddOne_0.input_arg.1": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 64, - 256, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406" - } - }, - "output_data": { - "AddOne_0.output_arg.0": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 32, - 512, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406" - }, - "AddOne_0.output_arg.1": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 64, - 256, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406" - } - }, - "is_forward": true, - "node_type": 0, - "outputs": [], - "pair": "None", - "subnodes": [ - "Test.add_0_withlonglonglonglonglonglonglonglongname.tt.ee" - ], - "type": "AddOne", - "upnode": "Test.maxpoolMaxPool2.maxpoolpo.tt.ee" - }, - "AddOne_1": { - "matched_node_link": [], - "data": {}, - "id": "AddOne_1", - "inputs": [], - "input_data": {}, - "is_forward": true, - "node_type": 0, - "outputs": [], - "output_data": {}, - "pair": "None", - "subnodes": [ - "add_1" - ], - "type": "AddOne", - "upnode": "Test.maxpoolMaxPool2.maxpoolpo.tt.ee" - }, - "Test.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.tt.ee": { - "matched_node_link": [], - "data": {}, - "id": "Test.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.tt.ee", - "inputs": [], - "input_data": {}, - "is_forward": true, - "node_type": 0, - "outputs": [], - "output_data": {}, - "pair": "None", - "subnodes": [ - "add_2" - ], - "type": "AddOne", - "upnode": "AddThree_0" - }, - "AddThree_0": { - "matched_node_link": [ - "N___AddThree_0" - ], - "data": {}, - "id": "AddThree_0", - "inputs": [], - "input_data": {}, - "is_forward": true, - "node_type": 0, - "outputs": [], - "output_data": {}, - "pair": "None", - "subnodes": [ - "arg0_1_0", - "Test.maxpoolMaxPool2.maxpoolpo.tt.ee", - "Test.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.tt.ee", - "output_0" - ], - "type": "AddThree", - "upnode": "root" - }, - "Test.maxpoolMaxPool2.maxpoolpo.tt.ee": { - "matched_node_link": [], - "data": {}, - "id": "Test.maxpoolMaxPool2.maxpoolpo.tt.ee", - "inputs": [], - "input_data": { - "Test.maxpoolMaxPool2.maxpoolpo.tt.ee.input_arg.0": { - "longlonglonglonglonglongName": "hah", - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": "[32, 512, 2, 2]", - "Max": "548.2343242", - "Min": "-234.124124234", - "Mean": "-5.23432654", - "Norm": "35555.3406", - "error_key": [ - "type", - "shape" - ] - }, - "Test.maxpoolMaxPool2.maxpoolpo.tt.ee.kwrag_arg.1": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 64, - 256, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406" - } - }, - "is_forward": true, - "node_type": 0, - "outputs": [], - "output_data": { - "output.0": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 128, - 512, - 2, - 2 - ], - "Max": "5038.2343242", - "Min": "-1234.124124234", - "Mean": "-410.23432654", - "Norm": "3255.3406" - }, - "output.1": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 16, - 256, - 2, - 2 - ], - "Max": "538.2343242", - "Min": "-234.124124234", - "Mean": "-51.23432654", - "Norm": "35555.3406" - } - }, - "pair": "None", - "subnodes": [ - "AddOne_0", - "AddOne_1" - ], - "type": "AddTwo", - "upnode": "AddThree_0" - }, - "Test.add_0_withlonglonglonglonglonglonglonglongname.tt.ee": { - "matched_node_link": [ - "N___AddThree_0", - "N___Test.maxpoolMaxPool2.maxpoolpo.tt.ee", - "N___AddOne_0", - "N___Test.add_0_withlonglonglonglonglonglonglonglongname.tt.ee" - ], - "data": {}, - "id": "Test.add_0_withlonglonglonglonglonglonglonglongname.tt.ee", - "inputs": [], - "input_data": { - "input_arg.0": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 32, - 512, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406" - }, - "input_arg.1": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 64, - 256, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406" - } - }, - "is_forward": true, - "node_type": 1, - "outputs": [], - "output_data": { - "output.0": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 128, - 512, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406" - }, - "output.1": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 16, - 256, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406" - } - }, - "pair": "None", - "subnodes": [], - "type": "add", - "upnode": "AddOne_0" - }, - "add_1": { - "matched_node_link": [], - "data": {}, - "id": "add_1", - "inputs": [], - "input_data": {}, - "is_forward": true, - "node_type": 1, - "outputs": [], - "output_data": {}, - "pair": "None", - "subnodes": [], - "type": "add", - "upnode": "AddOne_1" - }, - "add_2": { - "matched_node_link": [], - "data": {}, - "id": "add_2", - "inputs": [], - "input_data": { - "add_2.input_arg.0": { - "longlonglonglonglonglongName": "hah", - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": "[32, 512, 2, 2]", - "Max": "548.2343242", - "Min": "-234.124124234", - "Mean": "-5.23432654", - "Norm": "35555.3406", - "error_key": [ - "type", - "shape" - ] - }, - "add_2.kwrag_arg.1": { - "type": "torch.Tensor", - "dtype": "torch.float32", - "shape": [ - 64, - 256, - 2, - 2 - ], - "Max": "5348.2343242", - "Min": "-2344.124124234", - "Mean": "-51.23432654", - "Norm": "355555.3406" - } - }, - "is_forward": true, - "node_type": 1, - "outputs": [], - "output_data": {}, - "pair": "None", - "subnodes": [], - "type": "add", - "upnode": "Test.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.tt.ee" - }, - "arg0_1_0": { - "matched_node_link": [], - "data": {}, - "id": "arg0_1_0", - "inputs": [], - "input_data": {}, - "is_forward": true, - "node_type": 1, - "outputs": [], - "output_data": {}, - "pair": "None", - "subnodes": [], - "type": "arg0_1", - "upnode": "AddThree_0" - }, - "output_0": { - "matched_node_link": [], - "data": {}, - "id": "output_0", - "inputs": [], - "input_data": {}, - "is_forward": true, - "node_type": 1, - "outputs": [], - "output_data": {}, - "pair": "None", - "subnodes": [], - "type": "output", - "upnode": "AddThree_0" - } - }, - "root": "AddThree_0" - }, - "Colors": { - "#FF9B3D": { - "value": [ - 0, - 0.5 - ], - "description": "此节点所有输入输出的统计量相对误差,值越大代表测量值与标杆值的偏差越大,相对误差计算方式:|(测量值-标杆值)/标杆值|" - }, - "#FFDC7F": { - "value": [ - 0.5, - 1 - ], - "description": "此节点所有输入输出的统计量相对误差,值越大代表测量值与标杆值的偏差越大,相对误差计算方式:|(测量值-标杆值)/标杆值|" - }, - "#C7C7C7": { - "value": "无匹配节点", - "description": "对比过程中节点未匹配上" - } - }, - "MicroSteps": 5, - "StepList": [ - "ALL", - 0, - 1, - 2, - 3 - ], - "task": "summary", - "match": [], - "npu_match_nodes": { - "AddOne_0": "AddOne_0" - }, - "bench_match_nodes": { - "AddOne_0": "AddOne_0" - }, - "OverflowCheck": true -} \ No newline at end of file -- Gitee From d83e647277df688626d6315a3765212bd73df17c Mon Sep 17 00:00:00 2001 From: sunchao <1299792067@qq.com> Date: Fri, 18 Apr 2025 09:55:42 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tb_graph_ascend/fe/src/tf_graph/tf-graph-scene.ts | 3 +-- .../tb_graph_ascend/fe/src/tf_graph/tf-graph.ts | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/tf_graph/tf-graph-scene.ts b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/tf_graph/tf-graph-scene.ts index e7b12acc2f0..e1829e4140e 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/tf_graph/tf-graph-scene.ts +++ b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/tf_graph/tf-graph-scene.ts @@ -306,7 +306,6 @@ class TfGraphScene2 extends LegacyElementMixin(DarkModeMixin(PolymerElement)) im }, tb_debug.GraphDebugEventId.RENDER_SCENE_BUILD_SCENE, ); - console.log('tf-graph-scene: built scene====', renderHierarchy); // Update the minimap again when the graph is done animating. setTimeout((): void => { this.minimap.update(); @@ -703,7 +702,7 @@ class TfGraphScene2 extends LegacyElementMixin(DarkModeMixin(PolymerElement)) im _fireEnableClick(): void { this.fire('enable-click'); } - + // 取消鼠标点击自动居中 _noPanToNode(): void { this.enablePanSignal = false diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/tf_graph/tf-graph.ts b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/tf_graph/tf-graph.ts index 3eafa25502f..e16376056d3 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/tf_graph/tf-graph.ts +++ b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/tf_graph/tf-graph.ts @@ -28,7 +28,6 @@ import * as tf_graph_render from '../tf_graph_common/render'; import * as tf_graph_util from '../tf_graph_common/util'; import * as tf_graph_layout from '../tf_graph_common/layout'; import './tf-graph-scene'; -import '../main_graph/index' import './components/legend/index'; import type { MinimapVis, Selection } from '../tf_graph_controls/tf-graph-controls'; import { fetchPbTxt, parseGraphPbTxt } from '../tf_graph_common/parser'; -- Gitee From 756e2c580cb588f433c57f86818947239e021fec Mon Sep 17 00:00:00 2001 From: sunchao <1299792067@qq.com> Date: Fri, 18 Apr 2025 10:24:11 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=F0=9F=90=9E=20fix:=20code=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tb_graph_ascend/test/conftest.py | 28 ++++++-- .../integration/service/test_graph_service.py | 19 ++++- .../test_match_nodes_controller.py | 69 ++++++++++++------- .../tb_graph_ascend/test/units/test_plugin.py | 0 .../test/units/utils/test_graph_utils.py | 0 5 files changed, 83 insertions(+), 33 deletions(-) delete mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/test/units/test_plugin.py delete mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/test/units/utils/test_graph_utils.py diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/test/conftest.py b/plugins/tensorboard-plugins/tb_graph_ascend/test/conftest.py index 894f9ce6624..70475d16bd2 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/test/conftest.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/test/conftest.py @@ -1,7 +1,23 @@ -import pytest -import json +# Copyright (c) 2025, Huawei Technologies. +# 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 os +import json from pathlib import Path +import pytest def load_st_test_cases(): @@ -22,13 +38,13 @@ def pytest_generate_tests(metafunc): ut_test_cases = load_st_test_cases() params = [] for case in ut_test_cases: - metaData = case["meta_data"] - metaData["run"] = Path(__file__).parent / metaData["run"] + meta_data = case["meta_data"] + meta_data["run"] = Path(__file__).parent / meta_data["run"] for op in case["operations"]: params.append(pytest.param( - metaData, + meta_data, op, - id=f"{metaData['run']}-{op['type']}" + id=f"{meta_data['run']}-{op['type']}" )) # 确保参数名称与参数值数量一致 metafunc.parametrize("meta_data, operation", params) diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/test/integration/service/test_graph_service.py b/plugins/tensorboard-plugins/tb_graph_ascend/test/integration/service/test_graph_service.py index 35e3883ac5c..173b741bdfe 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/test/integration/service/test_graph_service.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/test/integration/service/test_graph_service.py @@ -1,9 +1,26 @@ +# Copyright (c) 2025, Huawei Technologies. +# 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 pytest from server.app.service.graph_service import GraphService class TestMatchNodesService: - + + @staticmethod def test_service(self, meta_data, operation_config): op_type = operation_config["type"] expected = operation_config["expected"] diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/test/units/controllers/test_match_nodes_controller.py b/plugins/tensorboard-plugins/tb_graph_ascend/test/units/controllers/test_match_nodes_controller.py index f0ac568d821..652f9c3b919 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/test/units/controllers/test_match_nodes_controller.py +++ b/plugins/tensorboard-plugins/tb_graph_ascend/test/units/controllers/test_match_nodes_controller.py @@ -1,66 +1,83 @@ +# Copyright (c) 2025, Huawei Technologies. +# 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 pytest from server.app.controllers.match_nodes_controller import MatchNodesController from server.app.utils.graph_utils import GraphUtils class TestMatchNodesController: - - def test_match_node_controller(self, ut_test_case): + + @staticmethod + def test_match_node_controller(ut_test_case): op_type = ut_test_case.get("type") - input = ut_test_case.get('input') + input_data = ut_test_case.get('input') expected = ut_test_case.get("expected") # 执行操作 try: if op_type == "process_md5_task_add": result = MatchNodesController.process_md5_task_add( - graph_data=input.get("graph_data"), - npu_node_name=input.get("npu_node_name"), - bench_node_name=input.get("bench_node_name"), + graph_data=input_data.get("graph_data"), + npu_node_name=input_data.get("npu_node_name"), + bench_node_name=input_data.get("bench_node_name"), ) elif op_type == "process_md5_task_delete": result = MatchNodesController.process_md5_task_delete( - graph_data=input.get("graph_data"), - npu_node_name=input.get("npu_node_name"), - bench_node_name=input.get("bench_node_name"), + graph_data=input_data.get("graph_data"), + npu_node_name=input_data.get("npu_node_name"), + bench_node_name=input_data.get("bench_node_name"), ) elif op_type == "process_summary_task_add": result = MatchNodesController.process_summary_task_add( - graph_data=input.get("graph_data"), - npu_node_name=input.get("npu_node_name"), - bench_node_name=input.get("bench_node_name"), + graph_data=input_data.get("graph_data"), + npu_node_name=input_data.get("npu_node_name"), + bench_node_name=input_data.get("bench_node_name"), ) elif op_type == "process_summary_task_delete": result = MatchNodesController.process_summary_task_delete( - npu_data=input.get("npu_data"), - bench_data=input.get("bench_data"), - npu_node_name=input.get("npu_node_name"), - bench_node_name=input.get("bench_node_name"), + npu_data=input_data.get("npu_data"), + bench_data=input_data.get("bench_data"), + npu_node_name=input_data.get("npu_node_name"), + bench_node_name=input_data.get("bench_node_name"), ) elif op_type == "calculate_statistical_diff": result = MatchNodesController.calculate_statistical_diff( - npu_data=input.get("npu_data"), - bench_data=input.get("bench_data"), - npu_node_name=input.get("npu_node_name"), - bench_node_name=input.get("bench_node_name"), + npu_data=input_data.get("npu_data"), + bench_data=input_data.get("bench_data"), + npu_node_name=input_data.get("npu_node_name"), + bench_node_name=input_data.get("bench_node_name"), ) elif op_type == "calculate_max_relative_error": result = MatchNodesController.calculate_max_relative_error( - result=input.get("result"), + result=input_data.get("result"), ) elif op_type == "calculate_md5_diff": result = MatchNodesController.calculate_md5_diff( - npu_data=input.get("npu_data"), - bench_data=input.get("bench_data"), + npu_data=input_data.get("npu_data"), + bench_data=input_data.get("bench_data"), ) elif op_type == "update_graph_node_data": result = MatchNodesController.update_graph_node_data( - graph_npu_node_data=input.get("graph_npu_node_data"), - statistical_diff=input.get("statistical_diff"), + graph_npu_node_data=input_data.get("graph_npu_node_data"), + statistical_diff=input_data.get("statistical_diff"), ) elif op_type == "delete_matched_node_data": result = MatchNodesController.delete_matched_node_data( - graph_npu_node_data=input.get("graph_npu_node_data"), + graph_npu_node_data=input_data.get("graph_npu_node_data"), ) else: return diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/test/units/test_plugin.py b/plugins/tensorboard-plugins/tb_graph_ascend/test/units/test_plugin.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/test/units/utils/test_graph_utils.py b/plugins/tensorboard-plugins/tb_graph_ascend/test/units/utils/test_graph_utils.py deleted file mode 100644 index e69de29bb2d..00000000000 -- Gitee