diff --git a/debug/accuracy_tools/ptdbg_ascend/src/python/ptdbg_ascend/common/utils.py b/debug/accuracy_tools/ptdbg_ascend/src/python/ptdbg_ascend/common/utils.py index 3b8bcc4b5f3a1a6ef33c860b586270014c1b959d..5957eb1924ffcb41d16843e79701b1296ab8cbfa 100644 --- a/debug/accuracy_tools/ptdbg_ascend/src/python/ptdbg_ascend/common/utils.py +++ b/debug/accuracy_tools/ptdbg_ascend/src/python/ptdbg_ascend/common/utils.py @@ -626,18 +626,18 @@ def check_seed_all(seed, mode): def get_process_rank(model): print_info_log("Rank id is not provided. Trying to get the rank id of the model.") try: - device = next(model.parameters()).device + local_device = next(model.parameters()).device except StopIteration: print_warn_log('There is no parameter in the model. Fail to get rank id.') return 0, False - if device.type == 'cpu': + if local_device.type == 'cpu': print_warn_log("Warning: the debugger is unable to get the rank id. " "This may cause the dumpped data to be corrupted in the " "case of distributed training. (You may ignore this if you are using only one card.) " "Transfer the model to npu or gpu before register_hook() to avoid this warning.") return 0, False else: - return device.index, True + return local_device.index, True def parameter_adapter(func): @@ -645,24 +645,24 @@ def parameter_adapter(func): @wraps(func) def inner(self, *args, **kwargs): if self.op_name_ == "__getitem__" and len(args) > 1 and isinstance(args[1], torch.Tensor): - input = args[0] + input_tensor = args[0] indices = args[1] if indices.dtype == torch.uint8: indices = indices.bool() if indices.dtype == torch.bool: - if indices.shape == input.shape: - return getattr(torch._C._VariableFunctionsClass, "masked_select")(input, indices) + if indices.shape == input_tensor.shape: + return getattr(torch._C._VariableFunctionsClass, "masked_select")(input_tensor, indices) else: indices = getattr(torch._C._VariableFunctionsClass, "nonzero")(indices, as_tuple=True) - return getattr(torch._C._TensorBase, "__getitem__")(input, indices) + return getattr(torch._C._TensorBase, "__getitem__")(input_tensor, indices) elif indices.dtype != torch.bool: if len(indices.shape) == 1: - return func(self, input, indices.tolist()) + return func(self, input_tensor, indices.tolist()) elif len(indices.shape) == 2: - result = [func(self, input, index) for index in indices.tolist()] + result = [func(self, input_tensor, index) for index in indices.tolist()] return getattr(torch._C._VariableFunctionsClass, "stack")(result, 0) else: - res = [input[tensor_index] for tensor_index in indices] + res = [input_tensor[tensor_index] for tensor_index in indices] return getattr(torch._C._VariableFunctionsClass, "stack")(res, 0) return func(self, *args, **kwargs) return inner diff --git a/debug/accuracy_tools/ptdbg_ascend/src/python/ptdbg_ascend/dump/dump.py b/debug/accuracy_tools/ptdbg_ascend/src/python/ptdbg_ascend/dump/dump.py index c5e3dd7b5054327a4ec26009e605898b3a35d13d..e726d2bc277c6b69a3704d794ad1a748f2655387 100644 --- a/debug/accuracy_tools/ptdbg_ascend/src/python/ptdbg_ascend/dump/dump.py +++ b/debug/accuracy_tools/ptdbg_ascend/src/python/ptdbg_ascend/dump/dump.py @@ -109,7 +109,6 @@ def json_dump_condition(prefix): def dump_tensor(x, prefix, dump_step): - global data_info if isinstance(x, (tuple, list)) and x: for i, item in enumerate(x): dump_tensor(item, "{}.{}".format(prefix, i), dump_step) diff --git a/debug/accuracy_tools/ptdbg_ascend/src/python/setup.py b/debug/accuracy_tools/ptdbg_ascend/src/python/setup.py index 02b990655aa04f9dec91898d11fcd124cc8a2bbb..8ce00ca4f7b665e8a2d1e9135fec2e6aaa3d8e2f 100644 --- a/debug/accuracy_tools/ptdbg_ascend/src/python/setup.py +++ b/debug/accuracy_tools/ptdbg_ascend/src/python/setup.py @@ -31,7 +31,7 @@ def generate_ptdbg_ascend_version(): flags = os.O_WRONLY | os.O_CREAT | os.O_EXCL modes = stat.S_IWUSR | stat.S_IRUSR with os.fdopen(os.open(version_path, flags, modes), 'w') as f: - f.write("__version__ = '{version}'\n".format(version = VERSION)) + f.write("__version__ = '{version}'\n".format(version=VERSION)) generate_ptdbg_ascend_version() @@ -40,7 +40,7 @@ setuptools.setup(name='ptdbg_ascend', description='This is a pytorch precision comparison tools', long_description='This is a pytorch precision comparison tools, include overflow detect tool', packages=setuptools.find_packages(), - install_requires = [ + install_requires=[ "wheel", "numpy", "pandas >= 1.3.5",