Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
61da262e
提交
61da262e
authored
5月 23, 2012
作者:
nouiz
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #649 from abergeron/cvm_gc
Add gc to CVM
上级
6a4a598b
05f3bfcb
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
39 行增加
和
15 行删除
+39
-15
lazylinker_c.c.txt
theano/gof/lazylinker_c.c.txt
+0
-0
lazylinker_c.py
theano/gof/lazylinker_c.py
+1
-1
vm.py
theano/gof/vm.py
+38
-14
没有找到文件。
theano/gof/lazylinker_c.c.txt
浏览文件 @
61da262e
差异被折叠。
点击展开。
theano/gof/lazylinker_c.py
浏览文件 @
61da262e
...
...
@@ -13,7 +13,7 @@ if config.compiledir not in sys.path:
sys
.
path
.
append
(
config
.
compiledir
)
force_compile
=
False
version
=
0.1
3
# must match constant returned in function get_version()
version
=
0.1
4
# must match constant returned in function get_version()
try
:
...
...
theano/gof/vm.py
浏览文件 @
61da262e
...
...
@@ -184,9 +184,8 @@ class Stack(VM):
"""
def
__init__
(
self
,
nodes
,
thunks
,
pre_call_clear
,
storage_map
,
compute_map
,
env
,
allow_gc
,
callback
=
None
):
storage_map
,
compute_map
,
env
,
allow_gc
,
dependencies
=
None
,
callback
=
None
):
super
(
Stack
,
self
)
.
__init__
(
nodes
,
thunks
,
pre_call_clear
)
self
.
allow_gc
=
allow_gc
...
...
@@ -211,16 +210,11 @@ class Stack(VM):
for
prereq
in
ords
[
node
]:
node
.
destroy_dependencies
+=
prereq
.
outputs
dependencies
=
self
.
dependencies
=
{}
for
k
in
storage_map
:
dependencies
[
k
]
=
[]
if
k
.
owner
and
k
.
clients
:
ls
=
[]
is_output
=
0
for
cl
in
k
.
clients
:
if
cl
[
0
]
is
not
'output'
:
ls
+=
cl
[
0
]
.
outputs
dependencies
[
k
]
+=
ls
self
.
dependencies
=
dependencies
if
self
.
allow_gc
and
self
.
dependencies
is
None
:
raise
ValueError
(
"Must set dependencies when using GC"
)
if
config
.
profile
:
self
.
memory_size_map
=
{
"nt8"
:
1
,
"t16"
:
2
,
"t32"
:
4
,
"t64"
:
8
,
"128"
:
16
}
...
...
@@ -454,6 +448,19 @@ class VM_Linker(link.LocalLinker):
# admittedly confusing, and it could use some cleaning up. The base
# Linker object should probably go away completely.
def
compute_gc_dependencies
(
self
,
smap
):
dependencies
=
{}
for
k
in
smap
:
dependencies
[
k
]
=
[]
if
k
.
owner
and
k
.
clients
:
ls
=
[]
is_output
=
0
for
cl
in
k
.
clients
:
if
cl
[
0
]
is
not
'output'
:
ls
+=
cl
[
0
]
.
outputs
dependencies
[
k
]
+=
ls
return
dependencies
def
make_vm
(
self
,
nodes
,
thunks
,
input_storage
,
output_storage
,
storage_map
,
post_thunk_clear
,
...
...
@@ -467,10 +474,14 @@ class VM_Linker(link.LocalLinker):
if
self
.
callback
is
not
None
:
if
self
.
use_cloop
:
logger
.
warn
(
'CLoop does not support callback, using Stack VM.'
)
deps
=
None
if
self
.
allow_gc
:
deps
=
self
.
compute_gc_dependencies
(
storage_map
)
vm
=
Stack
(
nodes
,
thunks
,
pre_call_clear
,
storage_map
,
compute_map
,
self
.
env
,
self
.
allow_gc
,
dependencies
=
deps
,
callback
=
self
.
callback
)
elif
self
.
use_cloop
:
# create a map from nodes to ints and vars to ints
...
...
@@ -500,6 +511,14 @@ class VM_Linker(link.LocalLinker):
assert
type
(
storage_map_list
[
0
])
is
list
assert
type
(
compute_map_list
[
0
])
is
list
if
self
.
allow_gc
:
dependency_map
=
self
.
compute_gc_dependencies
(
storage_map
)
dependency_map_list
=
[
[
vars_idx
[
d
]
for
d
in
dependency_map
[
vars_idx_inv
[
i
]]]
for
i
in
xrange
(
len
(
vars_idx_inv
))]
else
:
dependency_map_list
=
None
# build the pointers to node inputs and offsets
base_input_output_list
=
[]
node_n_inputs
=
[]
...
...
@@ -566,6 +585,7 @@ class VM_Linker(link.LocalLinker):
node_prereqs
=
node_prereqs
,
node_output_size
=
node_output_size
,
update_storage
=
update_storage
,
dependencies
=
dependency_map_list
,
)
assert
c0
==
sys
.
getrefcount
(
node_n_inputs
)
else
:
...
...
@@ -583,10 +603,14 @@ class VM_Linker(link.LocalLinker):
thunks
,
pre_call_clear
)
else
:
deps
=
None
if
self
.
allow_gc
:
deps
=
self
.
compute_gc_dependencies
(
storage_map
)
vm
=
Stack
(
nodes
,
thunks
,
pre_call_clear
,
storage_map
,
compute_map
,
self
.
env
,
self
.
allow_gc
self
.
env
,
self
.
allow_gc
,
dependencies
=
deps
)
return
vm
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论