From 4f5f530092dda4843c374218fc7d65c05141aab0 Mon Sep 17 00:00:00 2001 From: gitee Date: Mon, 11 Sep 2023 17:34:07 +0800 Subject: [PATCH 1/2] fwe --- .../api_accuracy_checker/common/utils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/common/utils.py b/debug/accuracy_tools/api_accuracy_checker/common/utils.py index 94907f0149..9ff2f1ff74 100644 --- a/debug/accuracy_tools/api_accuracy_checker/common/utils.py +++ b/debug/accuracy_tools/api_accuracy_checker/common/utils.py @@ -36,7 +36,14 @@ except ImportError: else: IS_GPU = False -if not IS_GPU: +torch_without_guard_version_list = ['2.1'] +for version in torch.without_guard_version_list: + if torch.__version__.startswith(version): + torch_without_guard_version = True + break + else: + torch_without_guard_version = False +if not IS_GPU and not torch_without_guard_version: from torch_npu.utils.device_guard import torch_device_guard as torch_npu_device_guard device = collections.namedtuple('device', ['type', 'index']) @@ -456,7 +463,7 @@ def format_value(value): def torch_device_guard(func): - if IS_GPU: + if IS_GPU or torch_without_guard_version: return func # Parse args/kwargs matched torch.device objects -- Gitee From 4a9f2402b4793d700eb9b4ca9c5d14d5501748f8 Mon Sep 17 00:00:00 2001 From: gitee Date: Mon, 11 Sep 2023 20:02:19 +0800 Subject: [PATCH 2/2] fix --- debug/accuracy_tools/api_accuracy_checker/common/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/common/utils.py b/debug/accuracy_tools/api_accuracy_checker/common/utils.py index 9ff2f1ff74..9304a9ca4f 100644 --- a/debug/accuracy_tools/api_accuracy_checker/common/utils.py +++ b/debug/accuracy_tools/api_accuracy_checker/common/utils.py @@ -37,7 +37,7 @@ else: IS_GPU = False torch_without_guard_version_list = ['2.1'] -for version in torch.without_guard_version_list: +for version in torch_without_guard_version_list: if torch.__version__.startswith(version): torch_without_guard_version = True break -- Gitee