Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
1b4cc22d
提交
1b4cc22d
authored
8月 18, 2008
作者:
Olivier Breuleux
浏览文件
操作
浏览文件
下载
差异文件
merge
上级
11be7be2
730f1d87
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
47 行增加
和
20 行删除
+47
-20
graph.py
gof/graph.py
+47
-20
没有找到文件。
gof/graph.py
浏览文件 @
1b4cc22d
...
...
@@ -349,7 +349,6 @@ def clone_get_equiv(i, o, copy_inputs_and_orphans = True):
"""
d
=
{}
for
input
in
i
:
if
copy_inputs_and_orphans
:
cpy
=
input
.
clone
()
...
...
@@ -359,29 +358,57 @@ def clone_get_equiv(i, o, copy_inputs_and_orphans = True):
else
:
d
[
input
]
=
input
def
clone_helper
(
result
):
if
result
in
d
:
return
d
[
result
]
node
=
result
.
owner
if
node
is
None
:
# result is an orphan
if
copy_inputs_and_orphans
:
cpy
=
result
.
clone
()
d
[
result
]
=
cpy
else
:
d
[
result
]
=
result
return
d
[
result
]
else
:
new_node
=
node
.
clone_with_new_inputs
([
clone_helper
(
input
)
for
input
in
node
.
inputs
])
d
[
node
]
=
new_node
for
output
,
new_output
in
zip
(
node
.
outputs
,
new_node
.
outputs
):
d
[
output
]
=
new_output
return
d
[
result
]
for
output
in
o
:
clone_helper
(
output
)
for
apply
in
io_toposort
(
i
,
o
):
for
input
in
apply
.
inputs
:
if
input
not
in
d
:
if
copy_inputs_and_orphans
:
cpy
=
input
.
clone
()
d
[
input
]
=
cpy
else
:
d
[
input
]
=
input
new_apply
=
apply
.
clone_with_new_inputs
([
d
[
i
]
for
i
in
apply
.
inputs
])
d
[
apply
]
=
new_apply
for
output
,
new_output
in
zip
(
apply
.
outputs
,
new_apply
.
outputs
):
d
[
output
]
=
new_output
return
d
## Previous version
# for input in i:
# if copy_inputs_and_orphans:
# cpy = input.clone()
# cpy.owner = None
# cpy.index = None
# d[input] = cpy
# else:
# d[input] = input
#
# def clone_helper(result):
# if result in d:
# return d[result]
# node = result.owner
# if node is None: # result is an orphan
# if copy_inputs_and_orphans:
# cpy = result.clone()
# d[result] = cpy
# else:
# d[result] = result
# return d[result]
# else:
# new_node = node.clone_with_new_inputs([clone_helper(input) for input in node.inputs])
# d[node] = new_node
# for output, new_output in zip(node.outputs, new_node.outputs):
# d[output] = new_output
# return d[result]
#
# for output in o:
# clone_helper(output)
#
# return d
# def clone_with_new_inputs(i, o, new_i):
# equiv = clone_with_new_inputs_get_equiv(i, o, new_i)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论