Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9cb4e9f3
提交
9cb4e9f3
authored
9月 16, 2012
作者:
Ian Goodfellow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
doc and cleaned up error handling
上级
492653e9
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
26 行增加
和
2 行删除
+26
-2
destroyhandler.py
theano/gof/destroyhandler.py
+26
-2
没有找到文件。
theano/gof/destroyhandler.py
浏览文件 @
9cb4e9f3
...
@@ -641,12 +641,36 @@ class IncrementalDestroyHandler(toolbox.Bookkeeper):
...
@@ -641,12 +641,36 @@ class IncrementalDestroyHandler(toolbox.Bookkeeper):
self
.
do_imports_on_attach
=
do_imports_on_attach
self
.
do_imports_on_attach
=
do_imports_on_attach
def
on_attach
(
self
,
fgraph
):
def
on_attach
(
self
,
fgraph
):
#boilerplate from old implementation
"""
When attaching to a new fgraph, check that
1) This DestroyHandler wasn't already attached to some fgraph
(its data structures are only set up to serve one)
2) The FunctionGraph doesn't already have a DestroyHandler.
This would result in it validating everything twice, causing
compilation to be slower.
Give the FunctionGraph instance:
1) A new method "destroyers(var)"
TODO: what does this do exactly?
2) A new attribute, "destroy_handler"
TODO: WRITEME: what does this do besides the checks?
"""
####### Do the checking ###########
already_there
=
False
if
self
.
fgraph
is
fgraph
:
already_there
=
True
if
self
.
fgraph
is
not
None
:
if
self
.
fgraph
is
not
None
:
raise
Exception
(
"A DestroyHandler instance can only serve one FunctionGraph. (Matthew 6:24)"
)
raise
Exception
(
"A DestroyHandler instance can only serve one FunctionGraph. (Matthew 6:24)"
)
for
attr
in
(
'destroyers'
,
'destroy_handler'
):
for
attr
in
(
'destroyers'
,
'destroy_handler'
):
if
hasattr
(
fgraph
,
attr
):
if
hasattr
(
fgraph
,
attr
):
raise
toolbox
.
AlreadyThere
(
"DestroyHandler feature is already present or in conflict with another plugin."
)
already_there
=
True
if
already_there
:
# FunctionGraph.attach_feature catches AlreadyThere and cancels the attachment
raise
toolbox
.
AlreadyThere
(
"DestroyHandler feature is already present or in conflict with another plugin."
)
####### Annotate the FunctionGraph ############
def
get_destroyers_of
(
r
):
def
get_destroyers_of
(
r
):
droot
,
impact
,
root_destroyer
=
self
.
refresh_droot_impact
()
droot
,
impact
,
root_destroyer
=
self
.
refresh_droot_impact
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论