Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c0f5f811
提交
c0f5f811
authored
9月 27, 2011
作者:
delallea
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #67 from nouiz/list_cache
Added "theano-cache list" to list the content of the theano cache
上级
d309a022
6e441bfe
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
49 行增加
和
3 行删除
+49
-3
theano-cache
bin/theano-cache
+4
-1
compiledir.py
theano/gof/compiledir.py
+45
-2
没有找到文件。
bin/theano-cache
浏览文件 @
c0f5f811
#!/usr/bin/env python
#!/usr/bin/env python
import
logging
,
os
,
sys
import
logging
,
os
,
sys
import
theano
from
theano
import
config
from
theano
import
config
from
theano.gof.cc
import
get_module_cache
from
theano.gof.cc
import
get_module_cache
...
@@ -25,10 +26,12 @@ elif sys.argv[1] in ('clear'):
...
@@ -25,10 +26,12 @@ elif sys.argv[1] in ('clear'):
config
.
compiledir
)
config
.
compiledir
)
_logger
.
debug
(
'Remaining elements (
%
s):
%
s'
%
_logger
.
debug
(
'Remaining elements (
%
s):
%
s'
%
(
len
(
items
),
', '
.
join
(
items
)))
(
len
(
items
),
', '
.
join
(
items
)))
elif
sys
.
argv
[
1
]
in
(
'list'
):
theano
.
gof
.
compiledir
.
print_compiledir_content
()
else
:
else
:
print
'command "
%
s" not recognized'
%
sys
.
argv
[
1
]
print
'command "
%
s" not recognized'
%
sys
.
argv
[
1
]
print
'Type "theano-cache" to print the cache location'
print
'Type "theano-cache" to print the cache location'
print
'Type "theano-cache clear" to erase the cache'
print
'Type "theano-cache clear" to erase the cache'
print
'Type "theano-cache list" to print the cache content'
sys
.
exit
(
1
)
sys
.
exit
(
1
)
theano/gof/compiledir.py
浏览文件 @
c0f5f811
import
cPickle
import
errno
import
errno
import
os
,
sys
import
os
import
platform
import
platform
import
re
import
re
import
theano
from
theano.configparser
import
config
,
AddConfigVar
,
ConfigParam
,
StrParam
from
theano.configparser
import
config
,
AddConfigVar
,
ConfigParam
,
StrParam
def
default_compiledirname
():
def
default_compiledirname
():
platform_id
=
'-'
.
join
([
platform_id
=
'-'
.
join
([
platform
.
platform
(),
platform
.
platform
(),
...
@@ -25,7 +28,7 @@ def filter_compiledir(path):
...
@@ -25,7 +28,7 @@ def filter_compiledir(path):
valid
=
True
valid
=
True
if
not
os
.
access
(
path
,
os
.
R_OK
|
os
.
W_OK
):
if
not
os
.
access
(
path
,
os
.
R_OK
|
os
.
W_OK
):
try
:
try
:
os
.
makedirs
(
path
,
0770
)
#
read-write-execute for user and group
os
.
makedirs
(
path
,
0770
)
#
read-write-execute for user and group
except
OSError
,
e
:
except
OSError
,
e
:
# Maybe another parallel execution of theano was trying to create
# Maybe another parallel execution of theano was trying to create
# the same directory at the same time.
# the same directory at the same time.
...
@@ -59,3 +62,43 @@ AddConfigVar('compiledir',
...
@@ -59,3 +62,43 @@ AddConfigVar('compiledir',
default_compiledirname
()),
default_compiledirname
()),
filter
=
filter_compiledir
,
filter
=
filter_compiledir
,
allow_override
=
False
))
allow_override
=
False
))
def
print_compiledir_content
():
def
flatten
(
a
):
if
isinstance
(
a
,
(
tuple
,
list
,
set
)):
l
=
[]
for
item
in
a
:
l
.
extend
(
flatten
(
item
))
return
l
else
:
return
[
a
]
compiledir
=
theano
.
config
.
compiledir
print
"List compiled ops in this theano cache:"
,
compiledir
print
"sub directory/Op/Associated Type"
print
table
=
[]
for
dir
in
os
.
listdir
(
compiledir
):
file
=
None
try
:
try
:
file
=
open
(
os
.
path
.
join
(
compiledir
,
dir
,
"key.pkl"
))
keydata
=
cPickle
.
load
(
file
)
ops
=
list
(
set
([
x
for
x
in
flatten
(
keydata
.
keys
)
if
isinstance
(
x
,
theano
.
gof
.
Op
)]))
assert
len
(
ops
)
==
1
types
=
list
(
set
([
x
for
x
in
flatten
(
keydata
.
keys
)
if
isinstance
(
x
,
theano
.
gof
.
Type
)]))
table
.
append
((
dir
,
ops
[
0
],
types
))
except
IOError
:
pass
finally
:
if
file
is
not
None
:
file
.
close
()
table
=
sorted
(
table
,
key
=
lambda
t
:
str
(
t
[
1
]))
for
dir
,
op
,
types
in
table
:
print
dir
,
op
,
types
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论