Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6c0556bc
提交
6c0556bc
authored
3月 14, 2008
作者:
bergstrj@iro.umontreal.ca
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed unreachable input bug with flag to graph.results_and_orphans
上级
affde532
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
29 行增加
和
4 行删除
+29
-4
_test_graph.py
gof/_test_graph.py
+12
-0
_test_link.py
gof/_test_link.py
+8
-3
env.py
gof/env.py
+1
-0
graph.py
gof/graph.py
+8
-1
没有找到文件。
gof/_test_graph.py
浏览文件 @
6c0556bc
...
...
@@ -58,6 +58,18 @@ class _test_orphans(unittest.TestCase):
op
=
MyOp
(
r1
,
r2
)
op2
=
MyOp
(
op
.
outputs
[
0
],
r5
)
assert
orphans
([
r1
,
r2
],
op2
.
outputs
)
==
set
([
r5
])
def
test_1
(
self
):
r1
,
r2
,
r5
=
MyResult
(
1
),
MyResult
(
2
),
MyResult
(
5
)
op
=
MyOp
(
r1
,
r2
)
op2
=
MyOp
(
op
.
outputs
[
0
],
r5
)
try
:
ro
=
results_and_orphans
([
r1
,
r2
,
op2
.
outputs
[
0
]],
op
.
outputs
,
True
)
self
.
fail
()
except
Exception
,
e
:
if
e
[
0
]
is
results_and_orphans
.
E_unreached
:
return
raise
class
_test_as_string
(
unittest
.
TestCase
):
...
...
gof/_test_link.py
浏览文件 @
6c0556bc
...
...
@@ -120,9 +120,7 @@ class _test_PerformLinker(unittest.TestCase):
a
,
d
=
add
(
x
,
y
),
div
(
x
,
y
)
e
=
mul
(
a
,
d
)
fn
=
perform_linker
(
env
([
x
,
a
],
[
e
]))
.
make_function
()
#perform linker should have recognized that one input is a function of
#the other one, which makes no sense
self
.
fail
(
'this graph should not have been compiled'
)
self
.
failUnless
(
fn
(
1.0
,
9.0
)
==
4.5
)
def
test_skiphole
(
self
):
x
,
y
,
z
=
inputs
()
...
...
@@ -132,6 +130,13 @@ class _test_PerformLinker(unittest.TestCase):
fn
=
perform_linker
(
env
([
x
,
y
,
r
],
[
e
]))
.
make_function
()
self
.
failUnless
(
fn
(
1.0
,
2.0
,
4.5
)
==
7.5
)
def
test_disconnected_input_output
(
self
):
x
,
y
,
z
=
inputs
()
a
=
add
(
x
,
y
)
fn
=
perform_linker
(
env
([
z
],
[
a
]))
.
make_function
()
self
.
failUnless
(
fn
(
1.0
)
==
3.0
)
self
.
failUnless
(
fn
(
2.0
)
==
3.0
)
if
__name__
==
'__main__'
:
...
...
gof/env.py
浏览文件 @
6c0556bc
...
...
@@ -378,6 +378,7 @@ class Env(graph.Graph):
listener
.
on_import
(
op
)
except
AbstractFunctionError
:
pass
__import__
.
E_output
=
'op output in Env.inputs'
def
__prune_r__
(
self
,
results
):
for
result
in
set
(
results
):
...
...
gof/graph.py
浏览文件 @
6c0556bc
...
...
@@ -39,7 +39,7 @@ def inputs(o):
return
results
def
results_and_orphans
(
i
,
o
):
def
results_and_orphans
(
i
,
o
,
warn_unreachable_input
=
False
):
"""
i -> list of input Results
o -> list of output Results
...
...
@@ -53,9 +53,11 @@ def results_and_orphans(i, o):
results
=
set
(
o
)
results
.
update
(
i
)
incomplete_paths
=
[]
reached
=
set
()
def
helper
(
r
,
path
):
if
r
in
i
:
reached
.
add
(
r
)
results
.
update
(
path
)
elif
r
.
owner
is
None
:
incomplete_paths
.
append
(
path
)
...
...
@@ -74,7 +76,12 @@ def results_and_orphans(i, o):
orphans
.
add
(
r
)
break
if
warn_unreachable_input
and
len
(
i
)
!=
len
(
reached
):
raise
Exception
(
results_and_orphans
.
E_unreached
)
return
results
,
orphans
results_and_orphans
.
E_unreached
=
'there were unreachable inputs'
def
ops
(
i
,
o
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论