From 4bb56bf2274d796dd9b56eb236c7c3e372c56665 Mon Sep 17 00:00:00 2001 From: sunchao <1299792067@qq.com> Date: Thu, 10 Jul 2025 16:20:20 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E2=9C=A8=20feat:=20=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E6=A1=86=E6=9E=B6=E6=90=AD=E5=BB=BA=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tb_graph_ascend/fe/package-lock.json | 53 ++++++++++++++- .../tb_graph_ascend/fe/package.json | 4 +- .../tb_graph_ascend/fe/src/common/i18n.ts | 44 +++++++++++++ .../components/tf_main_controler/index.ts | 9 ++- .../fe/src/graph_controls_board/index.ts | 65 ++++++++++++++----- 5 files changed, 155 insertions(+), 20 deletions(-) create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/fe/src/common/i18n.ts diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/fe/package-lock.json b/plugins/tensorboard-plugins/tb_graph_ascend/fe/package-lock.json index bf8421803..4ab8eb898 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/fe/package-lock.json +++ b/plugins/tensorboard-plugins/tb_graph_ascend/fe/package-lock.json @@ -50,6 +50,8 @@ "css-loader": "^7.1.2", "d3": "5.7.0", "dagre": "^0.8.5", + "i18next": "^25.3.2", + "i18next-browser-languagedetector": "^8.2.0", "lodash": "^4.17.21", "prettier": "^3.4.2", "style-loader": "^4.0.0" @@ -74,6 +76,15 @@ "ws": "8.13.0" } }, + "node_modules/@babel/runtime": { + "version": "7.27.6", + "resolved": "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.27.6.tgz", + "integrity": "sha512-vbavdySgbTTrmFE+EsiqUTzlOr5bzlnJtUv9PynGCAKvfQqjIXbvFdumPM/GxMDfyuGMJaJAU6TO4zc1Jf1i8Q==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@discoveryjs/json-ext": { "version": "0.5.7", "resolved": "https://registry.npmmirror.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz", @@ -4155,6 +4166,46 @@ "node": ">=10.17.0" } }, + "node_modules/i18next": { + "version": "25.3.2", + "resolved": "https://registry.npmmirror.com/i18next/-/i18next-25.3.2.tgz", + "integrity": "sha512-JSnbZDxRVbphc5jiptxr3o2zocy5dEqpVm9qCGdJwRNO+9saUJS0/u4LnM/13C23fUEWxAylPqKU/NpMV/IjqA==", + "funding": [ + { + "type": "individual", + "url": "https://locize.com" + }, + { + "type": "individual", + "url": "https://locize.com/i18next.html" + }, + { + "type": "individual", + "url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project" + } + ], + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.27.6" + }, + "peerDependencies": { + "typescript": "^5" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/i18next-browser-languagedetector": { + "version": "8.2.0", + "resolved": "https://registry.npmmirror.com/i18next-browser-languagedetector/-/i18next-browser-languagedetector-8.2.0.tgz", + "integrity": "sha512-P+3zEKLnOF0qmiesW383vsLdtQVyKtCNA9cjSoKCppTKPQVfKd2W8hbVo5ZhNJKDqeM7BOcvNoKJOjpHh4Js9g==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.23.2" + } + }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -6204,7 +6255,7 @@ "version": "5.8.2", "resolved": "https://registry.npmmirror.com/typescript/-/typescript-5.8.2.tgz", "integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==", - "dev": true, + "devOptional": true, "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/fe/package.json b/plugins/tensorboard-plugins/tb_graph_ascend/fe/package.json index fb9c1d48f..5334548a9 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/fe/package.json +++ b/plugins/tensorboard-plugins/tb_graph_ascend/fe/package.json @@ -71,8 +71,10 @@ "css-loader": "^7.1.2", "d3": "5.7.0", "dagre": "^0.8.5", + "i18next": "^25.3.2", + "i18next-browser-languagedetector": "^8.2.0", "lodash": "^4.17.21", "prettier": "^3.4.2", "style-loader": "^4.0.0" } -} \ No newline at end of file +} diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/common/i18n.ts b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/common/i18n.ts new file mode 100644 index 000000000..a18ddbef3 --- /dev/null +++ b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/common/i18n.ts @@ -0,0 +1,44 @@ +// i18n.js +import i18next from 'i18next'; +import LanguageDetector from 'i18next-browser-languagedetector'; + +i18next + .use(LanguageDetector) + .init({ + fallbackLng: 'zh-CN', + resources: { + en: { + translation: { + "fit": "Fit Screen", + "settings": "Settings", + "match": 'Matching', + "show_debug_minimap": "show debug minimap", + "show_bench_minimap": "show bench minimap", + "run": "Run", + "tag": "Tag", + "invalid_rank_id": "Tip: The target file does not exist" + } + }, + 'zh-CN': { + translation: { + "fit": "自适应屏幕", + "settings": "设置", + "match": '匹配', + "show_debug_minimap": "调试侧缩略图", + "show_bench_minimap": "标杆侧缩略图", + "run": "目录", + "tag": "文件", + "invalid_rank_id": "提示:目标文件不存在" + } + } + }, + detection: { + order: ['navigator'] // 只使用浏览器语言检测 + }, + debug: false, + interpolation: { + escapeValue: false + } + }); + +export default i18next; \ No newline at end of file diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/graph_controls_board/components/tf_main_controler/index.ts b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/graph_controls_board/components/tf_main_controler/index.ts index 847653905..74131c7c7 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/graph_controls_board/components/tf_main_controler/index.ts +++ b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/graph_controls_board/components/tf_main_controler/index.ts @@ -61,12 +61,15 @@ class MainController extends PolymerElement {
- - + +
`; + @property({ type: Object }) + t: Function = () => ''; + @property({ type: Object }) metaDir: MetaDirType = {}; @@ -154,7 +157,7 @@ class MainController extends PolymerElement { _getTagChanged(event): void { const detail = event.detail; if (!detail?.rankId || detail?.rankId >= this.tags.length) { - Notification.show('提示:目标文件不存在', { + Notification.show(this.t('invalid rank id'), { position: 'middle', duration: 2000, theme: 'warning', diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/graph_controls_board/index.ts b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/graph_controls_board/index.ts index 59ec172fe..fc6b7b866 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/graph_controls_board/index.ts +++ b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/graph_controls_board/index.ts @@ -21,6 +21,7 @@ import '@vaadin/icons'; import '@vaadin/select'; import '@vaadin/button'; + import * as _ from 'lodash'; import { customElement, property } from '@polymer/decorators'; import { html, PolymerElement } from '@polymer/polymer'; @@ -29,6 +30,7 @@ import { LegacyElementMixin } from '../polymer/legacy_element_mixin'; import { PaperCheckboxElement } from '../polymer/irons_and_papers'; import '../polymer/irons_and_papers'; +import i18next from '../common/i18n' import './components/tf_main_controler'; import './components/tf_manual_match/index'; import './components/tf_color_select/index'; @@ -75,13 +77,17 @@ class TfGraphControls extends LegacyElementMixin(DarkModeMixin(PolymerElement)) } .minimap-control { font-size: var(--tb-graph-controls-title-font-size); - height: 36px; - line-height: 36px; + height: 42px; + display: flex; + flex-wrap: wrap; } - .right-checkbox { - margin-left: 8px; + + .left-checkbox { + margin-right: 12px; } + + .icon-button { font-size: var(--tb-graph-controls-title-font-size); } @@ -109,6 +115,7 @@ class TfGraphControls extends LegacyElementMixin(DarkModeMixin(PolymerElement)) .tabs { display: flex; + height: 40px; border-bottom: 1px solid #ccc; } @@ -141,6 +148,17 @@ class TfGraphControls extends LegacyElementMixin(DarkModeMixin(PolymerElement)) font-weight: 400; cursor: pointer; } + .setting-title { + display: flex; + justify-content: space-between; + align-items: center; + } + .language-button{ + font-size: var(--tb-graph-controls-title-font-size); + font-weight: 400; + cursor: pointer; + color: black; + } .hidden { display: none; @@ -152,23 +170,26 @@ class TfGraphControls extends LegacyElementMixin(DarkModeMixin(PolymerElement))
- - + +
-
- - 自适应屏幕 +
+
+ + [[t('fit')]] +
+ 中|en
-
- 调试侧缩略图 + [[t('show_debug_minimap')]]
`; + @property({ type: Object }) + t: Function = (key) => i18next.t(key); + @property({ type: Object }) metaDir: MetaDirType = {} as MetaDirType; @@ -247,7 +271,18 @@ class TfGraphControls extends LegacyElementMixin(DarkModeMixin(PolymerElement)) override ready(): void { super.ready(); - this._showTabContent('设置', 'nodes-content'); + this._showTabContent(this.t('settings'), 'nodes-content'); + } + + changeLanguage() { + const currentLang = i18next.language === 'en' ? 'zh-CN' : 'en'; + i18next.changeLanguage(currentLang).then(() => { + //更新语言后重新渲染 + const t = this.t; + this.set('t', null); + this.set('t', t); + + }); } _showTabContent(buttonText, contentId): void { @@ -278,11 +313,11 @@ class TfGraphControls extends LegacyElementMixin(DarkModeMixin(PolymerElement)) // 使用示例 _showNodeControls(): void { - this._showTabContent('设置', 'nodes-content'); + this._showTabContent(this.t('settings'), 'nodes-content'); } _showMatch(): void { - this._showTabContent('匹配', 'match-content'); + this._showTabContent(this.t('match'), 'match-content'); } _fit(): void { -- Gitee From 9c6b87239c63623d7847d9cad871bb7cb40e88ab Mon Sep 17 00:00:00 2001 From: sunchao <1299792067@qq.com> Date: Fri, 11 Jul 2025 10:33:20 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E2=9C=A8=20feat:=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=AD=E8=8B=B1=E6=96=87=EF=BC=8820%?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tb_graph_ascend/fe/src/common/constant.ts | 8 --- .../tb_graph_ascend/fe/src/common/i18n.ts | 69 ++++++++++++++----- .../components/tf_color_select/index.ts | 35 +++++++--- .../tf_linkage_search_combox/index.ts | 23 +++++-- .../components/tf_main_controler/index.ts | 2 +- .../components/tf_manual_match/index.ts | 25 +++++-- .../fe/src/graph_controls_board/index.ts | 5 +- 7 files changed, 118 insertions(+), 49 deletions(-) diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/common/constant.ts b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/common/constant.ts index d9ba426e9..145aa9438 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/common/constant.ts +++ b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/common/constant.ts @@ -78,11 +78,3 @@ export const PREFIX_MAP = { NPU: NPU_PREFIX, Bench: BENCH_PREFIX, }; - -export const PRECISION_DESC = { - "summary": "节点中调试侧和标杆侧输出的统计量相对误差,值越大精度差距越大,颜色标记越深,相对误差指标(RelativeErr):| (调试值 - 标杆值) / 标杆值 |", - - "all": "节点中所有输入的最小双千指标和所有输出的最小双千分之一指标的差值,反映了双千指标的下降情况,值越大精度差距越大,颜色标记越深,双千分之一精度指标(One Thousandth Err Ratio):Tensor中的元素逐个与对应的标杆数据对比,相对误差小于千分之一的比例占总元素个数的比例,比例越接近1越好", - - "md5": "节点中任意输入输出的md5值不同则标记为红色" -} \ No newline at end of file diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/common/i18n.ts b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/common/i18n.ts index a18ddbef3..18036be0c 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/common/i18n.ts +++ b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/common/i18n.ts @@ -9,26 +9,63 @@ i18next resources: { en: { translation: { - "fit": "Fit Screen", - "settings": "Settings", - "match": 'Matching', - "show_debug_minimap": "show debug minimap", - "show_bench_minimap": "show bench minimap", - "run": "Run", - "tag": "Tag", - "invalid_rank_id": "Tip: The target file does not exist" + fit: "Fit Screen", + settings: "Settings", + match: 'Matching', + show_debug_minimap: "show debug minimap", + show_bench_minimap: "show bench minimap", + run: "Run", + tag: "Tag", + invalid_rank_id: "Tip: The target file does not exist", + data_side: "Data Side", + search_node: "Search Node", + node_list: "Node List", + debug: "Debug", + bench: "Bench", + accuracy_error: "Accuracy Error", + overflow: "Overflow", + match_accuracy_error: "Match Accuracy Error Node", + overflow_filter_node: "Overflow Filter Node", + no_matching_nodes: "No matching nodes", + precision_desc: { + summary: "The relative error between the statistical output of the debug side and the benchmark side of the node, the larger the value, the greater the precision gap, the darker the color mark, the relative error indicator (RelativeErr): | (debug value - benchmark value) / benchmark value |", + all: "The difference between the minimum double thousand indicator of all inputs and the minimum double thousandth indicator of all outputs of the node, reflecting the decline of the double thousand indicator, the larger the value, the greater the precision gap, the darker the color mark, the double thousandth precision indicator (One Thousandth Err Ratio): The relative error of each element in the tensor is compared with the corresponding benchmark data, the proportion of relative error less than one thousandth of the total number of elements, the closer the proportion is to 1, the better", + md5: "If the md5 value of any input or output of the node is different, it will be marked red" + }, + node_match: "Node Match", + select_match_config_file: "Select Match Config File", + select_match_config_file_desc: "Select the corresponding configuration file, read the matching node information, and match the corresponding node." + } }, 'zh-CN': { translation: { - "fit": "自适应屏幕", - "settings": "设置", - "match": '匹配', - "show_debug_minimap": "调试侧缩略图", - "show_bench_minimap": "标杆侧缩略图", - "run": "目录", - "tag": "文件", - "invalid_rank_id": "提示:目标文件不存在" + fit: "自适应屏幕", + settings: "设置", + match: '匹配', + show_debug_minimap: "调试侧缩略图", + show_bench_minimap: "标杆侧缩略图", + run: "目录", + tag: "文件", + invalid_rank_id: "提示:目标文件不存在", + data_side: "数据侧", + search_node: "节点搜索", + node_list: "节点列表", + debug: "调试侧", + bench: "标杆侧", + accuracy_error: "精度误差", + overflow: "精度溢出", + match_accuracy_error: "符合精度误差节点", + overflow_filter_node: "溢出筛选节点", + no_matching_nodes: "无匹配节点11", + precision_desc: { + "summary": "节点中调试侧和标杆侧输出的统计量相对误差,值越大精度差距越大,颜色标记越深,相对误差指标(RelativeErr):| (调试值 - 标杆值) / 标杆值 |", + "all": "节点中所有输入的最小双千指标和所有输出的最小双千分之一指标的差值,反映了双千指标的下降情况,值越大精度差距越大,颜色标记越深,双千分之一精度指标(One Thousandth Err Ratio):Tensor中的元素逐个与对应的标杆数据对比,相对误差小于千分之一的比例占总元素个数的比例,比例越接近1越好", + "md5": "节点中任意输入输出的md5值不同则标记为红色" + }, + node_match: "节点匹配", + select_match_config_file: "选择匹配配置文件", + select_match_config_file_desc: "选择对应配置文件,会读取匹配节点信息,并将对应节点进行匹配。" } } }, diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/graph_controls_board/components/tf_color_select/index.ts b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/graph_controls_board/components/tf_color_select/index.ts index a8efe1615..f7cdb2bee 100644 --- a/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/graph_controls_board/components/tf_color_select/index.ts +++ b/plugins/tensorboard-plugins/tb_graph_ascend/fe/src/graph_controls_board/components/tf_color_select/index.ts @@ -24,9 +24,7 @@ import { NPU_PREFIX, UNMATCHED_COLOR, defaultColorSetting, defaultColorSelects } import request from '../../../utils/request'; import { DarkModeMixin } from '../../../polymer/dark_mode_mixin'; import { LegacyElementMixin } from '../../../polymer/legacy_element_mixin'; -import { PRECISION_DESC } from '../../../common/constant'; -const UNMATCHED_NODE_NAME = '无匹配节点'; @customElement('tf-color-select') class Legend extends LegacyElementMixin(DarkModeMixin(PolymerElement)) { // 定义模板 @@ -146,7 +144,7 @@ class Legend extends LegacyElementMixin(DarkModeMixin(PolymerElement)) { cursor: pointer; position: relative; font-size: 10px; - top: -4px; + top: -2px; left: 2px; } @@ -170,7 +168,7 @@ class Legend extends LegacyElementMixin(DarkModeMixin(PolymerElement)) {