Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6a57a3a0
提交
6a57a3a0
authored
1月 03, 2021
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
1月 09, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename theano.gof.graph.ops to applys_between
上级
af03b72f
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
17 行增加
和
18 行删除
+17
-18
test_graph.py
tests/gof/test_graph.py
+2
-2
test_elemwise.py
tests/tensor/test_elemwise.py
+1
-1
test_extra_ops.py
tests/tensor/test_extra_ops.py
+7
-4
fg.py
theano/gof/fg.py
+2
-3
graph.py
theano/gof/graph.py
+2
-2
opt.py
theano/gof/opt.py
+2
-2
opt.py
theano/gpuarray/opt.py
+1
-1
basic.py
theano/scalar/basic.py
+0
-3
没有找到文件。
tests/gof/test_graph.py
浏览文件 @
6a57a3a0
...
...
@@ -9,6 +9,7 @@ from theano.gof.graph import (
Apply
,
Variable
,
ancestors
,
applys_between
,
as_string
,
clone
,
equal_computations
,
...
...
@@ -17,7 +18,6 @@ from theano.gof.graph import (
io_toposort
,
is_in_ancestors
,
list_of_nodes
,
ops
,
orphans
,
variables
,
walk
,
...
...
@@ -424,7 +424,7 @@ def test_ops():
o3
=
MyOp
(
r3
,
o1
,
o2
)
o3
.
name
=
"o3"
res
=
ops
([
r1
,
r2
],
[
o3
])
res
=
applys_between
([
r1
,
r2
],
[
o3
])
res_list
=
list
(
res
)
assert
res_list
==
[
o3
.
owner
,
o2
.
owner
,
o1
.
owner
]
...
...
tests/tensor/test_elemwise.py
浏览文件 @
6a57a3a0
...
...
@@ -1349,7 +1349,7 @@ def test_grad_useless_sum():
TensorType
.
values_eq_approx
=
old_values_eq_approx
assert
not
any
(
[
isinstance
(
node
.
op
,
Sum
)
for
node
in
theano
.
gof
.
graph
.
ops
([
x
],
[
g
])]
[
isinstance
(
node
.
op
,
Sum
)
for
node
in
theano
.
gof
.
graph
.
applys_between
([
x
],
[
g
])]
)
assert
np
.
allclose
(
outputs
,
[[
-
3.72007598e-44
],
[
-
0.26894142
],
[
-
0.5
],
[
-
0.73105858
],
[
-
1.0
]]
...
...
tests/tensor/test_extra_ops.py
浏览文件 @
6a57a3a0
...
...
@@ -6,7 +6,7 @@ from tests import unittest_tools as utt
from
theano
import
function
from
theano
import
tensor
as
tt
from
theano.configdefaults
import
config
from
theano.gof.graph
import
ops
as
graph_ops
from
theano.gof.graph
import
applys_between
from
theano.tensor.extra_ops
import
(
Bartlett
,
BroadcastTo
,
...
...
@@ -1221,7 +1221,8 @@ def test_broadcast_shape():
arrays_are_shapes
=
True
,
)
assert
any
(
isinstance
(
node
.
op
,
tt
.
opt
.
Assert
)
for
node
in
graph_ops
([
x_tt
,
y_tt
],
b_tt
)
isinstance
(
node
.
op
,
tt
.
opt
.
Assert
)
for
node
in
applys_between
([
x_tt
,
y_tt
],
b_tt
)
)
assert
np
.
array_equal
([
z
.
eval
()
for
z
in
b_tt
],
b
.
shape
)
b_tt
=
broadcast_shape
(
shape_tuple
(
x_tt
),
shape_tuple
(
y_tt
),
arrays_are_shapes
=
True
)
...
...
@@ -1229,7 +1230,8 @@ def test_broadcast_shape():
# These are all constants, so there shouldn't be any asserts in the
# resulting graph.
assert
not
any
(
isinstance
(
node
.
op
,
tt
.
opt
.
Assert
)
for
node
in
graph_ops
([
x_tt
,
y_tt
],
b_tt
)
isinstance
(
node
.
op
,
tt
.
opt
.
Assert
)
for
node
in
applys_between
([
x_tt
,
y_tt
],
b_tt
)
)
x
=
np
.
array
([
1
,
2
,
3
])
...
...
@@ -1257,7 +1259,8 @@ def test_broadcast_shape():
assert
b_tt
[
0
]
.
value
==
1
assert
np
.
array_equal
([
z
.
eval
()
for
z
in
b_tt
],
b
.
shape
)
assert
not
any
(
isinstance
(
node
.
op
,
tt
.
opt
.
Assert
)
for
node
in
graph_ops
([
x_tt
,
y_tt
],
b_tt
)
isinstance
(
node
.
op
,
tt
.
opt
.
Assert
)
for
node
in
applys_between
([
x_tt
,
y_tt
],
b_tt
)
)
b_tt
=
broadcast_shape
(
shape_tuple
(
x_tt
),
shape_tuple
(
y_tt
),
arrays_are_shapes
=
True
)
assert
np
.
array_equal
([
z
.
eval
()
for
z
in
b_tt
],
b
.
shape
)
...
...
theano/gof/fg.py
浏览文件 @
6a57a3a0
...
...
@@ -6,11 +6,10 @@ from io import StringIO
import
theano
from
theano.configdefaults
import
config
from
theano.gof
import
toolbox
,
utils
from
theano.gof.graph
import
Apply
,
Constant
,
Variable
from
theano.gof.graph
import
Apply
,
Constant
,
Variable
,
applys_between
from
theano.gof.graph
import
as_string
as
graph_as_string
from
theano.gof.graph
import
clone
as
clone_graph
from
theano.gof.graph
import
clone_get_equiv
,
io_toposort
from
theano.gof.graph
import
ops
as
ops_between
from
theano.gof.graph
import
variables
as
variables_between
from
theano.gof.utils
import
TestValueError
,
get_variable_trace_string
from
theano.misc.ordered_set
import
OrderedSet
...
...
@@ -710,7 +709,7 @@ class FunctionGraph(utils.MetaObject):
Call this for a diagnosis if things go awry.
"""
nodes
=
set
(
op
s_between
(
self
.
inputs
,
self
.
outputs
))
nodes
=
set
(
apply
s_between
(
self
.
inputs
,
self
.
outputs
))
if
self
.
apply_nodes
!=
nodes
:
missing
=
nodes
.
difference
(
self
.
apply_nodes
)
excess
=
self
.
apply_nodes
.
difference
(
nodes
)
...
...
theano/gof/graph.py
浏览文件 @
6a57a3a0
...
...
@@ -838,7 +838,7 @@ def orphans(
yield
from
(
r
for
r
in
variables
(
ins
,
outs
)
if
r
.
owner
is
None
and
r
not
in
ins
)
def
ops
(
def
applys_between
(
ins
:
Collection
[
Variable
],
outs
:
Iterable
[
Variable
]
)
->
Generator
[
Apply
,
None
,
None
]:
"""Extract the `Apply`s contained within the sub-graph between given input and output variables.
...
...
@@ -1291,7 +1291,7 @@ def as_string(
multi
.
add
(
op
)
else
:
seen
.
add
(
op
)
for
op
in
ops
(
i
,
outputs
):
for
op
in
applys_between
(
i
,
outputs
):
for
input
in
op
.
inputs
:
op2
=
input
.
owner
if
input
in
i
or
input
in
orph
or
op2
is
None
:
...
...
theano/gof/opt.py
浏览文件 @
6a57a3a0
...
...
@@ -1341,7 +1341,7 @@ class LocalOptGroup(LocalOptimizer):
new_vars
=
list
(
new_repl
.
values
())
if
self
.
profile
:
self
.
node_created
[
opt
]
+=
len
(
list
(
graph
.
ops
(
fgraph
.
variables
,
new_vars
))
list
(
graph
.
applys_between
(
fgraph
.
variables
,
new_vars
))
)
self
.
applied_true
[
opt
]
+=
1
break
# break from the for loop over optimization.
...
...
@@ -1453,7 +1453,7 @@ class GraphToGPULocalOptGroup(LocalOptGroup):
continue
if
self
.
profile
:
self
.
node_created
[
opt
]
+=
len
(
list
(
graph
.
ops
(
fgraph
.
variables
,
new_repl
))
list
(
graph
.
applys_between
(
fgraph
.
variables
,
new_repl
))
)
self
.
applied_true
[
opt
]
+=
1
...
...
theano/gpuarray/opt.py
浏览文件 @
6a57a3a0
...
...
@@ -397,7 +397,7 @@ class GraphToGPU(GlobalOptimizer):
if
new_ops
:
node_created
[
lopt
]
+=
len
(
graph
.
ops
([
mapping
[
i
]
for
i
in
node
.
inputs
],
outputs
)
graph
.
applys_between
([
mapping
[
i
]
for
i
in
node
.
inputs
],
outputs
)
)
if
any
(
[
...
...
theano/scalar/basic.py
浏览文件 @
6a57a3a0
...
...
@@ -4154,9 +4154,6 @@ class Composite(ScalarOp):
assert
len
(
res
[
0
])
==
len
(
inputs
)
assert
res
[
0
]
!=
inputs
inputs
,
outputs
=
res
[
0
],
res2
[
1
]
# Next assert comment just for speed
# assert not any([isinstance(node.op, Composite) for node in
# ops(inputs, outputs)])
self
.
inputs
=
copy
(
inputs
)
self
.
outputs
=
copy
(
outputs
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论