From 48dea25e9e60a4e6f5e7257c86a88d7d178a7dec Mon Sep 17 00:00:00 2001 From: fuchao Date: Thu, 12 Jun 2025 16:29:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DKBKDump=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=9A=E8=BF=9B=E7=A8=8B=E4=B8=8B=E5=86=99?= =?UTF-8?q?=E5=85=A5=E4=B8=8D=E5=AE=8C=E6=95=B4=E8=A2=AB=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msprobe/mindspore/dump/cell_dump_process.py | 8 +++++++- .../mindspore/dump/cell_dump_with_insert_gradient.py | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/debug/accuracy_tools/msprobe/mindspore/dump/cell_dump_process.py b/debug/accuracy_tools/msprobe/mindspore/dump/cell_dump_process.py index 44f8dbdfb..22a7e4ecd 100644 --- a/debug/accuracy_tools/msprobe/mindspore/dump/cell_dump_process.py +++ b/debug/accuracy_tools/msprobe/mindspore/dump/cell_dump_process.py @@ -801,8 +801,14 @@ def create_kbyk_json(dump_path, summary_mode, step): } create_directory(dump_path) + tmp_json_path = os.path.join(dump_path, "tmp.json") config_json_path = os.path.join(dump_path, "kernel_kbyk_dump.json") - save_json(config_json_path, config_json, indent=4) + save_json(tmp_json_path, config_json, indent=4) + while not os.path.exists(tmp_json_path): + logger.info(f"Waiting for {tmp_json_path} to be created...") + time.sleep(1) + if os.path.exists(tmp_json_path): + move_file(tmp_json_path, config_json_path) logger.info(config_json_path + " has been created.") return config_json_path diff --git a/debug/accuracy_tools/msprobe/mindspore/dump/cell_dump_with_insert_gradient.py b/debug/accuracy_tools/msprobe/mindspore/dump/cell_dump_with_insert_gradient.py index 6b8b73445..363503f9e 100644 --- a/debug/accuracy_tools/msprobe/mindspore/dump/cell_dump_with_insert_gradient.py +++ b/debug/accuracy_tools/msprobe/mindspore/dump/cell_dump_with_insert_gradient.py @@ -778,8 +778,14 @@ def create_kbyk_json(dump_path, summary_mode, step): } create_directory(dump_path) + tmp_json_path = os.path.join(dump_path, "tmp.json") config_json_path = os.path.join(dump_path, "kernel_kbyk_dump.json") - save_json(config_json_path, config_json, indent=4) + save_json(tmp_json_path, config_json, indent=4) + while not os.path.exists(tmp_json_path): + logger.info(f"Waiting for {tmp_json_path} to be created...") + time.sleep(1) + if os.path.exists(tmp_json_path): + move_file(tmp_json_path, config_json_path) logger.info(config_json_path + " has been created.") return config_json_path -- Gitee