Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b2570e99
提交
b2570e99
authored
2月 06, 2015
作者:
Pierre Luc Carrier
提交者:
Pierre Luc Carrier
2月 16, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update and move Feature accoding to feedback
上级
13056b2f
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
26 行增加
和
23 行删除
+26
-23
__init__.py
theano/gof/__init__.py
+2
-2
destroyhandler.py
theano/gof/destroyhandler.py
+0
-21
toolbox.py
theano/gof/toolbox.py
+24
-0
没有找到文件。
theano/gof/__init__.py
浏览文件 @
b2570e99
...
@@ -46,7 +46,7 @@ from theano.gof.fg import \
...
@@ -46,7 +46,7 @@ from theano.gof.fg import \
CachedConstantError
,
InconsistencyError
,
MissingInputError
,
FunctionGraph
CachedConstantError
,
InconsistencyError
,
MissingInputError
,
FunctionGraph
from
theano.gof.destroyhandler
import
\
from
theano.gof.destroyhandler
import
\
DestroyHandler
,
NoOutputFromInplace
DestroyHandler
from
theano.gof.graph
import
\
from
theano.gof.graph
import
\
Apply
,
Variable
,
Constant
,
view_roots
Apply
,
Variable
,
Constant
,
view_roots
...
@@ -74,7 +74,7 @@ from theano.gof.optdb import \
...
@@ -74,7 +74,7 @@ from theano.gof.optdb import \
from
theano.gof.toolbox
import
\
from
theano.gof.toolbox
import
\
Feature
,
\
Feature
,
\
Bookkeeper
,
History
,
Validator
,
ReplaceValidate
,
NodeFinder
,
\
Bookkeeper
,
History
,
Validator
,
ReplaceValidate
,
NodeFinder
,
\
PrintListener
,
ReplacementDidntRemovedError
PrintListener
,
ReplacementDidntRemovedError
,
NoOutputFromInplace
from
theano.gof.type
import
\
from
theano.gof.type
import
\
Type
,
Generic
,
generic
Type
,
Generic
,
generic
...
...
theano/gof/destroyhandler.py
浏览文件 @
b2570e99
...
@@ -7,7 +7,6 @@ import toolbox
...
@@ -7,7 +7,6 @@ import toolbox
import
graph
import
graph
from
theano.gof.python25
import
deque
from
theano.gof.python25
import
deque
from
theano.gof.python25
import
OrderedDict
from
theano.gof.python25
import
OrderedDict
from
theano.gof.toolbox
import
Feature
from
theano.misc.ordered_set
import
OrderedSet
from
theano.misc.ordered_set
import
OrderedSet
from
fg
import
InconsistencyError
from
fg
import
InconsistencyError
...
@@ -1027,23 +1026,3 @@ class DestroyHandler(toolbox.Bookkeeper):
...
@@ -1027,23 +1026,3 @@ class DestroyHandler(toolbox.Bookkeeper):
rval
[
app
]
=
root_clients
rval
[
app
]
=
root_clients
return
rval
return
rval
class
NoOutputFromInplace
(
Feature
):
def
__init__
(
self
):
pass
def
validate
(
self
,
fgraph
):
if
not
hasattr
(
fgraph
,
'destroyers'
):
return
True
for
out
in
list
(
fgraph
.
outputs
):
# Validate that the node that produces the output does not produce
# it by modifying something else inplace.
node
=
out
.
owner
op
=
node
.
op
out_idx
=
node
.
outputs
.
index
(
out
)
if
hasattr
(
op
,
'destroy_map'
)
and
out_idx
in
op
.
destroy_map
.
keys
():
raise
InconsistencyError
(
"Trying to produce an output "
,
out
,
" by modifying another variable inplace"
)
theano/gof/toolbox.py
浏览文件 @
b2570e99
import
sys
import
sys
import
time
import
time
import
theano
from
theano
import
config
from
theano
import
config
from
theano.gof.python25
import
partial
from
theano.gof.python25
import
partial
from
theano.gof.python25
import
OrderedDict
from
theano.gof.python25
import
OrderedDict
...
@@ -394,3 +395,26 @@ class PreserveNames(Feature):
...
@@ -394,3 +395,26 @@ class PreserveNames(Feature):
new_r
.
name
=
r
.
name
new_r
.
name
=
r
.
name
class
NoOutputFromInplace
(
Feature
):
def
validate
(
self
,
fgraph
):
if
not
hasattr
(
fgraph
,
'destroyers'
):
return
True
for
out
in
list
(
fgraph
.
outputs
):
if
out
.
owner
is
None
:
continue
# Validate that the node that produces the output does not produce
# it by modifying something else inplace.
node
=
out
.
owner
op
=
node
.
op
out_idx
=
node
.
outputs
.
index
(
out
)
if
hasattr
(
op
,
'destroy_map'
)
and
out_idx
in
op
.
destroy_map
.
keys
():
raise
theano
.
gof
.
InconsistencyError
(
"A function graph Feature has requested (probably for "
,
"efficiency reasons for scan) that outputs of the graph"
,
"be prevented from being the result of inplace "
,
"operations. This has prevented output "
,
out
,
" from "
,
"being the computed by modifying another variable "
,
"inplace."
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论