Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
4b8b4c71
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4b8b4c71
编写于
2月 11, 2023
作者:
C
cyber-pioneer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
map output from composite rule to origin op
上级
37b33973
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
33 addition
and
7 deletion
+33
-7
python/paddle/incubate/autograd/composite_rules.py
python/paddle/incubate/autograd/composite_rules.py
+2
-2
python/paddle/incubate/autograd/primx.py
python/paddle/incubate/autograd/primx.py
+7
-5
python/paddle/incubate/autograd/utils.py
python/paddle/incubate/autograd/utils.py
+24
-0
未找到文件。
python/paddle/incubate/autograd/composite_rules.py
浏览文件 @
4b8b4c71
...
...
@@ -98,6 +98,6 @@ def composite_batchnorm(
run_mean_
=
assign
(
run_mean
)
run_var_
=
assign
(
run_var
)
if
trainable_statistics
or
not
is_test
:
return
run_mean_
,
None
,
batch_mean_
,
batch_var_
,
run_var_
,
y
return
y
,
run_mean_
,
run_var_
,
batch_mean_
,
batch_var_
,
None
else
:
return
run_mean_
,
batch_mean_
,
batch_var_
,
run_var_
,
y
return
y
,
run_mean_
,
run_var_
,
batch_mean_
,
batch_var_
python/paddle/incubate/autograd/primx.py
浏览文件 @
4b8b4c71
...
...
@@ -36,6 +36,7 @@ from .utils import (
flatten_and_remove_none
,
get_input_var_list
,
get_output_var_list
,
get_output_vars_from_comosite
,
prepare_python_api_arguments
,
)
...
...
@@ -605,10 +606,11 @@ def _lower_composite(block, blacklist=[]):
bind
(
input_args
,
to_bind
,
value_table
)
for
orig_out
,
new_out
in
zip
(
expand_nested_list
(
get_output_var
_list
(
op
)),
expand_nested_list
(
get_output_var
s_from_comosite
(
op
)),
expand_nested_list
(
as_tensors
(
lower_fn
(
op
,
*
input_args
))),
):
if
new_out
is
not
None
:
if
orig_out
.
shape
and
new_out
.
shape
:
assert
orig_out
.
shape
==
new_out
.
shape
,
(
f
'when replace origin op with composite rule, origin out shape should be equal to new out shape, '
f
'but orig_out.shape=
{
orig_out
.
shape
}
and new_out.shape=
{
new_out
.
shape
}
'
...
...
python/paddle/incubate/autograd/utils.py
浏览文件 @
4b8b4c71
...
...
@@ -219,6 +219,30 @@ def get_output_var_list(op):
]
def
get_output_vars_from_comosite
(
op
):
"""origin op outputs must be mapped into outputs of composite rule."""
origin_output_names
=
op
.
output_names
if
origin_output_names
is
None
:
return
[]
else
:
name
=
op
.
type
res
=
[]
if
op_map
[
name
].
get
(
"outputs"
):
for
item
in
op_map
[
name
][
"outputs"
].
keys
():
origin_output_name
=
op_map
[
name
][
"outputs"
][
item
]
if
origin_output_name
not
in
origin_output_names
:
continue
origin_output_var
=
get_var_block
(
op
.
block
,
op
.
output
(
origin_output_name
))
res
.
append
(
origin_output_var
)
elif
len
(
origin_output_names
)
==
1
:
# When origin output num is 1, map info is not needed.
origin_output_var
=
get_var_block
(
op
.
block
,
op
.
output
(
origin_output_names
[
0
]))
res
.
append
(
origin_output_var
)
else
:
raise
ValueError
(
"When replace op with composite rule, there must exist output map info from origin op to composite rule."
)
return
res
def
flatten
(
inp
):
if
inp
is
None
or
isinstance
(
inp
,
paddle
.
fluid
.
framework
.
Variable
):
return
[
inp
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录