Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
25b4ef98
提交
25b4ef98
authored
6月 14, 2011
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid double refresh of cache when running 'theano-cache clear'
上级
c7ca7e51
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
31 行增加
和
10 行删除
+31
-10
theano-cache
bin/theano-cache
+5
-4
cc.py
theano/gof/cc.py
+6
-2
cmodule.py
theano/gof/cmodule.py
+20
-4
没有找到文件。
bin/theano-cache
浏览文件 @
25b4ef98
...
...
@@ -6,10 +6,11 @@ from theano.gof.cc import get_module_cache
if
len
(
sys
.
argv
)
==
1
:
print
config
.
compiledir
elif
sys
.
argv
[
1
]
in
(
'clear'
):
# TODO Note that there is a double refresh when running the line below, it
# should be optimized to refresh the cache only once.
get_module_cache
()
.
clear
(
unversioned_min_age
=-
1
,
clear_base_files
=
True
,
delete_if_problem
=
True
)
# We skip the refresh on module cache creation because the refresh will
# be done when calling clear afterwards.
cache
=
get_module_cache
(
init_args
=
dict
(
do_refresh
=
False
))
cache
.
clear
(
unversioned_min_age
=-
1
,
clear_base_files
=
True
,
delete_if_problem
=
True
)
else
:
print
'command "
%
s" not recognized'
%
sys
.
argv
[
1
]
print
'Type "theano-cache" to print the cache location'
...
...
theano/gof/cc.py
浏览文件 @
25b4ef98
...
...
@@ -63,8 +63,12 @@ def error(*args):
from
theano.gof.callcache
import
CallCache
def
get_module_cache
():
return
cmodule
.
get_module_cache
(
config
.
compiledir
)
def
get_module_cache
(
init_args
=
None
):
"""
:param init_args: If not None, the (k, v) pairs in this dictionary will
be forwarded to the ModuleCache constructor as keyword arguments.
"""
return
cmodule
.
get_module_cache
(
config
.
compiledir
,
init_args
=
init_args
)
_persistent_module_cache
=
None
def
get_persistent_module_cache
():
...
...
theano/gof/cmodule.py
浏览文件 @
25b4ef98
...
...
@@ -427,11 +427,15 @@ class ModuleCache(object):
"""set of all key.pkl files that have been loaded.
"""
def
__init__
(
self
,
dirname
,
force_fresh
=
None
,
check_for_broken_eq
=
True
):
def
__init__
(
self
,
dirname
,
force_fresh
=
None
,
check_for_broken_eq
=
True
,
do_refresh
=
True
):
"""
:param check_for_broken_eq: A bad __eq__ implemenation can break this cache mechanism.
This option turns on a not-too-expensive sanity check during the load of an old cache
file.
:param do_refresh: If True, then the ``refresh`` method will be called
in the constructor.
"""
self
.
dirname
=
dirname
self
.
module_from_name
=
dict
(
self
.
module_from_name
)
...
...
@@ -443,7 +447,8 @@ class ModuleCache(object):
self
.
force_fresh
=
force_fresh
self
.
loaded_key_pkl
=
set
()
self
.
refresh
()
if
do_refresh
:
self
.
refresh
()
start
=
time
.
time
()
if
check_for_broken_eq
:
...
...
@@ -566,6 +571,7 @@ class ModuleCache(object):
# This exception is often triggered by keys that contain
# references to classes that have not yet been imported. They are
# not necessarily broken.
# TODO But is there a reason to keep them?
pass
continue
...
...
@@ -1111,11 +1117,21 @@ def _rmtree(parent, ignore_nocleanup=False, msg='', level='debug',
warning
(
'Failed to remove or mark cache directory
%
s for removal'
%
parent
,
ee
)
_module_cache
=
None
def
get_module_cache
(
dirname
,
force_fresh
=
None
):
def
get_module_cache
(
dirname
,
force_fresh
=
None
,
init_args
=
None
):
"""
:param init_args: If not None, the (k, v) pairs in this dictionary will
be forwarded to the ModuleCache constructor as keyword arguments.
"""
global
_module_cache
if
init_args
is
None
:
init_args
=
{}
if
_module_cache
is
None
:
_module_cache
=
ModuleCache
(
dirname
,
force_fresh
=
force_fresh
)
_module_cache
=
ModuleCache
(
dirname
,
force_fresh
=
force_fresh
,
**
init_args
)
atexit
.
register
(
_module_cache
.
_on_atexit
)
elif
init_args
:
warning
(
'Ignoring init arguments for module cache because it was '
'created prior to this call'
)
if
_module_cache
.
dirname
!=
dirname
:
warning
(
"Returning module cache instance with different dirname than you requested"
)
return
_module_cache
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论