Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
35a7ae21
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
未验证
提交
35a7ae21
编写于
4月 03, 2023
作者:
C
cyber-pioneer
提交者:
GitHub
4月 03, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Prim] polish prim arg None check (#52449)
* polish prim arg None check * fix bug
上级
9197b7f7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
0 deletion
+18
-0
python/paddle/incubate/autograd/primx.py
python/paddle/incubate/autograd/primx.py
+18
-0
未找到文件。
python/paddle/incubate/autograd/primx.py
浏览文件 @
35a7ae21
...
@@ -550,6 +550,17 @@ def _lower(block, reverse, blacklist):
...
@@ -550,6 +550,17 @@ def _lower(block, reverse, blacklist):
block
.
_sync_with_cpp
()
block
.
_sync_with_cpp
()
# In some case, inputs and outputs of composite op or its replaced composite rule might be None.
# It means such arg will be no longer required in processed program by composite mechanism.
# Therefore, such special ops should be recorded in advance and be released in args check.
ops_contain_none
=
(
"batch_norm"
,
"flatten_contiguous_range"
,
"squeeze2"
,
"unsqueeze2"
,
)
def
_lower_composite
(
def
_lower_composite
(
block
,
block
,
filter_
:
typing
.
Callable
[[
framework
.
Operator
],
bool
]
=
lambda
x
:
True
,
filter_
:
typing
.
Callable
[[
framework
.
Operator
],
bool
]
=
lambda
x
:
True
,
...
@@ -664,10 +675,17 @@ def _lower_composite(
...
@@ -664,10 +675,17 @@ def _lower_composite(
f
'when replace origin op
{
op_name
}
with composite rule, num of origin outs should be equal to new outs, '
f
'when replace origin op
{
op_name
}
with composite rule, num of origin outs should be equal to new outs, '
f
'but len(orig_outs) =
{
len
(
orig_outs
)
}
and len(new_outs) =
{
len
(
new_outs
)
}
'
f
'but len(orig_outs) =
{
len
(
orig_outs
)
}
and len(new_outs) =
{
len
(
new_outs
)
}
'
)
)
for
orig_out
,
new_out
in
zip
(
for
orig_out
,
new_out
in
zip
(
orig_outs
,
orig_outs
,
new_outs
,
new_outs
,
):
):
if
(
orig_out
is
None
or
new_out
is
None
)
and
(
op_name
not
in
ops_contain_none
):
raise
ValueError
(
f
"op
{
op_name
}
should not contain any None value. original outs=
{
orig_outs
}
and its composite rule outs=
{
new_outs
}
"
)
if
orig_out
is
None
:
if
orig_out
is
None
:
# to keep same as phi op definition, orig_out may receive None
# to keep same as phi op definition, orig_out may receive None
continue
continue
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录