提交 01c99eea authored 作者: notoraptor's avatar notoraptor

Also print compiled set of ops.

Try to make printing more readable.
上级 aa98984b
......@@ -93,6 +93,15 @@ def cleanup():
file.close()
def print_title(title, overline='', underline=''):
len_title = len(title)
if overline:
print(str(overline) * len_title)
print(title)
if underline:
print(str(underline) * len_title)
def print_compiledir_content():
"""
print list of %d compiled individual ops in the "theano.config.compiledir"
......@@ -101,8 +110,8 @@ def print_compiledir_content():
compiledir = theano.config.compiledir
table = []
table_multiple_ops = []
table_op_class = {}
more_than_one_ops = 0
zeros_op = 0
big_key_files = []
total_key_sizes = 0
......@@ -122,8 +131,6 @@ def print_compiledir_content():
table_op_class[op_class] += 1
if len(ops) == 0:
zeros_op += 1
elif len(ops) > 1:
more_than_one_ops += 1
else:
types = list(set([x for x in flatten(keydata.keys)
if isinstance(x, theano.gof.Type)]))
......@@ -136,7 +143,12 @@ def print_compiledir_content():
compile_end = os.path.getmtime(
os.path.join(compiledir, dir, fn))
compile_time = compile_end - compile_start
table.append((dir, ops[0], types, compile_time))
if len(ops) == 1:
table.append((dir, ops[0], types, compile_time))
else:
ops_to_str = '[%s]' % ', '.join(sorted(str(op) for op in ops))
types_to_str = '[%s]' % ', '.join(sorted(str(t) for t in types))
table_multiple_ops.append((dir, ops_to_str, types_to_str, compile_time))
size = os.path.getsize(filename)
total_key_sizes += size
......@@ -148,16 +160,25 @@ def print_compiledir_content():
except IOError:
pass
print("List of %d compiled individual ops in this theano cache %s:" % (
len(table), compiledir))
print("sub dir/compiletime/Op/set of different associated Theano types")
print_title("Theano cache: %s" % compiledir, overline='=', underline='=')
print()
print_title("List of %d compiled individual ops" % len(table), underline='+')
print_title("sub dir/compiletime/Op/set of different associated Theano types", underline='-')
table = sorted(table, key=lambda t: str(t[1]))
for dir, op, types, compile_time in table:
print(dir, '%.3fs' % compile_time, op, types)
print()
print(("List of %d compiled Op classes and "
"the number of times they got compiled" % len(table_op_class)))
print_title("List of %d compiled sets of ops" % len(table_multiple_ops), underline='+')
print_title("sub dir/compiletime/Set of ops/set of different associated Theano types", underline='-')
table_multiple_ops = sorted(table_multiple_ops, key=lambda t: (t[1], t[2]))
for dir, ops_to_str, types_to_str, compile_time in table_multiple_ops:
print(dir, '%.3fs' % compile_time, ops_to_str, types_to_str)
print()
print_title(("List of %d compiled Op classes and "
"the number of times they got compiled" % len(table_op_class)), underline='+')
table_op_class = sorted(iteritems(table_op_class), key=lambda t: t[1])
for op_class, nb in table_op_class:
print(op_class, nb)
......@@ -176,13 +197,11 @@ def print_compiledir_content():
nb_keys = sorted(iteritems(nb_keys))
print()
print("Number of keys for a compiled module")
print("number of keys/number of modules with that number of keys")
print_title("Number of keys for a compiled module", underline='+')
print_title("number of keys/number of modules with that number of keys", underline='-')
for n_k, n_m in nb_keys:
print(n_k, n_m)
print(("Skipped %d files that contained more than"
" 1 op (was compiled with the C linker)" % more_than_one_ops))
print()
print(("Skipped %d files that contained 0 op "
"(are they always theano.scalar ops?)" % zeros_op))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论