Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
8c6c7500
提交
8c6c7500
authored
7月 20, 2015
作者:
Iban Harlouchet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
flake8 for theano/gof/tests/test_opt.py
上级
fc7be5b4
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
13 行增加
和
7 行删除
+13
-7
test_opt.py
theano/gof/tests/test_opt.py
+13
-7
没有找到文件。
theano/gof/tests/test_opt.py
浏览文件 @
8c6c7500
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
from
theano.gof.type
import
Type
from
theano.gof.type
import
Type
from
theano.gof.graph
import
Variable
,
Apply
,
Constant
from
theano.gof.graph
import
Variable
,
Apply
,
Constant
from
theano.gof.op
import
Op
from
theano.gof.op
import
Op
from
theano.gof.opt
import
*
from
theano.gof.opt
import
*
# noqa
from
theano.gof.fg
import
FunctionGraph
as
Env
from
theano.gof.fg
import
FunctionGraph
as
Env
from
theano.gof.toolbox
import
*
from
theano.gof.toolbox
import
*
# noqa
def
as_variable
(
x
):
def
as_variable
(
x
):
...
@@ -53,7 +53,7 @@ class MyOp(Op):
...
@@ -53,7 +53,7 @@ class MyOp(Op):
return
self
.
name
return
self
.
name
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
#rval = (self is other) or (isinstance(other, MyOp) and self.x is not None and self.x == other.x and self.name == other.name)
#
rval = (self is other) or (isinstance(other, MyOp) and self.x is not None and self.x == other.x and self.name == other.name)
rval
=
(
self
is
other
)
or
(
isinstance
(
other
,
MyOp
)
and
self
.
x
is
not
None
and
self
.
x
==
other
.
x
)
rval
=
(
self
is
other
)
or
(
isinstance
(
other
,
MyOp
)
and
self
.
x
is
not
None
and
self
.
x
==
other
.
x
)
return
rval
return
rval
...
@@ -84,8 +84,12 @@ def inputs():
...
@@ -84,8 +84,12 @@ def inputs():
return
x
,
y
,
z
return
x
,
y
,
z
PatternOptimizer
=
lambda
p1
,
p2
,
ign
=
False
:
OpKeyOptimizer
(
PatternSub
(
p1
,
p2
),
ignore_newtrees
=
ign
)
def
PatternOptimizer
(
p1
,
p2
,
ign
=
False
):
TopoPatternOptimizer
=
lambda
p1
,
p2
,
ign
=
True
:
TopoOptimizer
(
PatternSub
(
p1
,
p2
),
ignore_newtrees
=
ign
)
return
OpKeyOptimizer
(
PatternSub
(
p1
,
p2
),
ignore_newtrees
=
ign
)
def
TopoPatternOptimizer
(
p1
,
p2
,
ign
=
True
):
return
TopoOptimizer
(
PatternSub
(
p1
,
p2
),
ignore_newtrees
=
ign
)
class
TestPatternOptimizer
:
class
TestPatternOptimizer
:
...
@@ -205,6 +209,7 @@ class TestPatternOptimizer:
...
@@ -205,6 +209,7 @@ class TestPatternOptimizer:
x
,
y
,
z
=
inputs
()
x
,
y
,
z
=
inputs
()
e
=
op4
(
op1
(
op2
(
x
,
y
)),
op1
(
op1
(
x
,
y
)))
e
=
op4
(
op1
(
op2
(
x
,
y
)),
op1
(
op1
(
x
,
y
)))
g
=
Env
([
x
,
y
,
z
],
[
e
])
g
=
Env
([
x
,
y
,
z
],
[
e
])
def
constraint
(
r
):
def
constraint
(
r
):
# Only replacing if the input is an instance of Op2
# Only replacing if the input is an instance of Op2
return
r
.
owner
.
op
==
op2
return
r
.
owner
.
op
==
op2
...
@@ -225,6 +230,7 @@ class TestPatternOptimizer:
...
@@ -225,6 +230,7 @@ class TestPatternOptimizer:
x
,
y
,
z
=
inputs
()
x
,
y
,
z
=
inputs
()
e
=
op2
(
op1
(
x
,
x
),
op1
(
x
,
y
))
e
=
op2
(
op1
(
x
,
x
),
op1
(
x
,
y
))
g
=
Env
([
x
,
y
,
z
],
[
e
])
g
=
Env
([
x
,
y
,
z
],
[
e
])
def
constraint
(
r
):
def
constraint
(
r
):
# Only replacing if the input is an instance of Op2
# Only replacing if the input is an instance of Op2
return
r
.
owner
.
inputs
[
0
]
is
not
r
.
owner
.
inputs
[
1
]
return
r
.
owner
.
inputs
[
0
]
is
not
r
.
owner
.
inputs
[
1
]
...
@@ -263,8 +269,8 @@ class TestPatternOptimizer:
...
@@ -263,8 +269,8 @@ class TestPatternOptimizer:
# assert str(g) == "[Op3(x, y)]"
# assert str(g) == "[Op3(x, y)]"
OpSubOptimizer
=
lambda
op1
,
op2
:
TopoOptimizer
(
OpSub
(
op1
,
op2
))
def
OpSubOptimizer
(
op1
,
op2
):
OpSubOptimizer
=
lambda
op1
,
op2
:
OpKeyOptimizer
(
OpSub
(
op1
,
op2
))
return
OpKeyOptimizer
(
OpSub
(
op1
,
op2
))
class
TestOpSubOptimizer
:
class
TestOpSubOptimizer
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论