提交 97b4c370 authored 作者: Frederic's avatar Frederic

Small modif following code review(doc, python 2.4 compatibility, import)

上级 30f8bbc8
...@@ -32,5 +32,6 @@ else: ...@@ -32,5 +32,6 @@ 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 containt'
sys.exit(1) sys.exit(1)
import cPickle
import errno import errno
import os import os
import platform import platform
...@@ -64,7 +65,6 @@ AddConfigVar('compiledir', ...@@ -64,7 +65,6 @@ AddConfigVar('compiledir',
def print_compiledir_content(): def print_compiledir_content():
import cPickle
def flatten(a): def flatten(a):
if isinstance(a, (tuple, list, set)): if isinstance(a, (tuple, list, set)):
...@@ -77,7 +77,7 @@ def print_compiledir_content(): ...@@ -77,7 +77,7 @@ def print_compiledir_content():
return [a] return [a]
compiledir = theano.config.compiledir compiledir = theano.config.compiledir
print "List compiled op in theano this cache", compiledir print "List compiled ops in this theano cache:", compiledir
print "sub directory/Op/Associated Type" print "sub directory/Op/Associated Type"
print print
table = [] table = []
...@@ -85,16 +85,17 @@ def print_compiledir_content(): ...@@ -85,16 +85,17 @@ def print_compiledir_content():
for dir in os.listdir(compiledir): for dir in os.listdir(compiledir):
file = None file = None
try: try:
file = open(os.path.join(compiledir, dir, "key.pkl")) try:
keydata = cPickle.load(file) file = open(os.path.join(compiledir, dir, "key.pkl"))
ops = list(set([x for x in flatten(keydata.keys) keydata = cPickle.load(file)
if isinstance(x, theano.gof.Op)])) ops = list(set([x for x in flatten(keydata.keys)
assert len(ops) == 1 if isinstance(x, theano.gof.Op)]))
types = list(set([x for x in flatten(keydata.keys) assert len(ops) == 1
if isinstance(x, theano.gof.Type)])) types = list(set([x for x in flatten(keydata.keys)
table.append((dir, ops[0], types)) if isinstance(x, theano.gof.Type)]))
except IOError: table.append((dir, ops[0], types))
pass except IOError:
pass
finally: finally:
if file is not None: if file is not None:
file.close() file.close()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论