Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
d7e0f875
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
d7e0f875
编写于
8月 28, 2023
作者:
N
niuliling123
提交者:
GitHub
8月 28, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change the print in debugging to RuntimeError (#56622)
上级
c5fc413a
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
36 addition
and
3 deletion
+36
-3
paddle/phi/kernels/cpu/debug_tools_kernel.cc
paddle/phi/kernels/cpu/debug_tools_kernel.cc
+1
-1
paddle/phi/kernels/gpu/debug_tools_kernel.cu
paddle/phi/kernels/gpu/debug_tools_kernel.cu
+1
-1
python/paddle/amp/debugging.py
python/paddle/amp/debugging.py
+3
-1
test/amp/test_tensor_checker.py
test/amp/test_tensor_checker.py
+31
-0
未找到文件。
paddle/phi/kernels/cpu/debug_tools_kernel.cc
浏览文件 @
d7e0f875
// Copyright (c) 202
2
PaddlePaddle Authors. All Rights Reserved.
// Copyright (c) 202
3
PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
paddle/phi/kernels/gpu/debug_tools_kernel.cu
浏览文件 @
d7e0f875
// Copyright (c) 202
2
PaddlePaddle Authors. All Rights Reserved.
// Copyright (c) 202
3
PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
python/paddle/amp/debugging.py
浏览文件 @
d7e0f875
...
...
@@ -115,6 +115,8 @@ def check_layer_numerics(func):
if
args
:
# Set temp data and temp.gradient = False
start_data
=
args
[
0
]
if
not
isinstance
(
start_data
,
paddle
.
Tensor
):
raise
RuntimeError
(
"First input of this layer must be tensor."
)
start_data
.
stop_gradient
=
False
modified_args
=
list
(
args
)
# Convert args to a mutable list
# Set FLAGS_check_nan_inf = 1
...
...
@@ -125,7 +127,7 @@ def check_layer_numerics(func):
out
=
_C_ops
.
disable_check_model_nan_inf
(
out_data
,
0
)
return
out
else
:
print
(
"No elements found in args
"
)
raise
RuntimeError
(
"No elements found in args.
"
)
out
=
func
(
self
,
*
args
,
**
kwargs
)
return
out
...
...
test/amp/test_tensor_checker.py
浏览文件 @
d7e0f875
...
...
@@ -138,6 +138,37 @@ class TestCheckLayerNumerics(unittest.TestCase):
loss
.
backward
()
adam
.
step
()
def
test_error_no_element
(
self
):
class
MyLayer
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
dtype
):
super
().
__init__
()
self
.
_w
=
self
.
create_parameter
([
2
,
3
],
dtype
=
dtype
)
@
paddle
.
amp
.
debugging
.
check_layer_numerics
def
forward
(
self
):
return
self
.
_w
with
self
.
assertRaises
(
RuntimeError
):
dtype
=
'float32'
model
=
MyLayer
(
dtype
)
data
=
model
()
def
test_error_type_error
(
self
):
class
MyLayer
(
paddle
.
nn
.
Layer
):
def
__init__
(
self
,
dtype
):
super
().
__init__
()
self
.
_w
=
self
.
create_parameter
([
2
,
3
],
dtype
=
dtype
)
@
paddle
.
amp
.
debugging
.
check_layer_numerics
def
forward
(
self
,
x
):
return
self
.
_w
*
x
x
=
1
with
self
.
assertRaises
(
RuntimeError
):
dtype
=
'float32'
model
=
MyLayer
(
dtype
)
data
=
model
(
x
)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录