执行训练过程中,用户可使用以下方法进行调试。
print(torch.npu.synchronize(),"打点") print(inputs.shape, inputs.dtype, inputs,storage().npu_format) #所需打印参数可根据实际情况变更
import pdb pdb.set_trace()
breakpoint()
#调试core文件 gdb python3 core
def hook_func(name, module): def hook_function(module, inputs, outputs): print(name) return hook_function for name, module in model.named_modules(): if module is not None: module.register_forward_hook(hook_func('[forward]:' + name, module)) module.register_backward_hook(hook_func('[backward]:' + name, module))