Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
a127d7c8
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
未验证
提交
a127d7c8
编写于
8月 09, 2023
作者:
K
kangguangli
提交者:
GitHub
8月 09, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[NewIR] minor fix about new ir test (#56075)
* fix bugs about new ir test * enable dy2st newir test in all cases * fix
上级
1bf2ab48
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
73 addition
and
147 deletion
+73
-147
paddle/scripts/paddle_build.sh
paddle/scripts/paddle_build.sh
+0
-1
test/dygraph_to_static/dy2st_test_utils.py
test/dygraph_to_static/dy2st_test_utils.py
+0
-73
test/dygraph_to_static/dygraph_to_static_util.py
test/dygraph_to_static/dygraph_to_static_util.py
+0
-3
test/legacy_test/eager_op_test.py
test/legacy_test/eager_op_test.py
+73
-70
未找到文件。
paddle/scripts/paddle_build.sh
浏览文件 @
a127d7c8
...
...
@@ -3962,7 +3962,6 @@ function main() {
check_coverage_build
;;
gpu_cicheck_coverage
)
export
FLAGS_NEW_IR_DY2ST_TEST
=
True
parallel_test
check_coverage
;;
...
...
test/dygraph_to_static/dy2st_test_utils.py
已删除
100644 → 0
浏览文件 @
1bf2ab48
# Copyright (c) 2023 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.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
os
from
functools
import
wraps
import
numpy
as
np
from
paddle
import
set_flags
,
static
from
paddle.fluid
import
core
def
test_with_new_ir
(
func
):
@
wraps
(
func
)
def
impl
(
*
args
,
**
kwargs
):
ir_outs
=
None
with
static
.
scope_guard
(
static
.
Scope
()):
with
static
.
program_guard
(
static
.
Program
()):
try
:
new_ir_flag
=
'FLAGS_enable_new_ir_in_executor'
os
.
environ
[
new_ir_flag
]
=
'True'
set_flags
({
new_ir_flag
:
True
})
ir_outs
=
func
(
*
args
,
**
kwargs
)
finally
:
del
os
.
environ
[
new_ir_flag
]
set_flags
({
new_ir_flag
:
False
})
return
ir_outs
return
impl
def
test_and_compare_with_new_ir
(
need_check_output
:
bool
=
True
):
def
decorator
(
func
):
@
wraps
(
func
)
def
impl
(
*
args
,
**
kwargs
):
outs
=
func
(
*
args
,
**
kwargs
)
if
core
.
_is_bwd_prim_enabled
()
or
core
.
_is_fwd_prim_enabled
():
return
outs
# only run in CI-Coverage
if
os
.
environ
.
get
(
'FLAGS_NEW_IR_DY2ST_TEST'
,
None
)
is
None
:
return
outs
ir_outs
=
test_with_new_ir
(
func
)(
*
args
,
**
kwargs
)
if
not
need_check_output
:
return
outs
for
i
in
range
(
len
(
outs
)):
np
.
testing
.
assert_array_equal
(
outs
[
i
],
ir_outs
[
i
],
err_msg
=
'Dy2St Unittest Check ('
+
func
.
__name__
+
') has diff '
+
'
\n
Expect '
+
str
(
outs
[
i
])
+
'
\n
'
+
'But Got'
+
str
(
ir_outs
[
i
]),
)
return
outs
return
impl
return
decorator
test/dygraph_to_static/dygraph_to_static_util.py
浏览文件 @
a127d7c8
...
...
@@ -145,9 +145,6 @@ def test_and_compare_with_new_ir(need_check_output: bool = True):
outs
=
func
(
*
args
,
**
kwargs
)
if
core
.
_is_bwd_prim_enabled
()
or
core
.
_is_fwd_prim_enabled
():
return
outs
# only run in CI-Coverage
if
os
.
environ
.
get
(
'FLAGS_NEW_IR_DY2ST_TEST'
,
None
)
is
None
:
return
outs
ir_outs
=
test_with_new_ir
(
func
)(
*
args
,
**
kwargs
)
if
not
need_check_output
:
return
outs
...
...
test/legacy_test/eager_op_test.py
浏览文件 @
a127d7c8
...
...
@@ -47,6 +47,7 @@ from paddle.fluid.framework import (
Program
,
_current_expected_place
,
canonicalize_attrs
,
get_flags
,
set_flags
,
)
from
paddle.fluid.wrapped_decorator
import
signature_safe_contextmanager
...
...
@@ -1209,7 +1210,8 @@ class OpTest(unittest.TestCase):
return
if
self
.
_check_cinn
:
return
stored_flag
=
get_flags
(
'FLAGS_enable_new_ir_in_executor'
)
try
:
set_flags
({
"FLAGS_enable_new_ir_in_executor"
:
True
})
new_scope
=
paddle
.
static
.
Scope
()
executor
=
Executor
(
place
)
...
...
@@ -1246,8 +1248,8 @@ class OpTest(unittest.TestCase):
+
' in class '
+
self
.
__class__
.
__name__
,
)
set_flags
({
"FLAGS_enable_new_ir_in_executor"
:
False
}
)
finally
:
set_flags
(
stored_flag
)
def
_calc_output
(
self
,
...
...
@@ -2896,8 +2898,9 @@ class OpTest(unittest.TestCase):
if
self
.
_check_cinn
:
return
stored_flag
=
get_flags
(
'FLAGS_enable_new_ir_in_executor'
)
try
:
set_flags
({
"FLAGS_enable_new_ir_in_executor"
:
True
})
executor
=
Executor
(
place
)
new_gradients
=
list
(
map
(
...
...
@@ -2928,8 +2931,8 @@ class OpTest(unittest.TestCase):
+
' in class '
+
self
.
__class__
.
__name__
,
)
set_flags
({
"FLAGS_enable_new_ir_in_executor"
:
False
}
)
finally
:
set_flags
(
stored_flag
)
def
_get_gradient
(
self
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录